2009 Jan 11 8:23 AM
Hi All,
Could any one of you plz provide the solution for the below problem:
1) I am processing the BAPI_SALESORDER_CHANGE to MODIFy the Quantity of existing line item and simultaneously INSERT a New ITEM.
2) When I am only modifying the REQ_QTY of 2 or more items it is processing correctly.
3) And if i INSERT a new item then it is INSERTING all fields correctly.
BUT if I both MODIFY the quantity of line item AND INSERT a new item .The Quantity of existing item is getting Updated Correctly.
BUT the Quanity of new Item is not the Quantity we send through the IDOC it is showing some different Quantity.
I am filling the following fields in my code :
For MODIFYING an existing Line Item QUANTITY:
wa_item_bapi-sales_unit = 'CT'.
wa_item_bapi-itm_number = '156'.
APPEND wa_item_bapi TO i_item_bapi.
*********UPDATE i_item_BAPIX
wa_item_bapix-itm_number = '156'.
wa_item_bapix-updateflag = c_u.
wa_item_bapix-sales_unit = c_x.
APPEND wa_item_bapix TO i_item_bapix.
wa_schedule-itm_number = lv_posnr.
wa_schedule-sched_line = '0001'.
wa_schedule-req_qty = 15.
wa_schedule-sched_type = CN.
APPEND wa_schedule TO i_schedule.
**UPDATE i_scheduleX
wa_schedulex-itm_number = 156.
wa_schedulex-sched_line = 0001.
wa_schedulex-sched_type = c_x.
wa_schedulex-updateflag = c_u.
wa_schedulex-req_qty = c_x.
APPEND wa_schedulex TO i_schedulex.
After this I am passing these internal tables to BAPI_SALESORDER_CHANGE
For INSERTING a NEW LINE ITEM.
wa_item_bapi-sales_unit = 'CT'.
wa_item_bapi-itm_number = '157'.
wa_item_bapi-hg_lv_item = '156'(this field we are passing the item number of existing item in the Salesorder)
wa_item_bapi-po_itm_no = Blank.
wa_item_bapi-material = gv_codmat.
wa_item_bapi-plant = ITPA.
wa_item_bapi-item_categ = 'xxxx'.
APPEND wa_item_bapi TO i_item_bapi.
*UPDATE i_item_BAPIX
wa_item_bapix-updateflag = c_i.
wa_item_bapix-material = c_x.
wa_item_bapix-sales_unit = c_x.
wa_item_bapix-plant = c_x.
wa_item_bapix-item_categ = c_x.
wa_item_bapix-hg_lv_item = c_x.
wa_item_bapix-itm_number = c_x.
wa_item_bapix-po_itm_no = c_x.
APPEND wa_item_bapix TO i_item_bapix.
wa_schedule-itm_number = '157'.
wa_schedule-sched_line = 0001.(this schedule line is that of item existing already in Sales order for item 156)
wa_schedule-sched_type = CN(this schedule type is that of item existing already in Sales order for item 156)
wa_schedule-req_qty = 15.
APPEND wa_schedule TO i_schedule.
*UPDATE i_scheduleX
wa_schedulex-itm_number = '157'.
wa_schedulex-sched_line = 0001(this schedule line is that of item existing already in Sales order for item 156)
wa_schedulex-sched_type = c_x.
wa_schedulex-updateflag = c_i.
wa_schedulex-req_qty = c_x.
APPEND wa_schedulex TO i_schedulex.
Now i process the BAPI_SALESORDER_CHANGE
Could any one plz provide help on it?
Hi All,
Could any one of you plz provide the solution for the below problem:
1) I am processing the BAPI_SALESORDER_CHANGE to MODIFy the Quantity of existing line item and simultaneously INSERT a New ITEM.
2) When I am only modifying the REQ_QTY of 2 or more items it is processing correctly.
3) And if i INSERT a new item then it is INSERTING all fields correctly.
BUT if I both MODIFY the quantity of line item AND INSERT a new item .The Quantity of existing item is getting Updated Correctly.
BUT the Quanity of new Item is not the Quantity we send through the IDOC it is showing some different Quantity.
I am filling the following fields in my code :
For MODIFYING an existing Line Item QUANTITY:
wa_item_bapi-sales_unit = 'CT'.
wa_item_bapi-itm_number = '156'.
APPEND wa_item_bapi TO i_item_bapi.
*********UPDATE i_item_BAPIX
wa_item_bapix-itm_number = '156'.
wa_item_bapix-updateflag = c_u.
wa_item_bapix-sales_unit = c_x.
APPEND wa_item_bapix TO i_item_bapix.
wa_schedule-itm_number = lv_posnr.
wa_schedule-sched_line = '0001'.
wa_schedule-req_qty = 15.
wa_schedule-sched_type = CN.
APPEND wa_schedule TO i_schedule.
**UPDATE i_scheduleX
wa_schedulex-itm_number = 156.
wa_schedulex-sched_line = 0001.
wa_schedulex-sched_type = c_x.
wa_schedulex-updateflag = c_u.
wa_schedulex-req_qty = c_x.
APPEND wa_schedulex TO i_schedulex.
After this I am passing these internal tables to BAPI_SALESORDER_CHANGE
For INSERTING a NEW LINE ITEM.
wa_item_bapi-sales_unit = 'CT'.
wa_item_bapi-itm_number = '157'.
wa_item_bapi-hg_lv_item = '156'(this field we are passing the item number of existing item in the Salesorder)
wa_item_bapi-po_itm_no = Blank.
wa_item_bapi-material = gv_codmat.
wa_item_bapi-plant = ITPA.
wa_item_bapi-item_categ = 'xxxx'.
APPEND wa_item_bapi TO i_item_bapi.
*UPDATE i_item_BAPIX
wa_item_bapix-updateflag = c_i.
wa_item_bapix-material = c_x.
wa_item_bapix-sales_unit = c_x.
wa_item_bapix-plant = c_x.
wa_item_bapix-item_categ = c_x.
wa_item_bapix-hg_lv_item = c_x.
wa_item_bapix-itm_number = c_x.
wa_item_bapix-po_itm_no = c_x.
APPEND wa_item_bapix TO i_item_bapix.
wa_schedule-itm_number = '157'.
wa_schedule-sched_line = 0001.(this schedule line is that of item existing already in Sales order for item 156)
wa_schedule-sched_type = CN(this schedule type is that of item existing already in Sales order for item 156)
wa_schedule-req_qty = 15.
APPEND wa_schedule TO i_schedule.
*UPDATE i_scheduleX
wa_schedulex-itm_number = '157'.
wa_schedulex-sched_line = 0001(this schedule line is that of item existing already in Sales order for item 156)
wa_schedulex-sched_type = c_x.
wa_schedulex-updateflag = c_i.
wa_schedulex-req_qty = c_x.
APPEND wa_schedulex TO i_schedulex.
Now i process the BAPI_SALESORDER_CHANGE
Could any one plz provide help on it?
2009 Apr 20 8:24 PM
I had similar problem and apparently finding the right Itm_number is critical.
*Get from VBAP all the records
SELECT VBELN POSNR MATNR kwmeng INTO TABLE IT_VBAP
FROM VBAP WHERE VBELN = P_VBELN.
*Get the value by which SAP increments the POSNR
SELECT SINGLE INCPO INTO lv_incr FROM TVAK WHERE AUART = P_ORD_TYP.
*Get the last item record
sort it_vbap by vbeln ascending posnr descending.
read table it_vbap into wa_vbap index 1.
*Get the item number that SAP will assign
lv_itm_num = lv_incr + wa_vbap-posnr.
For new items that are to be added.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = input_matnr
IMPORTING
OUTPUT = lt_so_itm_in-material.
lt_so_itm_in-ITM_NUMBER = lv_itm_num.
APPEND lt_so_itm_in.
lt_so_itm_inx-updateflag = c_i.
lt_so_itm_inx-material = c_x.
lt_so_itm_inX-ITM_NUMBER = lv_itm_num.
APPEND lt_so_itm_inx.
lt_so_sch_in-ITM_NUMBER = lv_itm_num.
lt_so_sch_in-REQ_QTY = lv_MENGE.
append lt_so_sch_in.
lt_so_sch_in-ITM_NUMBER = lv_itm_num.
lt_so_sch_inx-UPDATEFLAG = c_i.
lt_so_sch_inx-REQ_QTY = c_x.
append lt_so_sch_inx.
lv_itm_num = lv_itm_num + lv_incr.
*The BAPI call looks like below
CLEAR: lt_so_rtn[], lt_so_rtn.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_sodoc
order_header_inx = lst_so_hdr_inx
TABLES
return = lt_so_rtn
order_item_in = lt_so_itm_in
order_item_inx = lt_so_itm_inx
SCHEDULE_LINES = lt_so_sch_in
SCHEDULE_LINESx = lt_so_sch_inx.
READ TABLE lt_so_rtn WITH KEY type = c_e.
IF sy-subrc <> 0. "No errors found
Transaction Commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
endif.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |