2009 May 28 7:13 PM
I am having a problem in BAPI. I have written the following routine to make change in a sales order. All I have to do is to change quantity in the sales order for a given sales order number. Its not updating?? The return table says in the MESSAGE field "Enter the document number" But I am passing the document number with the "salesdocument" field. Do I also need to enter the document number somewhere in "Order_header_in" table?
Also whats the field for order quantity field in the "order_item_in" table. I could see only one field called target quanity which I am using. Not sure if it is correct.
FORM SALESORDER_CHANGE .
DATA: order_item_in TYPE STANDARD TABLE OF bapisditm
WITH HEADER LINE,
order_item_inx TYPE STANDARD TABLE OF bapisditmx
WITH HEADER LINE,
return TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE,
salesdocument LIKE bapivbeln-vbeln,
order_header_in LIKE bapisdh1,
order_header_inx LIKE bapisdh1x,
schedule_lines TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE,
schedule_linesx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
REFRESH: order_item_in,
order_item_inx.
CLEAR: salesdocument.
loop at xlips.
CLEAR: salesdocument,
order_item_in,
order_item_inx.
salesdocument = xlips-vgbel.
ORDER_ITEM_IN-ITM_NUMBER = xlips-vgpos.
ORDER_ITEM_IN-TARGET_QTY = xlips-lfimg.
append ORDER_ITEM_IN.
ORDER_ITEM_INX-updateflag = 'U'.
ORDER_ITEM_INX-ITM_NUMBER = 'X'.
ORDER_ITEM_INX-TARGET_QTY = 'X'.
append ORDER_ITEM_INX.
endloop.
order_header_inx-updateflag = 'U'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE' "IN UPDATE TASK
EXPORTING
salesdocument = salesdocument
order_header_in = order_header_in
order_header_inx = order_header_inx
TABLES
ORDER_ITEM_IN = ORDER_ITEM_IN
ORDER_ITEM_INX = ORDER_ITEM_INX
schedule_lines = schedule_lines
schedule_linesx = schedule_linesx
return = return.
ENDFORM. " SALESORDER_CHANGE
I am having a problem in BAPI. I have written the following routine to make change in a sales order. All I have to do is to change quantity in the sales order for a given sales order number. Its not updating?? The return table says in the MESSAGE field "Enter the document number" But I am passing the document number with the "salesdocument" field. Do I also need to enter the document number somewhere in "Order_header_in" table?
Also whats the field for order quantity field in the "order_item_in" table. I could see only one field called target quanity which I am using. Not sure if it is correct.
FORM SALESORDER_CHANGE .
DATA: order_item_in TYPE STANDARD TABLE OF bapisditm
WITH HEADER LINE,
order_item_inx TYPE STANDARD TABLE OF bapisditmx
WITH HEADER LINE,
return TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE,
salesdocument LIKE bapivbeln-vbeln,
order_header_in LIKE bapisdh1,
order_header_inx LIKE bapisdh1x,
schedule_lines TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE,
schedule_linesx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
REFRESH: order_item_in,
order_item_inx.
CLEAR: salesdocument.
loop at xlips.
CLEAR: salesdocument,
order_item_in,
order_item_inx.
salesdocument = xlips-vgbel.
ORDER_ITEM_IN-ITM_NUMBER = xlips-vgpos.
ORDER_ITEM_IN-TARGET_QTY = xlips-lfimg.
append ORDER_ITEM_IN.
ORDER_ITEM_INX-updateflag = 'U'.
ORDER_ITEM_INX-ITM_NUMBER = 'X'.
ORDER_ITEM_INX-TARGET_QTY = 'X'.
append ORDER_ITEM_INX.
endloop.
order_header_inx-updateflag = 'U'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE' "IN UPDATE TASK
EXPORTING
salesdocument = salesdocument
order_header_in = order_header_in
order_header_inx = order_header_inx
TABLES
ORDER_ITEM_IN = ORDER_ITEM_IN
ORDER_ITEM_INX = ORDER_ITEM_INX
schedule_lines = schedule_lines
schedule_linesx = schedule_linesx
return = return.
ENDFORM. " SALESORDER_CHANGE
2009 May 28 8:14 PM
You are not checking sy-subrc after your loop and calling the BAPI unconditionally. If the internal table is empty, that is the error you will get.
Rob
2009 May 28 8:25 PM
Good point but in this case thats not the case. I checkd the internal table for Order_item_in has values in it. Also what is the field in the Order_item_in table for sales order quantity?
2009 May 28 8:28 PM
Either the table is empty or the field is empty. I don't think you can get this message any other way.
Rob
2009 May 28 8:42 PM
Its not empty but I just foun out that the sales order that needs to be changed is still in change mode and therefore locked. We deliver by going to sales order in change mode and do Sales Order --Deliver. May be the message is misleading but its not able to change because of this
2009 May 28 9:12 PM
No - if that's the case, you'll get a message that the order is locked. It's saying you aren't giving it a document number and I believe it.
Rob
2009 May 30 12:31 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |