onhand_new1

Upload: sridharvishwanath

Post on 10-Feb-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/22/2019 Onhand_NEW1

    1/5

    DECLARECURSOR c_11i_invIS

    SELECT item_id, whse_code, lot_id, LOCATION, loct_onhandFROM ic_loct_inv

    WHERE whse_code = 'SCP' AND item_id IN (72453);--- (183422);

    v_trx_id NUMBER;v_lot VARCHAR2 (50);v_exp_date DATE;v_item_id NUMBER;v_org NUMBER;v_item VARCHAR2 (100);v_uom VARCHAR2 (25);v_subinv VARCHAR2 (25);v_loc_id NUMBER;v_lcontrol NUMBER;v_lot_num VARCHAR2 (50);l_transaction_type_id NUMBER;l_source_id NUMBER;l_inventory_location_id NUMBER;l_account_id NUMBER;

    BEGINFOR v_rec IN c_11i_invLOOP

    dbms_output.put_line('item_id : '||v_rec.item_id );dbms_output.put_line(' whse_code: '||v_rec.whse_code );dbms_output.put_line('lot_id : '||v_rec.lot_id );dbms_output.put_line(' LOCATION: '||v_rec.LOCATION );dbms_output.put_line(' loct_onhand: '||v_rec.loct_onhand );

    --To get transaction_idBEGIN

    SELECT mtl_material_transactions_s.NEXTVAL

    INTO v_trx_idFROM DUAL;END;

    dbms_output.put_line('v_trx_id:'||v_trx_id );--Source Type R12BEGIN

    SELECTTRANSACTION_SOURCE_TYPE_ID

    INTO l_Source_idFROM mtl_txn_source_types

    WHERE TRANSACTION_SOURCE_TYPE_NAME = 'Account';END;

    dbms_output.put_line('l_transaction_type_id:'||l_transaction_type_id );

    BEGINSELECT transaction_type_id

    INTO l_transaction_type_idFROM mtl_transaction_types

    WHERE transaction_type_name = 'Account receipt';END;

    dbms_output.put_line('l_transaction_type_id:'||l_transaction_type_id );

  • 7/22/2019 Onhand_NEW1

    2/5

    SELECT code_combination_idINTO l_account_idFROM gl_code_combinations_kfv

    WHERE concatenated_segments = '01.01.1031.08.000.000.0000.000';

    dbms_output.put_line('l_account_id:'||l_account_id );

    --Item validation from 11iBEGIN

    SELECT item_no, item_umINTO v_item, v_uomFROM ic_item_mst

    WHERE item_id = v_rec.item_idand rownum=1;

    END;dbms_output.put_line('v_item:'||v_item );dbms_output.put_line('v_uom:'||v_uom );

    --Item and ORG validation from R12BEGIN

    SELECT inventory_item_id, organization_idINTO v_item_id, v_org

    FROM mtl_system_items_bWHERE SEGMENT1 = v_itemAND organization_id = (SELECT organization_id

    FROM org_organization_definitionsWHERE organization_code = v_rec.whse_code);

    END;dbms_output.put_line('v_item_id:'||v_item_id );dbms_output.put_line('v_org:'||v_org);

    SELECT inventory_location_id

    INTO l_inventory_location_idFROM mtl_item_locations

    WHERE organization_id = v_org AND segment1 = v_rec.LOCATION;

    dbms_output.put_line('l_inventory_location_id:'||l_inventory_location_id);

    --To get LOT numbers from 11iBEGIN

    SELECT lot_noINTO v_lot_numFROM ic_lots_mst

    WHERE lot_id = v_rec.lot_id;END;

    dbms_output.put_line('v_lot_num is:'||v_lot_num );

    --Lot data validation from R12BEGIN

    SELECT lot_number, expiration_dateINTO v_lot, v_exp_dateFROM mtl_lot_numbers

    WHERE lot_number = v_lot_numAND organization_id = v_organd rowNUM =1;

    -- AND inventory_item_id = 21907;--v_rec.item_id;

  • 7/22/2019 Onhand_NEW1

    3/5

    END;dbms_output.put_line('v_lot:'||v_lot );

    -- lot control code validation in R12BEGIN

    SELECT lot_control_codeINTO v_lcontrolFROM mtl_system_items_b

    WHERE inventory_item_id = v_item_id AND organization_id = v_org;END;

    dbms_output.put_line(' v_lcontrol:'|| v_lcontrol);--sub inventory validationBEGIN

    SELECT secondary_inventory_nameINTO v_subinvFROM mtl_secondary_inventories

    WHERE organization_id = v_org;END;

    dbms_output.put_line(' v_subinv:'||v_subinv);

    -- Locators validationBEGIN

    SELECT inventory_location_idINTO v_loc_id

    FROM mtl_item_locationsWHERE organization_id = v_orgAND subinventory_code = v_subinvAND segment1 = v_rec.LOCATION;

    END;dbms_output.put_line(' v_loc_id:'||v_loc_id);

    ----------------------------------------------------

    --insert into MTL_TRANSACTION_LOTS_INTERFACEINSERT INTO apps.mtl_transaction_lots_interface

    (transaction_interface_id,source_code,

    source_line_id,last_update_date,last_updated_by,creation_date,

    created_by,lot_number,lot_expiration_date,transaction_quantity,primary_quantity

    )VALUES (v_trx_id,

    l_transaction_type_id,0,

    SYSDATE,0,SYSDATE,0,v_lot,v_exp_date,v_rec.loct_onhand,v_rec.loct_onhand

    );/*

  • 7/22/2019 Onhand_NEW1

    4/5

    insert intoMTL_TRANSACTION_LOTS_INTERFACE(TRANSACTION_INTERFACE_ID,source_code,LOT_NUMBER,LOT_EXPIRATION_DATE,TRANSACTION_QUANTITY,PRIMARY_QUANTITY,CREATION_DATE,LAST_UPDATE_DATE,CREATED_BY,LAST_UPDATED_BY)values(v_trx_id,L_SOURCE_ID,v_lot,v_exp_date,v_rec.loct_onhand,v_rec.loct_onhand,SYSDATE,SYSDATE,NVL(fnd_global.USER_ID,-1),--PLEASE PUT VALID USER HERENVL(fnd_global.USER_ID,-1)--PLEASE PUT VALID USER HERE);

    */

    -- insert into MTL_TRANSACTION_INTERFACEINSERT INTO apps.mtl_transactions_interface

    (source_code,source_line_id,source_header_id,process_flag,transaction_mode,transaction_interface_id,inventory_item_id,organization_id,subinventory_code,

    locator_id,transaction_quantity,transaction_uom,transaction_date,transaction_type_id,transaction_source_id,transaction_source_name,distribution_account_id,last_update_date,last_updated_by,creation_date,created_by

    )

    VALUES (l_Source_id, --source_cod0, --source_line_id0, --source_header_id1, --process_flag2, --transaction_modev_trx_id, --transaction_interface_idv_item_id, --inventory_item_idv_org, --organization_idv_subinv, --subinventory_codel_inventory_location_id, --locator_id

  • 7/22/2019 Onhand_NEW1

    5/5

    v_rec.loct_onhand, --transaction_quantityv_uom, -- transaction_uomSYSDATE, --transaction_datel_transaction_type_id, --transaction_type_idl_account_id,'CONV',l_account_id,SYSDATE,

    0,SYSDATE,0

    );

    /*INSERT INTO mtl_transactions_interface

    (source_header_id,source_line_id,transaction_mode,source_code,process_flag,transaction_interface_id,transaction_date,inventory_item_id,

    transaction_uom,organization_id,subinventory_code,locator_id,transaction_quantity,transaction_type_id,transaction_source_type_id,created_by,

    creation_date,last_updated_by,

    last_update_date)values

    ( 1000,

    0,2,'OH Quantity',1,v_trx_id,sysdate,v_item_id,v_uom,v_org,v_subinv,

    v_loc_id,v_rec.loct_onhand,40, -- transaction_type_id

    13 ,--transaction_source_type_idNVL(fnd_global.user_id,-1),SYSDATE,NVL(fnd_global.user_id,-1),SYSDATE);

    */END LOOP;

    END;