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 for creating Delivery

Former Member
0 Likes
7,987

hi experts ,

I want to create an Outbound Delivery with

reference to a Sales Order, using an rfc connection.

I can use VL01N or VL04 for this. But Iam exploring for any BAPI available

for this, i'm using BAPI_DELIVERYPROCESSING_EXEC, but doesn't return the document number , so if you can plz help me .

best regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,525

Bear in mind that this FM is not released for customer use. I couldn't find it in transaction BAPI, so I'm not sure you can even really call it a BAPI.

Rob

13 REPLIES 13
Read only

former_member191735
Active Contributor
0 Likes
6,525

That is the right BAPI to create outbound delivery. for the delivery number, you need to pass internal table for the parameter 'createditems ' and then after the execution, you can read the internal table 'document_numb' holds the document number.

Read only

0 Likes
6,525

the problem is that the table RETURN is not filled , so i can't not ensure whether the delivery document has been created or not.

Read only

0 Likes
6,525

As sampath suggested, you have to read the internal table passed for parameter createditems.

Read only

0 Likes
6,525

Return table only returns the messages but not the delivery number. Have you tried what i suggested? if yes, what was the result in the return parameter?

Not all bapi's are same. You need to read the documentation and search google as well as SDN before posting a question.

First of all, you need to try what others suggested before anything else.

If the return parameter has nothing, that is also fine as you didnt get any errors. Read the other table that i mentioned early - you will get the document number.

Edited by: Sampath Kumar on May 17, 2011 3:08 PM

Read only

Former Member
0 Likes
6,525

Hi,

You can see the sample code to use the BAPI-BAPI_DELIVERYPROCESSING_EXEC

DATA: BEGIN OF t_vbap OCCURS 0,

vbeln LIKE vbap-vbeln,

posnr LIKE vbap-posnr,

kwmeng LIKE vbap-kwmeng,

matnr LIKE vbap-matnr,

werks LIKE vbap-werks,

lgort LIKE vbap-lgort,

vrkme LIKE vbap-vrkme,

END OF t_vbap.

*

DATA: t_request TYPE STANDARD TABLE OF bapideliciousrequest

WITH HEADER LINE.

*

DATA: t_created TYPE STANDARD TABLE OF bapideliciouscreateditems

WITH HEADER LINE.

*

DATA: t_sales TYPE STANDARD TABLE OF bapidlvreftosalesorder

WITH HEADER LINE.

*

DATA: t_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.

Select the fields from VBAP into internal table T_VBAP based on given Sales order No.

**

LOOP AT t_vbap.

t_request-document_type = 'A'.

t_request-document_numb = t_vbap-vbeln.

t_request-document_item = t_vbap-posnr.

t_request-material = t_vbap-matnr.

t_request-plant = t_vbap-werks.

t_request-stge_loc = t_vbap-lgort.

t_request-quantity_sales_uom = t_vbap-kwmeng.

t_request-delivery_date = sy-datum.

APPEND t_request.

ENDLOOP.

*

CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'

TABLES

request = t_request

createditems = t_created

return = t_return.

*

READ TABLE t_return WITH KEY type = 'E'.

IF sy-subrc = 0.

MESSAGE e208(00) WITH 'Delivery creation error'.

ELSE.

COMMIT WORK.

READ TABLE t_created INDEX 1.

WRITE: / 'Delivery ', t_created-document_numb.

ENDIF.

Otherwise, you can also use the below BAPI for creating Delivery.

***LOOP AT t_vbap.

      • t_sales-ref_doc = t_vbap-vbeln.

      • t_sales-ref_item = t_vbap-posnr.

      • t_sales-dlv_qty = t_vbap-kwmeng.

      • t_sales-sales_unit = t_vbap-vrkme.

      • APPEND t_sales.

***ENDLOOP.

***

***CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'

      • IMPORTING

      • delivery = l_delivery

      • num_deliveries = l_num

      • TABLES

      • sales_order_items = t_sales

      • return = t_return.

***

***READ TABLE t_return WITH KEY type = 'E'.

***

***IF sy-subrc = 0.

      • WRITE:/ 'Delivery creation error'.

***ELSE.

****COMMIT WORK.

      • WRITE: / 'Delivery ', l_delivery.

***ENDIF.

Regards,

Vimala P

Read only

0 Likes
6,525

HI Vimala,

Why only read all the messages in the tables. Just debug all the tables once what and all data is there in that.Post if help need.

Regards,

Madhu.

Read only

0 Likes
6,525

Hi,

You can try this also.

*---Fill all the details for BAPI Process

  • First create the delivery with main items and then call the change Bapi for

  • Batch determination

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'

IMPORTING

delivery = g_delivery

TABLES

sales_order_items = lt_soitem

deliveries = lt_delnum

created_items = lt_critems

return = lt_ret.

READ TABLE lt_ret WITH KEY type = 'E'

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

*---If required....

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'

EXPORTING

header_data = ls_head

header_control = ls_headc

delivery = g_delivery

TABLES

item_data = lt_delitem

item_control = lt_delitemc

return = lt_delret

item_data_spl = lt_itemspl.

READ TABLE lt_delret WITH KEY type = 'E'

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

endif.

endif.

Regards,

Goutam

Read only

Former Member
0 Likes
6,525

hi,

Please refer the following link.

Link: [;

Hope this will help you.

Regards,

Renuka S.

Read only

Former Member
0 Likes
6,525

hi,

thanks all for your answers , i can now get the document number but i still have a problem .

i'm creating a web portal where i have to create deliveries with reference to a sale order , the problem is that i need to show to the user of my portal the error messages (which should be in the table RETURN ) i pass an internal table for the parameter 'RETURN ' but it's not filled .

best regards

Read only

0 Likes
6,525

Tell the other users how and where you got the document number. Explain it to the people who answered your question by taking time.

For the return parameter.... .this will only be filled when there are any messages from the BAPI. For example, if you are trying to create a delivery for the item where there is no ATP then system generates the error message and pass through the return parameters.

read about API's.

Read only

0 Likes
6,525

Hi!

You did not mention which tool or technology you are using to invoke the BAPI. If it is from outside SAP like using the .NET Connector or BizTalk Adapter usually what happens is that you need to initialize the RETURN table parameter as empty, this means that the object must exists but with no rows on it, so when you get the response back you will see the errors or warnings.

In the project I was involved we used the BAPI_OUTB_DELIVERY_CREATE_SLS bapi which will return:

Export Parameter NUM_DELIVERIES will tell you how many deliveries where created

Tables:

DELIVERIES table containing all the deliveries that were created.

CREATED_ITEMS table containing the deliveries + delivery items created related to the Sales Order + Sales Order Item you provided.

I hope this helps.

Regards,

Read only

Former Member
0 Likes
6,526

Bear in mind that this FM is not released for customer use. I couldn't find it in transaction BAPI, so I'm not sure you can even really call it a BAPI.

Rob

Read only

Former Member
0 Likes
6,525

HI,

To get the document number I've passed an internal table for the parameter 'createditems ' which holds the document number 'document_numb' .

as a response to Mario Hernandez , i'm using SAPRFC with PHP .

best regards