2008 Jul 31 9:20 AM
Hi,
I want to add new configurable item in existing sales order with charactersitic values.
Iam using bapi BAPI_SALESORDER_CHANGE.
Iam now able to insert configurable item in existing sales order.
But the characteristic values are not getting stored.
Latest code is attached. What else is missing for storing characteristic values ?
select maximum item number in sales order
SELECT MAX( POSNR ) FROM VBAP CLIENT SPECIFIED
INTO MAX_POSNR
WHERE MANDT = SY-MANDT AND
VBELN = I_SORDER.
TMP_POSNR = MAX_POSNR + 10.
WA_HDRX-UPDATEFLAG = 'U'. "update
SALES_DOC = I_SORDER.
item data
WA_ITEM-ITM_NUMBER = TMP_POSNR.
WA_ITEM-MATERIAL = 'LEFTEYE'.
WA_ITEM-PLANT = I_STORE.
WA_ITEM-SHIP_POINT = I_STORE.
APPEND WA_ITEM TO IT_ITEM.
WA_ITEMX-ITM_NUMBER = TMP_POSNR.
WA_ITEMX-UPDATEFLAG = 'I'. "add
WA_ITEMX-MATERIAL = 'X'.
WA_ITEMX-PLANT = 'X'.
WA_ITEMX-SHIP_POINT = 'X'.
APPEND WA_ITEMX TO IT_ITEMX.
Schedule lines
WA_SCHD-ITM_NUMBER = TMP_POSNR.
WA_SCHD-SCHED_LINE = TMP_POSNR.
WA_SCHD-REQ_DATE = SY-DATUM.
WA_SCHD-REQ_QTY = 1.
WA_SCHD-SCHED_TYPE = 'CN'.
APPEND WA_SCHD TO IT_SCHD.
WA_SCHDX-ITM_NUMBER = TMP_POSNR.
WA_SCHDX-SCHED_LINE = TMP_POSNR.
WA_SCHDX-REQ_DATE = 'X'.
WA_SCHDX-REQ_QTY = 'X'.
WA_SCHDX-SCHED_TYPE = 'X'.
APPEND WA_SCHDX TO IT_SCHDX.
config & characteristic values
WA_VALUE-CONFIG_ID = '000001'.
WA_VALUE-INST_ID = '00000001'.
WA_VALUE-CHARC = 'PRES_DIST_SPH'.
WA_VALUE-VALUE = '3.2'.
APPEND WA_VALUE TO IT_VALUE.
WA_INST-CONFIG_ID = '000001'.
WA_INST-INST_ID = '00000001'.
WA_INST-OBJ_TYPE = 'MARA'.
WA_INST-CLASS_TYPE = '300'.
WA_INST-OBJ_KEY = 'LEFTEYE'.
WA_INST-QUANTITY = 1.
WA_INST-QUANTITY_UNIT = 'NO'.
APPEND WA_INST TO IT_INST.
WA_REF-POSEX = TMP_POSNR.
WA_REF-CONFIG_ID = '000001'.
WA_REF-ROOT_ID = '00000001'.
APPEND WA_REF TO IT_REF.
WA_PART-CONFIG_ID = '000001'.
WA_PART-PARENT_ID = '00000001'.
WA_PART-INST_ID = '00000001'.
WA_PART-OBJ_TYPE = 'MARA'.
WA_PART-CLASS_TYPE = '300'.
WA_PART-OBJ_KEY = 'LEFTEYE'.
APPEND WA_PART TO IT_PART.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = SALES_DOC
ORDER_HEADER_INX = WA_HDRX
TABLES
RETURN = IT_RET
ORDER_ITEM_IN = IT_ITEM
ORDER_ITEM_INX = IT_ITEMX
ORDER_CFGS_REF = IT_REF
ORDER_CFGS_PART_OF = IT_PART
ORDER_CFGS_INST = IT_INST
ORDER_CFGS_VALUE = IT_VALUE
SCHEDULE_LINES = IT_SCHD
SCHEDULE_LINESX = IT_SCHDX.
READ TABLE IT_RET INTO WA_RET WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
I get the following messages from BAPI :
ORDER_HEADER_IN has been processed successfully.
ITEM_IN has been processed successfully
The sales document is not yet complete: Edit data
TIL-Direct Sales TINDC01372 has been saved
What else is missing ? Any help is appreciated.
thanks,
Nagarajan.J
2008 Jul 31 9:48 AM
Hello Nagarajan,
I have used this BAPI in my last task. You are passing the values correctly. I will tell you why it is giving like that message.
Whenever we will create a sales order in VA01 transaction, you will get a message like "The sales order is not complete, would you like to EDIT" while saving the sales order.... This is because of not providing complete data required for careation of sales order.
Try to implement the changes manually in VA02, if you get same errors, then you can find your code is correct.
Even I got same type of messages when changing a sales order to change the Rejection Reason for the items.
Best Regards,
Sasidhar Reddy Matli.
Edited by: Sasidhar Reddy Matli on Jul 31, 2008 2:20 PM
2008 Jul 31 11:57 AM
Hi Sasidhar,
Getting message is one part. But the input characteristics values in parameter tables IT_VALUE are not stored in the sales order.
What could be the reason ?
thanks,
Nagarajan J
2008 Sep 17 4:39 AM
Hi,
My problem is solved. Iam sharing it for the benefit of all.
In tables interface ORDER_ITEM_IN & ORDER_ITEM_INX, PO_ITM_NO to be filled same as ITM_NUMBER. This solved my problem.
regards,
Nagarajan.J