2010 Aug 16 9:36 AM
Hi Experts,
My requirement is to change the item number(POSNR) and vehicle(CHARG) of the existing sales order.
Please let me know can i achieve this using the FM BAPI_SALESORDER_CHANGE and what are the mandatory fields that should be passed?
If i use the below code, i will get the error that Sales document 0080614498 was not changed
i_hdrx-updateflag = 'U'.
i_itm-itm_number = '000020'.
i_itm-batch = '0010570000'.
i_itmx-itm_number = '000020'.
i_itmx-updateflag = 'U'.
i_itmx-batch = 'X'.
APPEND i_itm.
APPEND i_itmx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_inx = i_hdrx
TABLES
return = i_ret
order_item_in = i_itm
order_item_inx = i_itmx.
COMMIT WORK.
Please let me know what are the changes need to be done in the above code.
Thank you,
Regards,
Kavya
Hi Experts,
My requirement is to change the item number(POSNR) and vehicle(CHARG) of the existing sales order.
Please let me know can i achieve this using the FM BAPI_SALESORDER_CHANGE and what are the mandatory fields that should be passed?
If i use the below code, i will get the error that Sales document 0080614498 was not changed
i_hdrx-updateflag = 'U'.
i_itm-itm_number = '000020'.
i_itm-batch = '0010570000'.
i_itmx-itm_number = '000020'.
i_itmx-updateflag = 'U'.
i_itmx-batch = 'X'.
APPEND i_itm.
APPEND i_itmx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_inx = i_hdrx
TABLES
return = i_ret
order_item_in = i_itm
order_item_inx = i_itmx.
COMMIT WORK.
Please let me know what are the changes need to be done in the above code.
Thank you,
Regards,
Kavya
2010 Aug 16 9:40 AM
Hi
USE function module BAPI_TRANSACTION_COMMIT instead of COMMIT WORK. and check if u get correct output....
2010 Aug 16 9:45 AM
Hi,
Now i am getting the message"No data was changed"
Please advice me what other changes i need to make
2010 Aug 16 10:32 AM
Along with Order Item, you have to also fill in Mandatory fields of Header as well as the Schedule lines [SCHEDULE_LINES]
in the schedule lines you will have to fill in the item no, item qty, req date fields. Also partners.
2010 Aug 16 10:22 AM
Since, you are changing the POSNR which is a key field in the sales order. You have to delete the line item and recreate it with your new POSNR and CHARG.
Cheers,
Sujay
2010 Aug 17 8:31 AM
Hi All,
Thanks for your replies.
I tried the all the solution posted, but nothing is working,
I think as Sujay told we can't change the POSNR as it is key field.
Now if i want to copy the contents of old line item to new line item, what are the mandatory fields that should be passed into the FM BAPI_SALESORDER_CHANGE.
Thank you,
Regards,
Kavya
2010 Aug 16 10:27 AM
2010 Aug 16 10:43 AM
Hi Kavya
First you need to get the details of the sales order fo which you want to change the values.
please see the below code.
I hope it will work for you.
PARAMETERS : P_PO TYPE BAPIMEPOHEADER-PO_NUMBER OBLIGATORY.
*-----DECLARING TABLES AND WORKAREA TO FETCH THE VALUES FROM BAPI AND TO INSERT THE CHANGED VALUES AGAIN THROUGH BAPI--
DATA : IT_RETURN TYPE STANDARD TABLE OF BAPIRET2,
WA_RETURN TYPE BAPIRET2,
IT_PO TYPE STANDARD TABLE OF BAPIMEPOITEM,
WA_PO TYPE BAPIMEPOITEM,
IT_POX TYPE STANDARD TABLE OF BAPIMEPOITEMX,
WA_POX TYPE BAPIMEPOITEMX,
IT_POH TYPE STANDARD TABLE OF BAPIMEPOTEXTHEADER,
WA_POH TYPE BAPIMEPOTEXTHEADER.
START-OF-SELECTION.
**-- GETING DETAILS OF THE PO BY CALLING FM---**
CALL FUNCTION 'BAPI_PO_GETDETAIL1'
EXPORTING
PURCHASEORDER = P_PO " PURCHASEORDER IS NOT OPTIONAL IN FM.
TABLES
RETURN = IT_RETURN " FETCHING VALUES FROM RETURN TABLE AND POITEM TABLE IN OUR INTERNAL TABLES.
POITEM = IT_PO
POTEXTHEADER = IT_POH " FETCHING ALL THE HEADER TEXT IN OUR INTERNAL TABLE.
.
READ TABLE IT_RETURN INTO WA_RETURN WITH KEY TYPE = 'E'. " READING RETURN TABLE IF THERE IS ANY ERROR MESSAGE.
IF SY-SUBRC <> 0.
REFRESH IT_RETURN.
LOOP AT IT_PO INTO WA_PO. " CHANGING VALUES IN OUR INTERNAL TABLE.
WA_PO-SHORT_TEXT = 'PURCHASE ORDER FOR CHANGE'.
WA_PO-NET_PRICE = '3500.00'.
WA_PO-QUANTITY = 15.
WA_PO-MATERIAL = 'REM'.
MODIFY IT_PO FROM WA_PO. " MODIFYING INTERNAL TABLE.
WA_POX-PO_ITEM = WA_PO-PO_ITEM. " FETCHING THE CORRECT LINE ITEM FOR WHICH THE VALUES WILL BE CHANGED.
WA_POX-SHORT_TEXT = 'X'. " SETTING THE FIELDS WHICH WE ARE CHANGING IN TRUE CONDITION.
WA_POX-NET_PRICE = 'X'.
WA_POX-QUANTITY = 'X'.
WA_POX-MATERIAL = 'X'.
APPEND WA_POX TO IT_POX.
CLEAR : WA_PO, WA_POX.
ENDLOOP.
*---CALLING THE BAPI TO PASS THE CHANGED VALUE TO THE PO.---*
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = P_PO
TABLES
RETURN = IT_RETURN
POITEM = IT_PO
POITEMX = IT_POX
.
READ TABLE IT_RETURN INTO WA_RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
WRITE:/ ' THERE IS AN ERROR WHILE CHANGIN THE VALUES'.
ENDIF.
IF SY-SUBRC <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE:/ 'PO HAS BEEN CHANGED SUCCESSFULLY'.
ULINE.
LOOP AT IT_POH INTO WA_POH.
WRITE:/ WA_POH-PO_NUMBER, WA_POH-PO_ITEM, WA_POH-TEXT_LINE.
ENDLOOP.
ENDIF .
ENDIF.
2010 Aug 16 11:23 AM
Hi Kavya,
Refer to your code
Do pass item no in po_itm_no also which is missing in ur code.
i_itm_-po_itm_no = '000020'.
It will work.
bye
anya
2010 Aug 17 9:38 AM
Function module BAPISDORDER_GETDETAILEDLIST gives all the relevant details of the salesorder.
Get the details.
Delete the line item USING BAPI_SALESORDER_CHANGE giving the updateflag as 'D'.
Create the line item USING BAPI_SALESORDER_CHANGE giving the updateflag as 'U'.
Look into the documentation for the function module to get the primary keys for the same.
Cheers,
Sujay
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |