Application Development 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: 

BAPI or FM to create outbound delivery from Sales order

Former Member
0 Kudos

Hello All,

My requirement is to create a outbound delivery from sales order. Also i need the batch number and texts to be updated in the delivery.

For this i need a single FM. The catch is that we don't have the batch number and texts in the sales order. That i have to take from some other delivery. I can get all the information .

The problem is that i can not find a FM through which i can create the delivery from the order and update the same.

I should not use two FM.

Could you please tell me some FM which does both in one go?

Thanks and Regards,

Rahul Sinha

9 REPLIES 9

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

Hi,

You can use the BAPI BAPI_DELIVERYPROCESSING_EXEC.

Check this sample code..

PARAMETERS: p_vbeln LIKE vbak-vbeln.

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,

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_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.

SELECT vbeln posnr kwmeng matnr werks

INTO TABLE t_vbap

FROM vbap

WHERE vbeln = p_vbeln.

LOOP AT t_vbap.

t_request-document_numb = t_vbap-vbeln.

t_request-document_item = t_vbap-posnr.

t_request-quantity_sales_uom = t_vbap-kwmeng.

t_request-id = 1.

t_request-document_type = 'A'.

t_request-delivery_date = sy-datum.

t_request-material = t_vbap-matnr.

t_request-plant = t_vbap-werks.

t_request-date = sy-datum.

t_request-goods_issue_date = sy-datum.

t_request-goods_issue_time = sy-uzeit.

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'.

ENDIF.

COMMIT WORK.

READ TABLE t_created INDEX 1.

Write: / 'Delivery ', t_created-document_numb.

Regards,

Sreeram

0 Kudos

Hello Sreeram,

This is not working.

No delivery is created. I gave the same values that you passed.Plus i passed the batch number which is not present in the sales order.

There was no error returned . The return table was empty and the created table was also empty.

Could you please check this and let me know if something is missing?

I need it urgently.

Thanks for the reply in advance.

Rahul

0 Kudos

Hello Sreeram,

The delivery is created but the batch number is not updated.

I gave the same values that you passed.Plus i passed the batch number which is not present in the sales order.

There was no error returned . The return table was empty .

Could you please check this and let me know if something is missing?

I need it urgently.

Thanks for the reply in advance.

Rahul

0 Kudos

Hello,

I think i was not clear enough in my last posts.

My requirement is to create a delivery from the sales order and at the same time update the batch number and texts in the same delivery using a FM or BAPI. I need a single BAPI or FM to do both operations in one go.

The batch number and the texts will not be available in the sales order.

Problem is that the delivery is replicated to other system as soon as it is created in one system using IDOC.So i can not use two FM's to create and update the delivery.

I tried the BAPI's and FM's but they are not updating the details..atleast batch number shud be updated.

Please let me know ASAP.

Thanks and Regards,

Rahul Sinha

0 Kudos

Hi,

You can do one thing.

First update the BATCH and item text details to Sales order. Then you create a delievry W.r.t the Sales order.

May be this solves your problem,

Hope this helps you.

Thanks,

CS REddy

0 Kudos

Hello CS,

This is the constraint. I am not suppose to update the sales order because of business requirements.

Could you please suggest any other way?

Thanks and Regards,

Rahul Sinha

0 Kudos

Hi Rahul,

Try to do with BDC. Using BDC you can create every thing at one go..

Thanks.

0 Kudos

Hello Rahul,

I've just the same problem, I need to update the batch and a Z field. Could you resolve this without a BDC recording?

Thanks in advance.

Former Member

Hi,

Try

BAPI_OUTB_DELIVERY_CREATE_SLS - Create delivery with reference to Sales Order

BAPI_OUTB_DELIVERY_SAVEREPLICA BAPI Function Module for Replication of Outbound Deliveries

BAPI_DELIVERYPROCESSING_EXEC Delivery Processing: Deliver Preceding Document, Expand Delivery

or Function module: SHP_VL10_DELIVERY_CREATE

RV_DELIVERY_CREATE