10-07-2008 8:17 AM
Hi experts
I am using 'BAPI_SALESORDER_CREATEFROMDAT2' in order to update The total (rounded) order quantity of a sales document.
I can update header of items but i couldnt update that field. I used
ORDER_SCHEDULES_IN-req_qty = T_VBFA-RFMNG.
ORDER_SCHEDULES_IN-ITM_NUMBER = T_VBAP-POSNR.
ORDER_SCHEDULES_INX-req_qty = 'X'.
but this only adds the amount to the current amount. For example in the sales doc order quantity is 100 and i want to make it 60. But if i assing 60 to T_VBFA-RFMNG it makes 160. It adds the value.
Which field should i have to fill in order to change order quantity?
Thanks
10-07-2008 8:20 AM
Hi,
If you want to change an existing document use BAPI BAPI_SALESORDER_CHANGE rather than a create one.
Darren
10-07-2008 8:22 AM
Thanks for the answer darren, if i cant find the answer i'll try that way, but i'll really appraciate if anyone can answer my question
10-07-2008 8:58 AM
I couldnt find the field for BAPI_SALESORDER_CHANGE to change order quantity.
They are nearly same bapi's. Anyone can help ?
10-07-2008 9:01 AM
10-07-2008 9:15 AM
Try using field ORDER_ITEMS_IN-TARGET_QTY instead of ORDER_SCHEDULES_IN-REQ_QTY.
Regards,
Aparna
10-07-2008 10:24 AM
Hi,
REPORT zchange_test MESSAGE-ID 38.
----
* Selection Screen Definitions *
----
PARAMETERS: p_vbeln TYPE vbap-vbeln OBLIGATORY, "Order Number
p_posnr TYPE vbap-posnr OBLIGATORY, "Order Item
p_etenr TYPE vbep-etenr OBLIGATORY, "Schedule Line
p_reqqty TYPE bapischdl-req_qty OBLIGATORY. " Order Qty
----
* Internal Tables/Structures/Variables for calling BAPI. *
----
DATA: i_hdr TYPE bapisdh1,
i_hdrx TYPE bapisdh1x,
i_ret TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
wa_ret TYPE bapiret2.
DATA: BEGIN OF i_sched OCCURS 10.
INCLUDE STRUCTURE bapischdl.
DATA: END OF i_sched.
DATA: BEGIN OF i_schedx OCCURS 10.
INCLUDE STRUCTURE bapischdlx.
DATA: END OF i_schedx.
----
* START-OF-SELECTION Event *
----
START-OF-SELECTION.
"----
" Initialize internal tables.
"----
REFRESH: i_sched, i_schedx, i_ret.
CLEAR: i_sched, i_schedx, i_ret.
"----
" Fill required ORDER_HEADER_IN data.
"----
i_hdrx-updateflag = 'U'.
"----
" Fill required SCHEDULE_LINES data.
"----
i_sched-itm_number = p_posnr.
i_sched-sched_line = p_etenr.
i_sched-req_qty = p_reqqty.
i_schedx-updateflag = 'U'.
i_schedx-itm_number = p_posnr.
i_schedx-sched_line = p_etenr.
i_schedx-req_qty = 'X'.
APPEND i_sched.
APPEND i_schedx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_in = i_hdr
order_header_inx = i_hdrx
TABLES
return = i_ret
schedule_lines = i_sched
schedule_linesx = i_schedx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
LOOP AT i_ret.
WRITE / i_ret-message.
ENDLOOP.
Try this Sample Code
Thanks,
Durai.V