2013 Feb 26 1:45 PM
Hi everyone,
I'm trying to find a FM or BAPI to add new items to an existing outbound delivery.
While searching, I found BAPI_OUTB_DELIVERY_CHANGE which has a parameter ‘NEW_ITEM_DATA’
which sounds promising, but although I filled the parameter in a test report and
didn’t get any errors as result, no new items are added.
Unfortunately, there is no documentation for the ‘NEW_ITEM_DATA’ parameter and no info in the
BAPI documentation how to add new items.
Does anyone know how to manage to add new items to an outbound delivery using FM or BAPI?
regards
Michael
2013 Feb 26 5:10 PM
2013 Feb 26 6:27 PM
Hi Maen,
yes, this is the test report i used:
report zvl02n_add_item_test.
data:
gs_header_data like bapiobdlvhdrchg,
gs_header_control like bapiobdlvhdrctrlchg,
g_delivery like bapiobdlvhdrchg-deliv_numb,
gs_new_item_data type bapiobdlvitem,
gt_new_item_data type bapiobdlvitem_t,
gs_item_control type bapiobdlvitemctrlchg,
gt_item_control type bapiobdlvitemctrlchg_t,
gt_return type bapirettab.
gs_header_data-deliv_numb = '0080818219'.
gs_header_control-deliv_numb = '0080818219'.
g_delivery = '0080818219'.
gs_new_item_data-deliv_numb = '0080818219'.
gs_new_item_data-itm_number = '000020'.
gs_new_item_data-material = 'V001'.
gs_new_item_data-dlv_qty = 2.
append gs_new_item_data to gt_new_item_data.
gs_item_control-deliv_numb = '0080818219'.
gs_item_control-deliv_item = '000020'.
gs_item_control-chg_delqty = 'X'.
append gs_item_control to gt_item_control.
call function 'BAPI_OUTB_DELIVERY_CHANGE'
exporting
header_data = gs_header_data
header_control = gs_header_control
delivery = g_delivery
* TECHN_CONTROL =
* HEADER_DATA_SPL =
* HEADER_CONTROL_SPL =
* SENDER_SYSTEM =
tables
* HEADER_PARTNER =
* HEADER_PARTNER_ADDR =
* HEADER_DEADLINES =
* ITEM_DATA =
item_control = gt_item_control
* ITEM_SERIAL_NO =
* SUPPLIER_CONS_DATA =
* EXTENSION1 =
* EXTENSION2 =
return = gt_return
* TOKENREFERENCE =
* ITEM_DATA_SPL =
* COLLECTIVE_CHANGE_ITEMS =
new_item_data = gt_new_item_data
* NEW_ITEM_DATA_SPL =
* NEW_ITEM_ORG =
* ITEM_DATA_DOCU_BATCH =
.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
2013 Feb 26 8:32 PM
hi,
instead of populating NEW_ITEM_DATA try filling ITEM_DATA with new item number and see the result.
let me know if it helps.
THanks
Gaurav
2013 Feb 26 9:03 PM
Browsing thru the code of BAPI should answer your question. From the code you have given above, I see that you have filled the structure new_item_data alone. Look at the include /SPE/V50IF06 line number 67. SAP says you need to fill IT_NEW_ITEM_ORG as well.
Try filling the values for storage location and plant in IT_NEW_ITEM_ORG and then run your program to see the results. I am hoping this should solve the issue.
If not, use the include given above and do a debug. That should give a lot of clarity.
Thanks,
Vikram.M
2013 Feb 27 7:56 AM
Hi Vikram,
ik it tried filling the IT_NEW_ITEM_ORG as well, but same result. No added item, no error or warning Messages.
So, I tried debbuging the /SPE/V50IF06 include, but to me it looks like that isn't adressed at all, because the Debugger won't stop at any breakpoint I set in there.
Michael
2013 Feb 27 7:58 AM
Hi Guarav,
when i fill item_data instead of new_item_data, it doesn't work either. But I get an error message VL 216. But i can't find any description for the message type.
Michael
2013 Feb 27 11:32 AM
Instead of using a break-point to enter debugging, i suggest to debug the function from the start of the call to find any discrepancies.
2013 Feb 27 12:13 PM
Hi Maen,
ok i followed your advice, and found out that seemlingly this if clause in form
OBDLV_INTERFACE_CHANGE prevents the BAPI from adding new items using form spe_new_item_fill:
IF cl_ops_switch_check=>le_sfws_sc3( ) = gc_true. "v_n_1466325
* EhP 3 EWM-ERP integration
PERFORM spe_vbpok_obdlv_fill_dbatch TABLES ct_item_data_docu_batch
ct_vbpok
USING cs_vbkok
CHANGING ct_return[]
lf_subrc .
IF lf_subrc NE 0.
gf_flag-rollback = gc_true.
ENDIF.
* Extend deliveries with new items
PERFORM spe_new_item_fill TABLES it_new_item_data
it_new_item_data_spl
it_new_item_org
CHANGING ct_new_items
ct_return[]
lf_subrc.
IF lf_subrc NE 0.
gf_flag-rollback = gc_true.
ENDIF.
ENDIF. "^_n_1466325
But I don't know what he checks here
cl_ops_switch_check=>le_sfws_sc3( ) ?
Michael
2013 Feb 27 12:33 PM
OK i already found out that he check with that if clause if switch LE_SFWS_SC3 is turned on.
Unfortunately in our System it's turned of. Does anyone now what the consequences of turning it on would be?
2013 Feb 27 12:57 PM
IF cl_ops_switch_check=>le_sfws_sc3( ) = gc_true. "v_n_1466325
is not in my system.
2013 Feb 27 1:02 PM
2013 Feb 27 1:15 PM
Yeah that discussion I found also searching for the meaning of the if clause.
If I can't find anything on the Impact of turning on Switch LE_SFWS_SC3, I guess I
try the described Workaround, although it annoys me that I can’t use the BAPI functionality.
2013 Feb 27 2:03 PM
2013 Feb 27 11:23 AM
Hi Michael,
The BAPI BAPI_OUTB_DELIVERY_CHANGE will allow you to only change the existing data in the Outbound Delivery. You cannot add any new items using this BAPI. For that purpose you might have to implement some function/screen exits and pass data.
What exactly are you trying to add or hopefully change (not add)?
2013 Feb 27 11:54 AM
Hi A N,
ok if i can't use the BAPI BAPI_OUTB_DELIVERY_CHANGE is there another BAPI / FM that will do the Job?
And trying to add some items to an existing outbound delivery, unfortunately not change.
2013 Feb 27 12:06 PM
A N wrote:
Hi Michael,
The BAPI BAPI_OUTB_DELIVERY_CHANGE will allow you to only change the existing data in the Outbound Delivery. You cannot add any new items using this BAPI. For that purpose you might have to implement some function/screen exits and pass data.
What exactly are you trying to add or hopefully change (not add)?
I haven't tried out the BAPI myself, but looking at the code it should work.
Now, based on what do you conclude that with this function you cannot add new items?
2013 Feb 27 12:11 PM
Hi Michael,
In that case you may have to do as below:
1. Incase you do not want those new fields on the Outbound Delivery tab (VL01N/02N/03N), then you have to just add those required fields in LIKP/LIPS table as per your requirement-Header or Item Level. You can do this by adding a Custom Include in the table.
2. If you want these new fields to show on the Delivery Screen (VL01N/VL02N/VL03N), then you need to search for a Customer Exit/Screen Exit and add those fields on the screen along with step 1.
3. For future use, you may have to implement Customer Exit/BADI in both cases to code and pass the values to your additional fields.
4. For the existing delivery, once these fields are in the LIKP or LIPS table, the BAPI BAPI_OUTB_DELIVERY_CHANGE should allow you to update the existing fields.
Currently this BAPI is unable to get those additional fields as they are not available in the database table hence its failing.
2013 Feb 27 12:12 PM
Your code:
gs_item_control-deliv_numb = '0080818219'.
gs_item_control-deliv_item = '000020'.
gs_item_control-chg_delqty = 'X'.
append gs_item_control to gt_item_control.
How about leaving out that part since this one is for changing items? When i look at the BAPI code, it does nothing with GT_ITEM_CONTROL when it processes the contents of NEW_ITEM_DATA. And you do need to pass table NEW_ITEM_ORG as well.
2013 Feb 27 1:20 PM
Hi A N,
I don't wan't wan't to add new fields, I just wan't to add new positions to an existing delivery.
2013 Feb 28 3:39 AM
Can you please specify the positions? I am unable to understand what you mean by 'Positions' in a delivery. Thanks
2013 Feb 28 7:28 AM
Hi,
I mean, I have to extend existing outbound deliveries, with additional material positions without order reference.
2014 Feb 17 5:23 PM
Check out this sample code
PARAMETERS: p_vbeln TYPE likp-vbeln,
p_matnr TYPE matnr,
p_quan TYPE lips-lfimg,
p_werks TYPE werks_d,
p_lgort TYPE lips-lgort,
p_vrkme TYPE lips-vrkme.
DATA: ls_vbkok TYPE vbkok,
ls_delivery_head TYPE likpvb,
lt_new_items TYPE TABLE OF /spe/add_delivery_item,
ls_new_items TYPE /spe/add_delivery_item,
lt_return TYPE TABLE OF bapiret2,
ls_return TYPE bapiret2,
is_vbkok TYPE vbkok,
lv_posnr TYPE lips-posnr,
lv_meins TYPE meins.
" Set header data
ls_delivery_head-vbeln = p_vbeln.
ls_delivery_head-spe_le_scenario = 'S'. " STO (Stock Transfer Order)
" Get last item number in delivery
SELECT SINGLE MAX( posnr )
FROM lips
INTO lv_posnr
WHERE vbeln = p_vbeln.
" Set new item number in delivery
ADD 10 TO lv_posnr.
" get uom for material
SELECT SINGLE meins
FROM mara
INTO lv_meins
WHERE matnr = p_matnr.
" Set new item data
ls_new_items-rfpos = lv_posnr.
ls_new_items-matnr = p_matnr.
ls_new_items-pstyv = 'ULN'. " StandStockTransItem
ls_new_items-lfimg = p_quan.
ls_new_items-vrkme = p_vrkme.
ls_new_items-werks = p_werks.
ls_new_items-lgort = p_lgort.
ls_new_items-vbeln = p_vbeln.
ls_new_items-posnr = lv_posnr .
ls_new_items-meins = lv_meins.
APPEND ls_new_items TO lt_new_items.
" Set new item to delivey
CALL FUNCTION '/SPE/OUTB_DLV_CHG_ITEMS_INSERT'
EXPORTING
if_delivery_number = p_vbeln
is_vbkok = ls_vbkok
is_delivery_head = ls_delivery_head
TABLES
it_new_items = lt_new_items
et_return = lt_return.
READ TABLE lt_return WITH KEY type = 'E' INTO ls_return.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
Regards
Eyal
2014 Feb 18 2:09 PM
Hello Eyal,
thanks for your Input. I tried your sample code with two modifications, because I want to extend normal outbount delivieries (not Stock Transfer Order).
So, i adjusted
ls_delivery_head-spe_le_scenario = 'S'. " STO (Stock Transfer Order) to ls_delivery_head-spe_le_scenario = ' '. " Normal Outbound Delivery
and used a different Position Type on item Level.
But now I'm getting error message VL565 "Data of preceding document was not transmitted". And for the positions we need to add, there are no preceding documents, because they are added without reference.
Michael
2014 Feb 24 12:26 PM
Hi Michael
Please check whether your delivery was created with both of the following flags on.
SPE_LE_SCENARIO
A Transportation Cross-Docking
T TPOP (Third Party Order Processing)
S STO (Stock Transfer Order)
C CRM Order as Predecessor for Unchecked Delivery
R CRM Complaint as Predecessor for Returns Delivery
D POD (Proof of Delivery) - Correction Delivery
E ID Handling
I Additional Item Discrepancy
B Production Supply Delivery
F Production Consumption Delivery
G Repetitive Manufacturing
H Kanban Replenishment
J Goods Receipt for Production/Process Orders
SPE_LIFEX_TYPE
S Stock Transfer: Number of Preceding Outbound Delivery
R Returns: Number of Returns ASN
V External Identification from Vendor
N Stock Transfer w/o STO: Number of Preceding Outb. Del.
this is the cause for your error.
Eyal
2014 Feb 24 2:30 PM
Hi Eyal,
i had SPE_LE_SCENARIO set to empty(' '), because in the Domain value range it's specifiy for "normal".
but I didn't have SPE_LIFEX_TYPE specified.
So, now tried various Scenarios with values for SPE_LE_SCENARIO and SPE_LIFEX_TYPE set. But I Keep geeting
the error message "Data of preceding document was not transmitted".
Michael
2014 Feb 25 6:46 AM
In order for this to add the new items both flags need to be full with any value but empty....
I have enhanced include /SPE/LDIRDLVF28
subroutine MAP_NEW_ITEMS_TO_KOMDLGN
and filled it there (since i dont know what will be the consequence of such act from the begining)
2024 Aug 22 8:32 AM
Hi Eyal,
I used this FM '/SPE/OUTB_DLV_CHG_ITEMS_INSERT' and i successfully added a new article line item to an existing delivery.
But in my case the Picking Quantity is showing as 0 , even i passed PIKMG field value in to the lt_new_items. And status is showing as Partially Picked . Please suggest me , what else i need to pass? Below are the screen shots , for what all i passed to the FM , do i need to add any flags , please suggest me some solution.
2015 Oct 09 12:41 AM
This BAPI works for adding items to an existing delivery
call function 'BAPI_DELIVERYPROCESSING_EXEC'
exporting
delivery_extend = lv_extend
tables
request = lt_request
return = lt_return.
2024 Jul 04 7:24 AM
Hey,
To solve the problem we used the BAPI_OUTB_DELIVERY_CHANGE and NEW_ITEM_DATA. We found out that that the reference to the SO doc was missing. We added an enhancement where the missing values were filled.
Here's an example: