Friday, 27 January 2012

Item Classification program for New Items


CREATE OR REPLACE procedure APPS.XXXXXX_INV_ITEM_CLASSIFI_P (ERRBUF OUT VARCHAR2,RETCODE OUT NUMBER, ln_temp_id IN NUMBER,ln_organization_id IN NUMBER, ln_inventory_item_id IN NUMBER) IS
CURSOR lcur_rgn (ln_organization_id NUMBER) IS
SELECT   templ_org_regns_id
    FROM jai_templ_org_regns
   WHERE template_id = ln_temp_id
     AND organization_id IN (
            SELECT   inventory_organization_id
                FROM hr_locations
               WHERE inactive_date IS NULL
                 AND inventory_organization_id IS NOT NULL
                 AND inventory_organization_id =
                           NVL (ln_organization_id, inventory_organization_id)
            GROUP BY inventory_organization_id)
            ORDER BY 1;
 ln_org_regns NUMBER;
Begin
  For i in lcur_rgn(ln_organization_id)  loop
    Exit when lcur_rgn%notfound;
    Begin
    SELECT templ_org_regns_id
     INTO ln_org_regns
     FROM jai_templ_itm_regns
     WHERE templ_org_regns_id = i.templ_org_regns_id
     AND inventory_item_id = ln_inventory_item_id;
    Exception
       When Others then
       ln_org_regns:=null;
    End;
   If ln_org_regns is null THEN
   INSERT INTO jai_templ_itm_regns
            (templ_itm_regns_id, templ_org_regns_id,
             inventory_item_id, creation_date, created_by,
             last_update_date, last_update_login, last_updated_by
            )
     VALUES (jai_templ_itm_regns_s.NEXTVAL, i.templ_org_regns_id,
             ln_inventory_item_id, SYSDATE, fnd_profile.VALUE ('USER_ID'),
             SYSDATE, fnd_profile.value('LOGIN_ID'), fnd_profile.VALUE ('USER_ID')
            );
   End if;
  End loop;
  Commit;
End;

No comments:

Post a Comment