11-06-2007 5:42 AM
hi experts,
i am using the bapi BAPI_SALESORDER_CHANGE to update a sales order by adding new line item to the sales order... it is adding the new line item but the problem is that it is not taking into consideration the order quantity...
am passing the data as follows:
import
SALESDOCUMENT = sales document number (5488)
ORDER_HEADER_INX-UPDATEFLAG = 'U'
tables
ORDER_ITEM_IN-MATERIAL = matnr (12871)
ORDER_ITEM_IN-TARGET_QTY = 75
then i run the bapi BAPI_TRANSACTION_COMMIT
the sales order is updated with the new line item but order quantity remains blank...
please help me on this..
points will be rewarded..
regards,
vitish
11-06-2007 6:10 AM
Hi,
Check this sample code to update quantity.
DATA: T_ITEM LIKE BAPISDITM OCCURS 0 WITH HEADER LINE.
DATA: T_ITEMX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE.
DATA: T_SCHE LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE.
DATA: T_SCHEX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE.
DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: BAPISDH1X LIKE BAPISDH1X.
PARAMETERS: P_VBELN LIKE VBAK-VBELN OBLIGATORY.
PARAMETERS: P_KWMENG LIKE VBAP-KWMENG OBLIGATORY.
BAPISDH1X-UPDATEFLAG = 'U'.
T_ITEM-ITM_NUMBER = '000010'.
APPEND T_ITEM.
T_ITEMX-ITM_NUMBER = '000010'.
T_ITEMX-UPDATEFLAG = 'U'.
APPEND T_ITEMX.
T_SCHE-ITM_NUMBER = '000010'.
T_SCHE-SCHED_LINE = '0001'.
T_SCHE-REQ_QTY = P_KWMENG.
APPEND T_SCHE.
T_SCHEX-ITM_NUMBER = '000010'.
T_SCHEX-SCHED_LINE = '0001'.
T_SCHEX-REQ_QTY = 'X'.
APPEND T_SCHEX.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = P_VBELN
order_header_inx = BAPISDH1X
tables
return = T_RETURN
ORDER_ITEM_IN = T_ITEM
ORDER_ITEM_INX = T_ITEMX
SCHEDULE_LINES = T_SCHE
SCHEDULE_LINESX = T_SCHEX
.
COMMIT WORK.
Thanks
naren
11-06-2007 5:46 AM
Hi,
You need to pass the quantity in the scheduleline parameter
Thanks
Naren
11-06-2007 5:50 AM
hi naren,
thanks for the quick reply...i've tried passing the quantity to the field REQ_QTY of the parameter SCHEDULE_LINES but it does not work also...
regards,
vitish
11-06-2007 5:57 AM
Hi,
You have to pass both the schedule_lines and SCHEDULE_LINESX parameter..
IN the schedule_linesx parameter I believe you have to pass UPDATEFLAG = 'I'
Thanks
Naren
11-06-2007 6:02 AM
hi,
i tried passing 'I' to the field updateflag of the parameter SCHEDULE_LINESX also...still does not work...
thanks,
vitish
11-06-2007 6:10 AM
Hi,
Check this sample code to update quantity.
DATA: T_ITEM LIKE BAPISDITM OCCURS 0 WITH HEADER LINE.
DATA: T_ITEMX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE.
DATA: T_SCHE LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE.
DATA: T_SCHEX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE.
DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: BAPISDH1X LIKE BAPISDH1X.
PARAMETERS: P_VBELN LIKE VBAK-VBELN OBLIGATORY.
PARAMETERS: P_KWMENG LIKE VBAP-KWMENG OBLIGATORY.
BAPISDH1X-UPDATEFLAG = 'U'.
T_ITEM-ITM_NUMBER = '000010'.
APPEND T_ITEM.
T_ITEMX-ITM_NUMBER = '000010'.
T_ITEMX-UPDATEFLAG = 'U'.
APPEND T_ITEMX.
T_SCHE-ITM_NUMBER = '000010'.
T_SCHE-SCHED_LINE = '0001'.
T_SCHE-REQ_QTY = P_KWMENG.
APPEND T_SCHE.
T_SCHEX-ITM_NUMBER = '000010'.
T_SCHEX-SCHED_LINE = '0001'.
T_SCHEX-REQ_QTY = 'X'.
APPEND T_SCHEX.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = P_VBELN
order_header_inx = BAPISDH1X
tables
return = T_RETURN
ORDER_ITEM_IN = T_ITEM
ORDER_ITEM_INX = T_ITEMX
SCHEDULE_LINES = T_SCHE
SCHEDULE_LINESX = T_SCHEX
.
COMMIT WORK.
Thanks
naren
11-06-2007 7:27 AM
hi naren,
it's working for adding 1 line item...but now am trying to add 2 or more line items...the problem is that it is taking the quantity for the first itemi only and ignoring the quantity for the remaining items...what do u suggest to do...?
regards,
vitish
02-04-2008 12:38 PM
IF U MAKE SCHEDULE LINE ITEM NO. TO BE TO BE UNIQUE FOR EACH LINE ITEM. IT WILL SHOW THE QUANTITY. ETENR IN VBEP WILL BE 001 ONLY.
***********************************************************************
**This creates additional line no. in the sales order.
**Material no is hard coded, you need to change the materisl no in
**available in ur system.
************************************************************************
*
T_ITEM-itm_number = ''.
T_ITEM-material = 'AGA350'.
T_ITEM-target_qty = '2'.
APPEND T_ITEM.
T_ITEMx-itm_number = ''.
T_ITEMX-UPDATEFLAG = 'I'.
T_ITEMX-target_qty = 'X'.
T_ITEMX-material = 'X'.
APPEND T_ITEMX.
T_SCHE-SCHED_LINE = '1'.
T_SCHE-REQ_QTY = 2.
t_sche-req_date = '20080204'.
APPEND T_SCHE.
T_SCHEX-updateflag = c_insertflag.
t_schex-req_date = 'X'.
T_SCHEX-SCHED_LINE = '1'.
t_schex-req_qty = 'X'.
APPEND T_SCHEX.
***********************************************************************
**This also creates additional line no. in the sales order.
**Material no is hard coded, you need to change the materisl no in
**available in ur system.
***********************************************************************
*T_ITEM-itm_number = ''.
T_ITEM-material = 'AGA350'.
T_ITEM-target_qty = '1'.
APPEND T_ITEM.
*T_ITEMx-itm_number = ''.
T_ITEMX-UPDATEFLAG = 'I'.
T_ITEMX-target_qty = 'X'.
T_ITEMX-material = 'X'.
APPEND T_ITEMX.
T_SCHE-SCHED_LINE = '4'.
t_sche-req_date = '20080202'.
T_SCHE-REQ_QTY = 1.
APPEND T_SCHE.
T_SCHEX-updateflag = c_insertflag.
t_schex-req_date = 'X'.
T_SCHEX-ITM_NUMBER = 'X'.
T_SCHEX-SCHED_LINE = '4'.
T_SCHEX-REQ_QTY = 'X'.
APPEND T_SCHEX.
02-04-2008 12:40 PM
HOW DID U MANAGE TO SOLVE THE QTY BLANK ISSUE FOR ITEM 2,3,4 ..... I SOLVED IT THE WAY I HAVE MENTIONED IN THE POST, HOWEVER IF THERE IS ANOTHER WAY TO DO IT PLZ. LET ME.