Oracle EBS INV 挑库发放物料搬运单

create or replace PROCEDURE XX_TRANSACT_MO_LINE  
AS 
        -- Common Declarations
        l_api_version     NUMBER := 1.0; 
        l_init_msg_list     VARCHAR2(2) := FND_API.G_TRUE; 
        l_commit     VARCHAR2(2) := FND_API.G_FALSE; 
        x_return_status     VARCHAR2(2);
        x_msg_count     NUMBER := 0;
        x_msg_data               VARCHAR2(255);
          
        -- API specific declarations          
        l_move_order_type       NUMBER := 1;
        l_transaction_mode      NUMBER := 1;
        l_trolin_tbl            INV_MOVE_ORDER_PUB.trolin_tbl_type;
        l_mold_tbl              INV_MO_LINE_DETAIL_UTIL.g_mmtt_tbl_type;
        x_mmtt_tbl              INV_MO_LINE_DETAIL_UTIL.g_mmtt_tbl_type;
        x_trolin_tbl            INV_MOVE_ORDER_PUB.trolin_tbl_type;
        l_transaction_date      DATE := SYSDATE;   

        -- WHO columns
        l_user_id    NUMBER := -1;
  l_resp_id    NUMBER := -1;
         l_application_id  NUMBER := -1;
        l_row_cnt    NUMBER := 1;
        l_user_name    VARCHAR2(30) := 'MFG';
        l_resp_name    VARCHAR2(80) := 'Manufacturing and Distribution Manager';   

  l_mo_line_id          NUMBER  := 0;

BEGIN

      -- Get the user_id
      SELECT user_id
      INTO l_user_id
      FROM fnd_user
      WHERE user_name = l_user_name;
    
      -- Get the application_id and responsibility_id
      SELECT application_id, responsibility_id
      INTO l_application_id, l_resp_id
      FROM fnd_responsibility_vl
      WHERE responsibility_name = l_resp_name;
    
      FND_GLOBAL.APPS_INITIALIZE(l_user_id, l_resp_id, l_application_id);  -- Mfg / Mfg Dist Mgr / INV
      dbms_output.put_line('Initialized applications context: '|| l_user_id || ' '|| l_resp_id ||' '|| l_application_id );
      
      l_trolin_tbl(1).line_id := l_mo_line_id;

       -- call API to create move order header
       DBMS_OUTPUT.PUT_LINE('=======================================================');
       DBMS_OUTPUT.PUT_LINE('Calling INV_Pick_Wave_Pick_Confirm_PUB.Pick_Confirm API');        

      INV_PICK_WAVE_PICK_CONFIRM_PUB.Pick_Confirm
      (
            p_api_version_number     => l_api_version
        ,   p_init_msg_list       => l_init_msg_list
        ,   p_commit         => l_commit
        ,   x_return_status       => x_return_status
        ,   x_msg_count         => x_msg_count
        ,   x_msg_data         => x_msg_data
        ,   p_move_order_type        => l_move_order_type
        ,   p_transaction_mode       => l_transaction_mode
        ,   p_trolin_tbl             => l_trolin_tbl
        ,   p_mold_tbl         => l_mold_tbl
        ,   x_mmtt_tbl             => x_mmtt_tbl
        ,   x_trolin_tbl             => x_trolin_tbl
        ,   p_transaction_date       => l_transaction_date
      );

       DBMS_OUTPUT.PUT_LINE('=======================================================');
       DBMS_OUTPUT.PUT_LINE('Return Status: '||x_return_status);

       IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
          DBMS_OUTPUT.PUT_LINE('Message count: '||x_msg_count||' Error Message :'||x_msg_data);

            IF ( x_msg_count > 1 ) THEN
                FOR i IN 1 .. x_msg_count LOOP
                    x_msg_data := fnd_msg_pub.get ( p_msg_index => i , p_encoded =>FND_API.G_FALSE ) ;
                    dbms_output.put_line ( 'message :' || x_msg_data);
                END LOOP;
           END IF;
       END IF;
       
      DBMS_OUTPUT.PUT_LINE('=======================================================');

EXCEPTION
        WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE('Exception Occured :');
          DBMS_OUTPUT.PUT_LINE(SQLCODE ||':'||SQLERRM);
          DBMS_OUTPUT.PUT_LINE('=======================================================');
END XX_TRANSACT_MO_LINE;

  

posted on 2018-11-26 16:00  Jenrry  阅读(881)  评论(0编辑  收藏  举报