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: 

Delivery Bapi

Former Member
0 Kudos

Hi Friends,

I am trying to create delivery with reference to sales order number using bapi in my alv report. I am passing the parameters as:

IF GV_SALESDOCUMENT NE ''.

READ TABLE ITAB INTO WA INDEX 1.

CLEAR: GV_PLANT.

GV_PLANT = WA-WERKS.

LOOP AT ITAB INTO WA WHERE CUSTOMER = WA-CUSTOMER.

GS_DELV-REF_DOC = GV_SALESDOCUMENT.

GS_DELV-REF_ITEM = WA-POSNR.

GS_DELV-DLV_QTY = WA-ZMENG.

GS_DELV-SALES_UNIT = WA-ZIEME.

APPEND GS_DELV TO GT_DELV.

CLEAR GS_DELV.

ENDLOOP.

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'

EXPORTING

SHIP_POINT = GV_PLANT

DUE_DATE = SY-DATUM

IMPORTING

DELIVERY = GV_DELIVERY

TABLES

SALES_ORDER_ITEMS = GT_DELV

RETURN = GT_DELRETURN.

COMMIT WORK AND WAIT.

IF SY-SUBRC EQ 0.

ENDIF.

I am getting error in GT_DELRETURN while debuging - "No Schedule line due for delivery up to the selected date".

How can I handle this. Please correct me.

Thanks.

1 ACCEPTED SOLUTION

jack_graus2
Active Contributor
0 Kudos

Hi Nani, in the call to the BAPI you use the current date (SY-DATUM) as delivery date (DUE_DATE). But it looks like the order is not to be deliverd on that date (No Schedule line due for delivery up to the selected date).

You can check the delivery date in the sales order and pass that date to the BAPI either from your internal table ITAB or as input parameter.

Regards jack

18 REPLIES 18

jack_graus2
Active Contributor
0 Kudos

Hi Nani, in the call to the BAPI you use the current date (SY-DATUM) as delivery date (DUE_DATE). But it looks like the order is not to be deliverd on that date (No Schedule line due for delivery up to the selected date).

You can check the delivery date in the sales order and pass that date to the BAPI either from your internal table ITAB or as input parameter.

Regards jack

0 Kudos

Hi Jack,

Thanks for the response.

Is DUE_DATE from my function module equal to Requested Delivery date(VBAK-VDATU). It is still throwing me an error if I set the date 1 month forward from todays date.

Should my Schedule line date (VBEP-EDATU) should match Requested Delivery date(VBAK-VDATU)?

Please suggest.

Thanks.

Edited by: nani on May 24, 2011 9:56 AM

0 Kudos

VBAK-VDATU is the requested delivery date and VBEP-EDATU the actual date the goods are available for delivery. Best is to use VBEP-EDATU as delivery date for schedule lines that do have a delivery confirmation (VBEP-BMENG > 0).

Regards Jack

0 Kudos

If I choose, VBEP-EDATU, still it doesn't matter if my Requested delivery date and schedule line date are same. Right.

Please suggest.

0 Kudos

Well, the problem is with the ATP. Check the sales order in VA02/VA03 and double click on the order Item(s) and go to schedule lines tab then check for schedule lines.

For me, this is not a program error but the the available quantity in the reference sales order is not enough to create delivery.

However, for your ref.... the following code should work.

wa_request-document_type = 'A'.

wa_request-document_numb = vbap-vbeln.

wa_request-document_item = vbap-posnr.

wa_request-material = vbap-matnr.

wa_request-plant = vbap-werks.

wa_request-stge_loc = vbap-lgort.

wa_request-delivery_date = vbap-vdatu.

wa_request-quantity_base__uom = vbap-kbmeng.

append wa_Request to it_request.

It_request is the internal table which needs to be passed to request tables parameter of the bapi.

You don't need anything else to create a delivery with ref to order. The only thing you need is available quantity.

0 Kudos

Hi Sampath,

Thanks for the reply. This is what I have done. But it gives me the same error.

DATA:

GT_DELV TYPE STANDARD TABLE OF BAPIDLVREFTOSALESORDER,

GS_DELV TYPE BAPIDLVREFTOSALESORDER.

IF GV_SALESDOCUMENT NE ''.

READ TABLE ITAB INTO WA INDEX 1.

CLEAR: GV_PLANT.

GV_PLANT = WA-WERKS.

LOOP AT ITAB INTO WA WHERE CUSTOMER = WA-CUSTOMER.

GS_DELV-REF_DOC = GV_SALESDOCUMENT.

GS_DELV-REF_ITEM = WA-POSNR.

GS_DELV-DLV_QTY = WA-ZMENG. -


This is of type-ZMENG TYPE WMENG (Order quantity in sales units)

GS_DELV-SALES_UNIT = WA-ZIEME.

APPEND GS_DELV TO GT_DELV.

CLEAR GS_DELV.

ENDLOOP.

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'

EXPORTING

SHIP_POINT = GV_PLANT

DUE_DATE = WA-REQ_DATE

IMPORTING

DELIVERY = GV_DELIVERY

TABLES

SALES_ORDER_ITEMS = GT_DELV

RETURN = GT_DELRETURN.

COMMIT WORK AND WAIT.

Please suggest.

Thanks.

0 Kudos

Once again, the error you are getting is because of the Schedule lines in the sales order. go to Va02/Va03 and check the availability (ATP) of items and see if you have at least one deliverable item in the order.

However, there are couple of ways of creating a delivery with ref to order.

The one you are using is to create with ref and this one creates one delivery for all the deliverable items in the sales order. So it is a single delivery and based your configuration the delivery can be split into multiple deliveries.

So if you want to go with the one you are using, do the following. The same example discussed in the BAPI documentation too but in case, if you don't have documentation available in English... below is the code.

DATA: lf_vbeln TYPE vbeln_vl,

lf_num TYPE vbnum,

ls_deli TYPE bapishpdelivnumb,

lt_deli TYPE TABLE OF bapishpdelivnumb,

lt_order TYPE TABLE OF bapidlvreftosalesorder,

ls_order TYPE bapidlvreftosalesorder,

ls_itm TYPE bapidlvitemcreated,

lt_itm TYPE TABLE OF bapidlvitemcreated,

ls_ret TYPE bapiret2,

lt_return TYPE TABLE OF bapiret2.

data: l_vbeln type vbeln.

START-OF-SELECTION.

  • SalesOrderItems (here: complete sales order)

ls_order-ref_doc = l_vbeln.

APPEND ls_order TO lt_order.

  • Synchronous RFC

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'

IMPORTING

delivery = lf_vbeln

num_deliveries = lf_num

TABLES

sales_order_items = lt_order

deliveries = lt_deli

created_items = lt_itm

return = lt_return.

loop at lt_return into ls_ret where type = 'A' or type = 'E'.

message e000 with 'Delivery creation failed'.

exit.

endloop.

call function 'BAPI_TRANSACTION_COMMIT'.

The other one i am talking about is with reference to the sales order and you can also create delivery for only selected items in the sales order. To do this, you have to call other bapi.

Here is the example, For easy understanding, i mentioned actual table names but you better define per your naming conventions.

data: it_request type table of bapideliciousrequest,

wa_request type bapideliciousrequest,

it_createditems type table of bapideliciouscreateditems,

wa_createditems type bapideliciouscreateditems,

it_return type table of bapiret2,

wa_return type bapiret2.

data: it_vbap type table of vbap,

wa_vbap type vbap,

it_vbfa type table of vbfa,

wa_vbfa type vbfa.

" Data

data: w_rfmng type rfmng.

" Create delivery.

loop at it_vbap into wa_vbap.

wa_request-document_type = c_a.

wa_request-document_numb = wa_vbap-vbeln.

wa_request-document_item = wa_vbap-posnr.

wa_request-material = wa_vbap-matnr.

wa_request-plant = wa_vbap-werks.

wa_request-stge_loc = wa_vbap-lgort.

wa_request-delivery_date = wa_vbap-vdatu.

" Calculate delivered qty and substract from the confirmed qty.

loop at it_vbfa into wa_vbfa where vbelv = wa_vbap-vbeln

and posnv = wa_vbap-posnr.

w_rfmng = w_rfmng + wa_vbfa-rfmng.

endloop.

wa_vbap-kbmeng = wa_vbap-kbmeng - w_rfmng.

wa_request-quantity_base__uom = wa_vbap-kbmeng.

append wa_request to it_request.

clear: wa_request, w_rfmng.

endloop.

" Call bapi to create delivery

call function 'BAPI_DELIVERYPROCESSING_EXEC'

tables

request = it_request

createditems = it_createditems

return = it_return.

after this read the it_return like in above example then use commit upon success.

NOTE: Unless, you have deliverable items in the sales order, you won't be able to create a delivery for the sales order.

0 Kudos

Hi Sampath, Jack and Srikanth.

Thankyou so much for being helpful to my issue. My special thanks to Sampath as he is being helpful to my other issues too.

As you said, this is not a program issue. We don't have stocks maintained for the material I am using for my sales order. I tried different options like backorder processing and maintaining stocks for my material but still couldn't figure out the exact reason. May be there is some config issue which my team is working on.

I will close this thread after couple of days once the config settings are done. Because I do not want to post the same issue after couple of days if my config setting are working fine and the problem is with the code.

Thanks again.

0 Kudos

Just a note: First try out the online / regular processing with the same order. For example, if you are processing order 123 and you got error then you better create delivery from VL01N or VA02 for the same order. This way you will understand the exact problem and you can show it to functional people then if it works, you can always delete the delivery and run through your program.

Edited by: Sampath Kumar on May 25, 2011 11:20 AM

0 Kudos

Hi sampath,

I have done creating what u have said. But the same error repeats. Lets wait and see from config point of view.

Thanks.

0 Kudos

Hi Experts,

Here I come back with the solution to the Schedule Lines Issue. It is a config error. But still when I run my program with the new materials created, I see some new issues popping up in my delivery return table.(GT_RETURN)

1. Info message - Delivery $ 1:picking 05/25/2011 070326 set (check delivery dates)

2. Info Message - No packing instructions could be found for material 3000024

3. Info message - In the 1 loop, no packing proposal data could be determined.

4. Error message - The customer has requested complete delivery

5.Error message - No instance of object type outbound delivery has created. External reference.

Please suggest me some ideas how to deal this.

Thanks.

0 Kudos

We all have been explaining the same thing that it was not a program error but ATP qty issue. Glad, you were able to solve the issue.

For your other issue, it is again not a program issue but it is master data issue. The message itself is self explanatory. Here is how to find and correct the error messages. You can ignore all info messages for now and the last error message is the result of the error message 'customer requested complete delivery'

It is a setting in the customer master. Goto transaction XD02 and enter the partner (first sold to and then ship to) - enter sales area data - Press enter to get into customer master data - choose 'Sales area data' on application toolbar - Go to 'Shipping' Tab - there is a field 'Partial Delivery Per Item'. in your case it would be something else other than just an empty... clear out value and enter maximum number in 'Max.partial deliveries' ... run your program again.

Reason for this error is again you dont have enough ATP available and only few or partial qty available for delivery.

Seems, you have got new system. I recommend you run online before you execute with your program so that you can easily differentiate the error between config and program.

0 Kudos

Hi Sampath,

You are really the man. I really bet you. You are right, I got a new system. And I am the new developer too.

Anyways, my answer is solved and I thank you a lot on guiding me with my issues. I am closing this thread now.

Thanks.

0 Kudos

Well, Nani - I think a lot of other people also helped you out; you can assign polnts for very helpful and helpful answers as well.

Rob

0 Kudos

Agree with you. There are helpful answers in this thread.

@nani: you should always be assigning points to every helpful answer in any thread. People take time to read and help you and awarding points is the appreciation in a way.

0 Kudos

I agree with you two guys. But, according to my thread, I feel Sampath tried helping/guiding me a lot to resolve my issue. I definetly will award points for others whom I think are helpful too.

Thanks.

0 Kudos

Hi Sampath,

I am using BAPI_DELIVERYPROCESSING_EXEC to create single Inbound delivery for mutiple sales order but its not work it generates multiple IBD for multiple SO. Coud please provide any help on this?

Thanks,

Abhijeet.

former_member213275
Contributor
0 Kudos

HI Nani,

NO SCHEDULINE DUE FOR DELIVERY UP TO THE SELECTED DATE - This error means that the date which you are passing to FM is wrong. If in Sales order your order date is 01.04.08, then pass devlivey date 3 or 4 days in advance this may solve your problem. There will be two dates in the schedule line 1st schedule line comfirm quantity 0, Do not take this

date. second schedule line Date with confirm quantity. Take this date and pass this to FM now you will be able to deliver.

Srikanth