2013 Nov 20 12:05 PM
Hi, experts!
When I call BAPI_DELIVERYPROCESSING_EXEC in code, system returns two errors:
And my parameters are as below,
Could you tell me what's wrong with my code? Thanks a lot!
2013 Nov 20 4:13 PM
Hi,
The delivery type is not determining automatically. Check the delivery type assignment once again.
Technically, the error is triggering from below function module.
GN_DELIVERY_TYPE_DETERMINE
if x_komdlgn-lfart is initial.
write x_komdlgn-matnr to lf_matnr_txt.
perform message_handling(sapmv50a) using x_komdlgn-rfpos
'295'
'E'
'VL'
x_komdlgn-dlvtp
lf_matnr_txt
x_komdlgn-bwart
space.
thanks,
Kiran
2013 Nov 20 12:27 PM
Hi Shelvin
I believe you are try to create inbound delivery for PO if yes please use this
BBP_INB_DELIVERY_CREATE
Thanks
Nabheet
2013 Nov 21 11:34 AM
Yes, I tried this FM and it is really useful for creating inboubd delivery. But I encounterred a problem when using this FM. The inbound delivery created has no material numner while I'm sure that I have passed the value of material number when calling this FM.
2013 Nov 21 11:43 AM
Please find the sample code for the same. Kindly share your sample code
* Build the internal table .
w_inb_delivery_detail-material = <fs_po_items>-material .
w_inb_delivery_detail-unit = <fs_po_items>-unit.
w_inb_delivery_detail-po_number = <fs_po_items>-po_number .
w_inb_delivery_detail-po_item = <fs_po_items>-po_item .
w_inb_delivery_detail-deliv_qty = <fs_po_item_schedules>-QUANTITY .
append w_inb_delivery_detail to t_inb_delivery_detail .
w_bbp_inbd_l-deliv_date = w_po_item_schedules_temp-deliv_date .
w_bbp_inbd_l-deliv_date = w_po_item_schedules_temp-deliv_date .
* Create Inbound delivery
CALL FUNCTION 'BBP_INB_DELIVERY_CREATE'
EXPORTING
is_inb_delivery_header = w_bbp_inbd_l
IMPORTING
ef_delivery = w_ef_delivery
TABLES
it_inb_delivery_detail = t_inb_delivery_detail
return = t_return_del.
2013 Nov 21 2:50 PM
I'm sure that my code is very similar to your sample code...
ls_inb_delivery_header-deliv_date = sy-datum.
ls_inb_delivery_header-deliv_time = sy-uzeit.
LOOP AT lt_po_items INTO ls_po_item.
lo_item = ls_po_item-item.
ls_item_data = lo_item->get_data( ).
lv_confirm_control = ls_item_data-bstae.
* CHECK lv_confirm_control = '0004'.
lv_item_num = ls_item_data-ebelp.
lv_item_matnr = ls_item_data-matnr.
lv_item_quantity = ls_item_data-menge.
lv_po_uom = ls_item_data-meins.
CLEAR ls_inb_delivery_detail.
ls_inb_delivery_detail-material = lv_item_matnr.
ls_inb_delivery_detail-deliv_qty = lv_item_quantity.
ls_inb_delivery_detail-unit = lv_po_uom.
ls_inb_delivery_detail-po_number = lv_po_num.
ls_inb_delivery_detail-po_item = lv_item_num.
APPEND ls_inb_delivery_detail TO lt_inb_delivery_detail.
ENDLOOP.
CALL FUNCTION 'BBP_INB_DELIVERY_CREATE'
EXPORTING
is_inb_delivery_header = ls_inb_delivery_header
IMPORTING
ef_delivery = lv_delivery_num
TABLES
it_inb_delivery_detail = lt_inb_delivery_detail
return = lt_return.
2013 Nov 21 3:08 PM
2013 Nov 22 1:26 AM
Above this snippet of code, I didn't paste it in last night.
lv_po_num is filled from the header data which is returned from IM_HEADER->GET_DATA(). IM_HEADER is an importing parameter of the method (CLOSE() of BADI ME_PROCESS_PO_CUST) I put my code inside.
And I find that it may be a bug of this FM. I reviewed its source code, and it will get my material number deleted inside. (I will put my research below later, because I'm replying using my mobile phone, but my screenshots are all in my computer...)
2013 Nov 22 5:08 AM
Hi, Nabheet! Here is my research about BBP_INB_DELIVERY_CREATE.
Inside this function module, another function module (ME_CONFIRMATION_VIA_EDI) will be invoked. After execution of ME_CONFIRMATION_VIA_EDI, material numbers of all items will be erased. So what does ME_CONFIRMATION_VIA_EDI do? Please look at the screenshot below.
There is an enhancement inside ME_CONFIRMATION_VIA_EDI. And the t_kom-ematn (Material Number Corresponding to Manufacturer Part Number) is initial all the time. So after executing the code in line 126, material number will be erased.
However, I think I can use GN_DELIVERY_CREATE, instead of BBP_INB_DELIVERY_CREATE, to create inbound delivery. GN_DELIVERY_CREATE is the core function that is called inside BBP_INB_DELIVERY_CREATE.
But my scruple is that function module BBP_INB_DELIVERY_CREATE has done many other things before calling GN_DELIVERY_CREATE, and I have no idea if it is trouble-free that I just use GN_DELIVERY_CREATE.
2013 Nov 22 5:33 AM
Hi Shelwin,
My practical experience, I have used and using the FM GN_DELIVERY_CREATE to create the inbound deliveries reference to PO. The FM will work perfectly, However there is a disadvantage of this FM is, can't present the dynamic dynamically fill the exceptions. You have to handled it explicitly.
for example, if you have to find wether the inbound delivery is created or not.
XVBFS - is storing the collective messages in the function module. You have to be store it or display it by using the FM MESSAGE_STORE ( depends on your requirement ).
Absolutely no functional issue of using the FM.
Thanks,
Kiran
2013 Nov 25 6:49 AM
How to use FM MESSAGE_STORE, please? Here is my code:
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'ZTEST'
exception_if_not_active = 'X'
msgty = 'E'
msgv1 = lv_po_num
* MSGV2 = ' '
* MSGV3 = ' '
* MSGV4 = ' '
txtnr = '000'
* ZEILE = ' '
* IMPORTING
* ACT_SEVERITY =
* MAX_SEVERITY =
EXCEPTIONS
message_type_not_valid = 1
not_active = 2
OTHERS = 3.
Message Class 'ZTEST':
000 Failed to create inbound delivery for purchase order &.
After execution of this FM, sy-subrc = 2. But my message in message class is saved and message class is in active state.
2013 Nov 25 10:19 AM
Hi,
After calling the all function to create inbound Delivery.
For example:
call function 'GN_DELIVERY_CREATE'
exporting
vbsk_i = ls_xvbsk
tables
xkomdlgn = lt_komdlgn
xvbfs = lt_xvbfs
xvbls = lt_xvbls
xxlips = lt_xlips
exceptions
error_message = 99.
You need to check wether the delivery is created or not. If the delivery is created the data will import the lt_xlips table.
Read table lt_xlips into ls_xlips index 1.
if sy-subrc = 0 NAD
ls_xlips-vbeln IS NOT INITIAL. (. " it mean delivery created)
call function 'MESSAGE_STORE'
exporting
arbgb = 'VL' ( standard Message type)
msgty = 'I'
msgv1 = text-006 ( Inbound Delivery)
msgv2 = ls_xlips-vbeln
msgv3 = space
msgv4 = space
txtnr = '311' ( message for Sale )
zeile = lv_count
exceptions
message_type_not_valid
not_active.
ELSE. ( ERROR OCCURED)
*All errors will be stored in lt_xvbfs -
loop at lt_xvbfs into ls_xvbfs.
call function 'MESSAGE_STORE'
exporting
arbgb = sy-msgid
msgty = sy-msgty
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv3
msgv4 = sy-msgv4
txtnr = sy-msgno
zeile = lv_count
exceptions
message_type_not_valid
not_active.
endloop.
endif.
Thanks,
Kiran
2013 Nov 20 4:13 PM
Hi,
The delivery type is not determining automatically. Check the delivery type assignment once again.
Technically, the error is triggering from below function module.
GN_DELIVERY_TYPE_DETERMINE
if x_komdlgn-lfart is initial.
write x_komdlgn-matnr to lf_matnr_txt.
perform message_handling(sapmv50a) using x_komdlgn-rfpos
'295'
'E'
'VL'
x_komdlgn-dlvtp
lf_matnr_txt
x_komdlgn-bwart
space.
thanks,
Kiran
2013 Nov 22 5:28 AM
Hi, Kiran! Thank you for your direction, and apologies for not reply to you for a long time!
I check my code and I think I find the source of the problem. At the beginning, I put my code that calling BAPI_DELIVERYPROCESSING_EXEC inside method POST( ) of BADI ME_PROCESS_PO_CUST. At this time, PO is not created physically, which may account for the errors showed in the first screenshot of the original post. So it is not appropriate to create inbound delivery at this method.
2013 Nov 22 5:35 AM
Hi,
Yes, I have read your findings and appreciated! I would suggest better to use the function module as suggested by you.
Thanks,
Kiran.
2014 Oct 20 2:10 PM
HI Wei,
Appreciate your investigation.
I was facing the same issue while creating delivery from STO. It was observed BAPI "BAPI_DELIVERYPROCESSING_EXEC" was successfully creating delivery upto 2 STOs, but at the time of 3rd delivery process by 3rd STO , BAPI failed to create delivery.
It was due to 3rd STO failed to fetch EKPV table data for that 3rd STO done in "ME_EKPV_ARRAY_READ" FM exist in above delivery BAPI.
under this FM , there is counter me->mv_iter which limits iteration max to 2 counts.
use "ME_EKPV_ARRAY_READ" function module with PI_REFRESH_BUFFER = 'X' before calling BAPI "BAPI_DELIVERYPROCESSING_EXEC".
-------------------------Code--------------------------------
CALL FUNCTION 'ME_EKPV_ARRAY_READ'
EXPORTING
pi_refresh_buffer = c_x
TABLES
pti_ekpv_key = lt_pti_ekpv_key.
CLEAR lt_pti_ekpv_key[].
CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'
TABLES
request = lt_request[]
createditems = lt_createditems[]
return = lt_return[].
-----------------------------------------------------------------------
By using above logic, an issue has been solved.
Thanks,
Vikas