05-26-2011 5:28 AM
Hello community,
I am about to use the BAPI function called "BAPI_SALESORDER_CHANGE" to insert new schedule lines to an existing Sales Order with let's say 1 Item and 2 existing schedule lines. I suppose I have to set the "UPDATEFLAG" for each new schedule line to "I" for insert. Furthermore I need to refer to the Order Number by providing "SALESDOCUMENT" and so on.
Do I need to provide the parameter "SCHED_LINE" to the BAPI call in order to add a new schedule line?
If so, what value would I use for "SCHED_LINE" ?
If so, can I use any value not already used by existing "SCHED_LINE" fields for that specific item?
If not, what happens with that Sales Order when I do not set "SCHED_LINE" ?
Thanks in advance!
05-26-2011 5:39 AM
See the following example
LOOP AT itab_ch .
* Header update indicator
s_order_header_inx-updateflag = 'U'.
* Line items
i_order_item_in-itm_number = itab_ch-itm_number .
i_order_item_in-material = itab_ch-material.
i_order_item_in-target_qty = itab_ch-target_qty.
i_order_item_in-sales_unit = itab_ch-sales_unit.
i_order_item_in-val_type = itab_ch-val_type.
i_order_item_inx-updateflag = 'I'.
i_order_item_inx-itm_number = itab_ch-itm_number .
i_order_item_inx-material = itab_ch-material.
i_order_item_inx-target_qty = 'X'.
i_order_item_inx-sales_unit = itab_ch-sales_unit.
i_order_item_inx-val_type = 'X'.
APPEND: i_order_item_in, i_order_item_inx.
** Fill schedule lines
i_sched-itm_number = itab_ch-itm_number .
i_sched-sched_line = '0001'.
i_sched-req_qty = itab_ch-target_qty.
APPEND i_sched.
* Fill schedule line flags
i_schedx-itm_number = itab_ch-itm_number .
i_schedx-sched_line = '0001'.
i_schedx-updateflag = 'I'.
i_schedx-req_qty = 'X'.
APPEND i_schedx.
ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_in = s_order_header_in
order_header_inx = s_order_header_inx
behave_when_error = 'P'
TABLES
return = it_return
order_item_in = i_order_item_in
order_item_inx = i_order_item_inx
schedule_lines = i_sched
schedule_linesx = i_schedx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
05-26-2011 5:39 AM
See the following example
LOOP AT itab_ch .
* Header update indicator
s_order_header_inx-updateflag = 'U'.
* Line items
i_order_item_in-itm_number = itab_ch-itm_number .
i_order_item_in-material = itab_ch-material.
i_order_item_in-target_qty = itab_ch-target_qty.
i_order_item_in-sales_unit = itab_ch-sales_unit.
i_order_item_in-val_type = itab_ch-val_type.
i_order_item_inx-updateflag = 'I'.
i_order_item_inx-itm_number = itab_ch-itm_number .
i_order_item_inx-material = itab_ch-material.
i_order_item_inx-target_qty = 'X'.
i_order_item_inx-sales_unit = itab_ch-sales_unit.
i_order_item_inx-val_type = 'X'.
APPEND: i_order_item_in, i_order_item_inx.
** Fill schedule lines
i_sched-itm_number = itab_ch-itm_number .
i_sched-sched_line = '0001'.
i_sched-req_qty = itab_ch-target_qty.
APPEND i_sched.
* Fill schedule line flags
i_schedx-itm_number = itab_ch-itm_number .
i_schedx-sched_line = '0001'.
i_schedx-updateflag = 'I'.
i_schedx-req_qty = 'X'.
APPEND i_schedx.
ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_in = s_order_header_in
order_header_inx = s_order_header_inx
behave_when_error = 'P'
TABLES
return = it_return
order_item_in = i_order_item_in
order_item_inx = i_order_item_inx
schedule_lines = i_sched
schedule_linesx = i_schedx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
05-26-2011 5:50 AM
Looking at this example it looks like I have to provide the schedule line identifier mandatory even for NEW schedule lines.
* Fill schedule line flags
i_schedx-itm_number = itab_ch-itm_number .
i_schedx-sched_line = '0001'.
i_schedx-updateflag = 'I'.
i_schedx-req_qty = 'X'.
APPEND i_schedx.
ENDLOOP.
Is filling sched_line mandatory?
Can I increase that value when there are existing schedule lines? E.g. set it to 0002 when 0001 exists?
05-26-2011 5:51 AM
yes to create or update any schedule line, this value has to be populated, its like VBEP-ETENR, if the line item has no schedule items tilll date, populate SCHED_LINE starting from 0001, 0002..etc, else increment the existing scedule line number by 1 and fill in SCHEDULE_LINES and SCHEDULE_LINESX
05-26-2011 6:04 AM
Thanks, I have read different opinions on that. Somebody was mentioning that you do not need to fill the SCHED_LINE for new schedule lines at all when using UPDATEFLAG = I. Suppose that is wrong then.