03-05-2012 5:33 PM
Hello All,
Requirement: Update the Sales Order Schedule Lines delivery block field to 'BLANK'.
Can anyone please let me know what I am doing wrong here? Why it is not updating the Delivery Block field on the schedule lines?
Here is the code that I am passing it to BAPI_SALESORDER_CHANGE.
st_order_header_inx-dlv_block = 'X'.
st_order_header_inx-updateflag = 'U'.
APPEND st_order_header_inx TO t_order_header_inx.
CLEAR : st_order_sche_in, st_order_sche_inx.
st_order_sche_in-itm_number = '000010'.
st_order_sche_in-sched_line = '0001'.
st_order_sche_in-req_dlv_bl = ' '.
APPEND st_order_sche_in TO t_order_sche_in.
st_order_sche_inx-itm_number = '000010'.
st_order_sche_inx-sched_line = '0001'.
st_order_sche_inx-updateflag = 'U'.
st_order_sche_inx-req_dlv_bl = 'X'.
APPEND st_order_sche_inx TO t_order_sche_inx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = st_temp_pricing-vbeln
order_header_inx = st_order_header_inx
TABLES
return = t_return1
schedule_lines = t_order_sche_in
schedule_linesx = t_order_sche_inx.
Can anyone please post sample code to update the schedule lines Delivery Block?
Thank in Advance.
Thank You.
Shyam
03-05-2012 5:56 PM
Code seems to be OK, did you check the contents of RETURN structure ? Does it contains any Error/warning records ?
03-05-2012 6:18 PM
Hi Vinod,
I am not getting any error messages.
Here are the return values:
S V4 233 ORDER_HEADER_IN has been processed successfully
S V4 233 SCHEDULE_IN has been processed successfully
S V4 233 SCHEDULE_IN has been processed successfully
S V1 311 IR Std.Order 13545 has been saved
Please let me know what I am doing wrong.
Thank You.
Shyam
03-05-2012 6:30 PM
Don't see anything wrong with the code, an obvious question : Did you execute BAPI_TRANSACTION_COMMIT after Change BAPI ?
03-05-2012 6:42 PM
Vinod,
I have already kept BAPI_TRANSACTION_COMMIT after BAPI_SALESORDER_CHANGE, even though its not updating.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = st_return2.
Thank You.
Shyam
03-05-2012 6:48 PM
As written in the link below, you need to build item structure of the BAPI. The tricky thing is that even if we do not need to change the PO_ITM_NO in the item level, we still need to set it to u2018Xu2019. Otherwise, it will not be able to work in certain condition. Please refer below code for detail information.
Reference http://abaps4.blogspot.com/2010/10/bapi-bapisalesorderchange.html
Regards,
Felipe
03-05-2012 6:59 PM
fsimionatto,
The link which you provided above is not working. Can you pleas copy paste the details in your reply message?
Thank You.
Shyam
Edited by: shyam.. on Mar 5, 2012 11:15 AM
03-05-2012 7:14 PM
fsimionatto,
I have passed the item details to the BAPI. still not working...
loop at t_vbap into st_vbap where vbeln = st_temp_pricing-vbeln.
st_order_item_in-itm_number = st_vbap-posnr.
append st_order_item_in to t_order_item_in.
st_order_item_inx-itm_number = st_vbap-posnr.
st_order_item_inx-updateflag = c_update.
append st_order_item_inx to t_order_item_inx.
clear: st_vbap, st_order_item_in, st_order_item_inx.
endloop.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = st_temp_pricing-vbeln
* order_header_in = t_order_header_in
order_header_inx = st_order_header_inx
TABLES
return = t_return1
order_item_in = t_order_item_in
order_item_inx = t_order_item_inx
schedule_lines = t_order_sche_in
schedule_linesx = t_order_sche_inx.
Edited by: shyam.. on Mar 5, 2012 11:16 AM
03-05-2012 7:46 PM
Try this link
http://www.sapgeek.net/2009/09/bapi_salesorder_change/
The tables that i told you is not the schedule ones but the ORDER_ITEM_IN and ORDER_ITEM_INX with basic information like:
lv_bapi_view-item = 'X'.
lv_bapi_view-sdcond = 'X'.
lv_bapi_view-configure = 'X'.
CLEAR lt_sales_doc.
ls_sales_doc-vbeln = gs_output-vbeln.
APPEND ls_sales_doc TO lt_sales_doc.
CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
EXPORTING
i_bapi_view = lv_bapi_view
TABLES
sales_documents = lt_sales_doc
order_items_out = lt_items
order_conditions_out = lt_condition
order_cfgs_curefs_out = lt_cfgs_curefs
order_cfgs_cucfgs_out = lt_cfgs_cucfgs
order_cfgs_cuins_out = lt_cfgs_cuins
order_cfgs_cuvals_out = lt_cfgs_cuvals.
ls_item_in-itm_number = ls_items-itm_number.
ls_item_in-hg_lv_item = ls_items-hg_lv_item.
ls_item_in-po_itm_no = ls_items-itm_number.
ls_item_in-material = ls_items-material.
APPEND ls_item_in TO lt_item_in.
ls_item_inx-itm_number = ls_item_in-itm_number.
ls_item_inx-updateflag = 'U'.
ls_item_inx-po_itm_no = 'X'.
ls_item_inx-config_id = 'X'.
ls_item_inx-inst_id = 'X'.
APPEND ls_item_inx TO lt_item_inx.
* call BAPI 'BAPI_SALESORDER_CHANGE' to modify the configuration data and the condition record
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = ls_sales_doc-vbeln
order_header_inx = ls_header_inx
TABLES
RETURN = lt_return
order_item_in = lt_item_in
order_item_inx = lt_item_inx
order_cfgs_ref = lt_cfgs_ref
order_cfgs_inst = lt_cfgs_inst
order_cfgs_value = lt_cfgs_value
conditions_in = lt_cond_in
conditions_inx = lt_cond_inx.
* Database update
COMMIT WORK AND WAIT.
03-05-2012 10:35 PM
It didn't work out for me... Any other suggestions...
Thank You.
Shyam
03-06-2012 12:26 AM
03-06-2012 2:55 AM
03-07-2012 8:28 AM
just a guess but i would expect the delivery block at header level overwriting the changes at item level.
st_order_header_inx-dlv_block = 'X'.
st_order_header_inx-updateflag = 'U'.
APPEND st_order_header_inx TO t_order_header_inx.
Regards,
Dev