Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_OUTB_DELIVERY_CREATE_STO

Former Member
0 Likes
3,194

Hi Experts,

I am using  BAPI_PO_CREATE1  to POs for open PRs, and after creting POs i am using Bapi commit as well and also Wait stmt is used for 5 sconds. After that i am trying create delivery for the created PO just now. BAPI_OUTB_DELIVERY_CREATE_STO is used for creating the Delivery, but i am getting error saying that PO is already delivered or PO is not for delivery relevant. But when i use BAPI is directly using SE37 and able to create Delivery. Please help.

Warm regards,

Rajesh

Hi Experts,

I am using  BAPI_PO_CREATE1  to POs for open PRs, and after creting POs i am using Bapi commit as well and also Wait stmt is used for 5 sconds. After that i am trying create delivery for the created PO just now. BAPI_OUTB_DELIVERY_CREATE_STO is used for creating the Delivery, but i am getting error saying that PO is already delivered or PO is not for delivery relevant. But when i use BAPI is directly using SE37 and able to create Delivery. Please help.

Warm regards,

Rajesh

9 REPLIES 9
Read only

raghug
Active Contributor
0 Likes
2,824

If SE37 works and your program does not, the first step would be to check if all the relevant fields are properly sent through their conversion exits. Your delivery number for example will have to padded with zeros in front.

Read only

Former Member
0 Likes
2,824

In addition to the above reply, you can check the type of PO created.

Thanks,

Sowbhagya

Read only

0 Likes
2,824

i have used CONVERSION_EXIT_ALPHA_INPUT for the PO created and passed the same to to Bapi, but getting same error. "Order item XXX  already delivered or not delivery relevant " Message  ID V50R no 062".

Read only

0 Likes
2,824

All the relevant fields need to be zero padded correctly, including the item, material, etc.

Read only

0 Likes
2,824

i checked and found that some Delivery no is created and showed in the import parameters on BAPI when i execute directly from SE37 but not updated in concern PO with PO History tab. That means its also not directly executing SE37 also not working i guess. If its true then what could be missing in the PO or some other ? Pl advise 

Read only

0 Likes
2,824

You have to use BAPI_TRANSACTION_COMMIT after the first call for the data to be written to the database.

Read only

0 Likes
2,824

below is the code.

CALL FUNCTION 'BAPI_PO_CREATE1'
       EXPORTING
         poheader         = wa_poheader
         poheaderx        = wa_poheaderx
       IMPORTING
         exppurchaseorder = lv_po
       TABLES
         return           = it_return
         poitem           = it_poitem
         poitemx          = it_poitemx.
     READ TABLE it_return WITH KEY type = 'E' TRANSPORTING NO FIELDS.
     IF sy-subrc = 0.
       lv_po_message = wa_return-message.
       CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
     ELSE.
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
         EXPORTING
           wait = c_wait.
       CLEAR : it_return,it_poitem,it_poitemx.
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
           input  = lv_po
         IMPORTING
           output = wa_stock_item-ref_doc.
       SELECT SINGLE * FROM ekpv INTO wa_ekpv
         WHERE ebeln = lv_po.
*      wa_stock_item-ref_doc = lv_po.
       wa_stock_item-ref_item = wa_ekpv-ebelp .
       APPEND wa_stock_item-ref_doc TO it_stock_item.
       CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_STO'
         EXPORTING
           ship_point        = wa_ekpv-vstel
         IMPORTING
           delivery          = lv_delno
         TABLES
           stock_trans_items = it_stock_item
           return            = it_return.
       READ TABLE it_return WITH KEY type = 'E' TRANSPORTING NO FIELDS.
       IF sy-subrc = 0.
         lv_del_message = wa_return-message.
         CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
       ELSE.
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             wait = c_wait.

Read only

0 Likes
2,824

Re-reading this, it looks like you are saying that the BAPI call is now working and you have a delivery created. But, this delivery that is created is not showing up in the document flow. Is this correct? Or, is the delivery not actually created still, did you check the delivery tables or VL03n?

If it is still failing, did you check what is actually in the it_return in the debugger? If you are still testing in SE37, did you set up a Test Sequence to run the BAPI_TRANSACTION_COMMIT after the BAPI_OUTB_DELIVERY_CREATE_STO?

Read only

Former Member
0 Likes
2,824

This message was moderated.