跳到主要內容

更新或建立 ITEM CATEGORY


 DECLARE
  
   CURSOR C3 IS
   SELECT TRIM(A ) item_number, TRIM(D) g01
     FROM TMP_CCC
    where TRIM(d) is not null;

    v_process_id                    number;
    v_inventory_item_id                number;
    v_item_insert                   number:=0 ;
    v_category_id                    number;
    v_po_category_set_id            number;
    v_om_category_set_id            number;
    v_item_count                     number:=0 ;
    v_count1                        number:=0 ;
    v_request_id                    number;
    v_organization_id                number;
    xx_ls_phase                     varchar2(240 );
    xx_ls_status                    varchar2(240 );
    xx_ls_dummy1                    varchar2(240 );
    xx_ls_dummy2                    varchar2(240 );
    xx_ls_dummy3                    varchar2(240 );
    xx_lb_return                    boolean;
    v_buyer_id                        number;
    v_planner_code                    number;
    v_template_id                     number;
    v_template_name                    varchar2(30 );
    x_item_id                          number;
    dummy                                number;
    x_category_id                    number;
    v_uom                                varchar2(10 );
    v_weight_uom                    varchar2(10 );
    x_errbuf                           VARCHAR2(200 );
  x_retcode                          VARCHAR2(200 );
  V_CATEGORY_SET_ID_O   number;
  V_CATEGORY_ID_O       number;
  V_CATEGORY_CONCAT_SEGS   VARCHAR2(163 );
  V_CATEGORY_SET_ID     number;
  v_exist               VARCHAR2(1 ):= 'N';
BEGIN

DBMS_APPLICATION_INFO.SET_CLIENT_INFO (84);    --Organization_ID
--DBMS_APPLICATION_INFO.SET_CLIENT_INFO(FND_PROFILE.VALUE('LANG'));

    select    Mtl_system_items_intf_sets_s.nextval
    into     v_process_id
    from     dual;

  v_exist := 'N';

    for r in c3 loop
        v_exist := 'Y';

            begin
                select a.CATEGORY_ID
                        ,b. category_set_id
                into    v_category_id
                        ,v_po_category_set_id
                from     mtl_categories_b_kfv a
                        ,MTL_CATEGORY_SETS_V b
                WHERE     a.structure_id = b .structure_id
                and          b.CATEGORY_SET_NAME = 'Group01'    --只更新指定的Category Name
                and          a.CONCATENATED_SEGMENTS = r .g01;
            exception
                when others then
                     v_category_id := '';
                     v_po_category_set_id := '';
            end;
           
            select inventory_item_id into  v_inventory_item_id from mtl_system_items_b where segment1=r.item_number
                and organization_id=84 ;

            if v_category_id is not null then
           BEGIN
              SELECT CATEGORY_SET_ID, CATEGORY_ID, CATEGORY_CONCAT_SEGS
                INTO V_CATEGORY_SET_ID_O, V_CATEGORY_ID_O, V_CATEGORY_CONCAT_SEGS
                FROM MTL_ITEM_CATEGORIES_V A,
                     MTL_SYSTEM_ITEMS_B B
               WHERE A.Organization_id = B .Organization_id
                 AND A.Organization_id = 84
                 AND A.INVENTORY_ITEM_ID = B .INVENTORY_ITEM_ID
                 AND A.STRUCTURE_ID = 50272
                 AND B.SEGMENT1 = trim(upper( r.item_number ));
           EXCEPTION
              WHEN OTHERS THEN
                   V_CATEGORY_SET_ID_O := '';
                   V_CATEGORY_ID_O := '';
                   V_CATEGORY_CONCAT_SEGS := '';
           END;
                    BEGIN
                      IF V_CATEGORY_CONCAT_SEGS IS NOT NULL AND V_CATEGORY_CONCAT_SEGS ! = r.FUHSING_STOCKER THEN
                           Insert into MTL_Item_Categories_Interface (
                                                            inventory_item_id,
                                                            Organization_id,
                                                            Transaction_type,
                                                            process_flag,
                                                            Item_number,
                                                            Set_process_id,
                                                            category_set_id,
                                                            category_id,
                                                            OLD_CATEGORY_ID)
                                                    Values(
                                                             v_inventory_item_id,
                                                            84,
                                                            'UPDATE',
                                                             1,
                                                            trim(upper(r. item_number)),
                                                            v_process_id,
                                                            V_CATEGORY_SET_ID_O,
                                                            v_category_id,  -- NEW_CATEGORY_ID
                                                            V_CATEGORY_ID_O -- OLD_CATEGORY_ID
                              );

                      END IF;

                      IF V_CATEGORY_CONCAT_SEGS IS NULL THEN
                         Insert into MTL_Item_Categories_Interface (
                                                               inventory_item_id,
                                                               Organization_id,
                                                               last_update_date,
                                                               last_updated_by,
                                                               creation_date,
                                                               ----------------------5
                                                               created_by,
                                                               last_update_login,
                                                               category_set_id,
                                                               category_id,
                                                               Transaction_type,
                                                               ----------------------10
                                                               process_flag,
                                                               Item_number,
                                                               Set_process_id
                                                       )Values(
                                                               v_inventory_item_id,
                                                               84,
                                                               sysdate,
                                                               fnd_profile.VALUE('USER_ID' ),--fnd.user,
                                                               sysdate,
                                                               ----------------------5
                                                               fnd_profile.VALUE('USER_ID' ),--fnd.user,
                                                               fnd_profile.VALUE('USER_ID' ),--fnd.user,
                                                               v_po_category_set_id,
                                                               v_category_id,
                                                               'CREATE',
                                                               ----------------------10
                                                               1,
                                                               trim(upper(r. item_number)),
                                                               v_process_id
                                                               );
            END IF;
                  END;
            end if;   

        commit;

    end loop;

END;
/

執行完上述的PL/SQL之後,可以到ERP來執行。

1、找出set_process_id

select set_process_id from   mtl_item_categories_interface ;


2、執行ERP,填入Set_Process_id





留言

這個網誌中的熱門文章

Line如何換行

在電腦版的Line輸入文字時,遇到需要換行的情形時,我都是用記事本先寫好再複製上去,這樣就可以有換行的效果,可是這樣的做法好像失去Line的便利性。 於是查了一下,原來有一個設定可以指定Enter換行,而不是發訊息出去。 完成設定之後,要發送訊息就改用Alt+Enter,而Enter就可以換行了。

在Windows下,利用tasklist與taskkill來刪除Process

Windows7 / Windows8 kill process Linux下要刪除某個程序通常會使用 ps 配合 kill 來刪除程序。 例如:ps -ef |grep [PROCESS NAME]       kill -9 [PID] 在Windows下,通常是開啟工作管理員來強制結束應用程式,但是如果要寫成Script,就必須改為命令式。 TASKLIST [/S system [/U username [/P [password]]]]          [/M [module] | /SVC | /V] [/FI filter] [/FO format] [/NH]           TASKKILL [/S system [/U username [/P [password]]]]          { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]           (Tasklist:查詢Process ; Taskkill:刪除Process)           例如要刪除已開啟的記事本(notepad): 1、查詢記事本的Process訊息     C:\> tasklist |find /i "notepad.exe"     notepad.exe      6092 Console     1     5,832 K 2、由上得知記事本的PID為6092     C:\> taskkill /f /PID 6092     成功:處理程序 PID 6092 已經終止了。     taskkill使用的參數     /f:指定此參數可強制終止處理程序     /PID:指定要終止之處理程序的 PID      3、也可以直接以程式名稱刪除     C:\ taskkill /f /im notepad.exe     成功:處理程序 "notepad.exe" <PID 6092> 已經終止了      下面是我自己測試的Script,可以刪除多個相同的程式,例如同時開啟了三個記事本: @echo off for /f &quo

Win 10 工作排程無法執行bat批次檔

利用Win 10的工作排程器來設定每日自動執行的批次檔,單獨執行批次檔沒問題,但是放在排程上就是無法執行。 後來試了幾種網路上提供的方式,其注意的事項如下: 1、在「安全性選項」選擇「只有使用者登入時才執行」並取消「以最高權限執行」。 2、在「設定」中選擇「Windows 10」 3、批次檔內的執行檔需以完整的路徑執行,或設定PATH路徑。 3、批次檔中如果帶有中文的路徑,則文字編碼類型必需是ANSI碼,       我的批次檔一開始就是UTF-8碼,但是單獨執行沒有問題,排程上就是有問題,       最後在批次檔中加入暫停指令pause才發現的。 4、如果想選擇「不論使用者登入與否均執行」,則在「設定」必須選擇「Windows Server 2003、Windows XP或Windows 2000」,    但是上述的選項只有在新增工作程程時才會出現,原有的工作排程是不會有此選項