1 Reply Latest reply on Jan 19, 2016 2:25 PM by Srini Chavali-Oracle

    inv_move_order_pub.process_move_order API Issue

    Imran Yaqoob

      hi guyz,

      I hope all you r going well

       

      I am facing again an issue in subject mention API.

      This api is not creating more then one line at Move Order Form , if more then one rows found in cursor it creates different move orders but not same move order with different lines.

       

      Kindlyyyy help....

       

      PROCEDURE CREATE_MOVE_ORDER_API(errbuf OUT varchar2, retcode OUT varchar2,v_receipt_no number)

      IS

            l_hdr_rec         inv_move_order_pub.trohdr_rec_type              := inv_move_order_pub.g_miss_trohdr_rec;

            l_line_tbl        inv_move_order_pub.trolin_tbl_type              := inv_move_order_pub.g_miss_trolin_tbl;

            x_return_status   VARCHAR2 (1);

            x_msg_count       NUMBER;

            x_msg_data        VARCHAR2 (4000);

            x_hdr_rec         inv_move_order_pub.trohdr_rec_type              := inv_move_order_pub.g_miss_trohdr_rec;

            x_hdr_val_rec     inv_move_order_pub.trohdr_val_rec_type;

            x_line_tbl        inv_move_order_pub.trolin_tbl_type;

            x_line_val_tbl    inv_move_order_pub.trolin_val_tbl_type;

            v_msg_index_out   NUMBER;

            l_rsr_type        inv_reservation_global.mtl_reservation_tbl_type;

          

            cursor h is

            select a.RECEIPT_NUM,a.organization_id,b.item_id,b.LINE_NUM,b.QUANTITY_RECEIVED,msi.PRIMARY_UOM_CODE,b.SHIPMENT_LINE_ID

      from RCV_SHIPMENT_HEADERS a,RCV_SHIPMENT_LINES b,mtl_system_items_b_kfv msi

      WHERE a.SHIPMENT_HEADER_ID = b.SHIPMENT_HEADER_ID

      and msi.inventory_item_id = b.item_id

      and msi.organization_id = a.organization_id

      and msi.segment1 not like 'FG%'

      and msi.segment1 not like 'PR%'

      and msi.segment1 not like 'BB%'

      and a.RECEIPT_NUM = v_receipt_no;

       

       

      BEGIN 

              for i in H

          LOOP

        

            l_line_tbl.DELETE;

            x_line_tbl.DELETE;

            l_hdr_rec.date_required := SYSDATE;

            l_hdr_rec.header_status := inv_globals.g_to_status_preapproved;

            l_hdr_rec.organization_id := i.ORGANIZATION_ID;-- ; ---- fill in the values for ORganization_ID

            l_hdr_rec.status_date := SYSDATE;

            l_hdr_rec.transaction_type_id := 63;--inv_globals.g_type_transfer_order_issue;

            l_hdr_rec.move_order_type := inv_globals.g_move_order_requisition;

            l_hdr_rec.db_flag := fnd_api.g_true;

            l_hdr_rec.operation := inv_globals.g_opr_create;

            l_hdr_rec.description := null;

            l_hdr_rec.to_account_id := 11329;

            l_hdr_rec.from_subinventory_code := 'TechStore';

       

       

       

           l_line_tbl (1).date_required := SYSDATE;

            l_line_tbl (1).inventory_item_id := i.ITEM_ID; --------- XXXXXXXX will be your Inventory item id

            l_line_tbl (1).line_id := fnd_api.g_miss_num;

            l_line_tbl (1).line_number := 1;--i.LINE_NUM;

            l_line_tbl (1).line_status := inv_globals.g_to_status_preapproved;

            l_line_tbl (1).transaction_type_id := 63;--inv_globals.g_type_transfer_order_issue;

            l_line_tbl (1).organization_id := i.ORGANIZATION_ID;--ORG_ID ; ---- fill in the values for ORganization_ID

            l_line_tbl (1).quantity := i.QUANTITY_RECEIVED; --------- XX will be the QTY

            l_line_tbl (1).status_date := SYSDATE;

            l_line_tbl (1).uom_code := i.PRIMARY_UOM_CODE;  -- UOM code

            l_line_tbl (1).db_flag := fnd_api.g_true;

            l_line_tbl (1).operation := inv_globals.g_opr_create;

            l_line_tbl (1).from_subinventory_code := 'TechStore';

            l_line_tbl (1).to_account_id := 11329;

            --l_line_tbl (1).lot_number := XXX;                                                 -- use this If the item is lot controlled

            --l_line_tbl (1).serial_number_start := 'XXXXXX';                                 -- use this If the item is serial number controlled

            --l_line_tbl (1).serial_number_end := 'XXXXXX';                                   -- use this If the item is serial number controlled

            inv_move_order_pub.process_move_order (p_api_version_number      => 1.0

                                                 , p_init_msg_list           => fnd_api.g_false

                                                 , p_return_values           => fnd_api.g_false

                                                 , p_commit                  => fnd_api.g_false

                                                 , x_return_status           => x_return_status

                                                 , x_msg_count               => x_msg_count

                                                 , x_msg_data                => x_msg_data

                                                 , p_trohdr_rec              => l_hdr_rec

                                                 , p_trolin_tbl              => l_line_tbl

                                                 , x_trohdr_rec              => x_hdr_rec

                                                 , x_trohdr_val_rec          => x_hdr_val_rec

                                                 , x_trolin_tbl              => x_line_tbl

                                                 , x_trolin_val_tbl          => x_line_val_tbl

                                                  );

            apps.fnd_file.put_line

                      (apps.fnd_file.output,

                      --'Return Status is :' || x_return_status ||

                      --'Message Count is :' || x_msg_count ||

                      'Move Order Number is :' || x_hdr_rec.request_number ||

                      'Number of Lines Created are :' || x_line_tbl.COUNT);      

            /*DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);

            DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);

            DBMS_OUTPUT.put_line ('Move Order Number is :' || x_hdr_rec.request_number);

            DBMS_OUTPUT.put_line ('Number of Lines Created are :' || x_line_tbl.COUNT);*/

      end loop;

            IF x_return_status = 'S'

            THEN

               COMMIT;

            ELSE

               ROLLBACK;

            END IF;

       

       

            IF x_msg_count > 0

            THEN

               FOR v_index IN 1 .. x_msg_count

               LOOP

                  fnd_msg_pub.get (p_msg_index => v_index, p_encoded => 'F', p_data => x_msg_data, p_msg_index_out => v_msg_index_out);

                  x_msg_data := SUBSTR (x_msg_data, 1, 200);

                  apps.fnd_file.put_line

                      (apps.fnd_file.output,'Error Message :' || x_msg_data);

                  /*DBMS_OUTPUT.put_line (x_msg_data);

                  DBMS_OUTPUT.put_line ('============================================================');*/

               END LOOP;

            END IF;

         END;