08-16-2007 3:21 PM
Hi,
I need to write a program which will change rejection reason of selected sales order line items from "UP" to "99". Please let me know the best way of doing this.
Thanks,
Sandeep
08-16-2007 3:23 PM
Hi!
We were using BDC for a task like this in VA02...
Just create a recording in SM35 for it.
Regards
Tamá
08-16-2007 3:23 PM
Hi!
We were using BDC for a task like this in VA02...
Just create a recording in SM35 for it.
Regards
Tamá
08-16-2007 3:25 PM
The problem is that I have more than 8400 entries and many of the sales orders have more than one line items which has the ABGRU field value as 99. I think it would be a very complicated logic to perform this task using BDC.
08-16-2007 3:27 PM
BAPI is the Best Option.
BAPI_SALESORDER_CHANGE
and see the documentation of it.
Regards
Peram
08-16-2007 3:30 PM
I have explored this option as well. Could you confirm by using this BAPI will if have any other side-effects??
08-16-2007 3:33 PM
08-16-2007 3:32 PM
I Wrote a sample program for you, please let me know if you are successfull.
You can use the following bapi ...!
REPORT ZTEST_REASONREJ.
parameters : vbeln like vbak-vbeln.
DATA IT_ITEM TYPE STANDARD TABLE OF BAPISDITM.
DATA W_ITEM TYPE BAPISDITM.
DATA IT_ITEMX TYPE STANDARD TABLE OF BAPISDITMX.
DATA W_ITEMX TYPE BAPISDITM.
DATA IT_RETURN TYPE STANDARD TABLE OF BAPIRET2.
w_ordhinx-updateflag = 'U'.
W_ITEM-ITMNUMBER = '0010'.
W_ITEM-ITEMCATEG = 'ZTAN'.
W_ITEM-REASON_REJ = 'Z1'.
APPEND W_ITEM TO IT_ITEM.
W_ITEMX-ITMNUMBER = 'X'.
W_ITEMX-ITEMCATEG = 'X'.
W_ITEMX-REASON_REJ = 'X'.
APPEND W_ITEMX TO IT_ITEMX.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = vbeln
order_header_inx = w_ordhinx
tables
return = it_return
ORDER_ITEM_IN = it_item
ORDER_ITEM_INX = it_itemx
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
Reward Points if usefull.
Thanks and regards,
Veerendranath Maddula.
08-16-2007 3:35 PM
This requirement will work fine and there will not be any side effects because of this.
Just display the error log from it_return table.
Reward points again - if usefull.
Thanks and regards,
Veerendranath Maddula.
08-18-2007 4:05 PM
Hi Veera,
Your code does not work. I guess, there is some problem in the statement w_ordhinx-updateflag = 'U'. Could you tell me what exactly this statement does?
Thanks,
Sandeep
08-20-2007 9:51 AM
Ok, the problem might be with the second workarea where we should give value as X not 'U' .
You do one thing, keep the code same and change the following value to 'X'.
w_order_item_inx-updateflag = 'X'.
This will work, Reward points if usefull ..!
Thanks and regards,
Veeru.
08-21-2007 7:20 AM
Hi Veeru,
The code doesnt work inspite of this change. Here is the code that I am using. Correct me if I am going wrong anywhere.
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN type VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
ABGRU TYPE VBAP-ABGRU,
PSTYV TYPE VBAP-PSTYV,
END OF IT_VBAP.
DATA WA_VBAP like IT_VBAP.
DATA IT_ITEM TYPE STANDARD TABLE OF BAPISDITM.
DATA W_ITEM TYPE BAPISDITM.
DATA IT_ITEMX TYPE STANDARD TABLE OF BAPISDITMX.
DATA W_ITEMX TYPE BAPISDITMX.
DATA IT_RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA w_ordhinx type BAPISDH1X.
w_ordhinx-updateflag = 'X'.
W_ITEM-ITM_NUMBER = WA_VBAP-POSNR.
W_ITEM-ITEM_CATEG = WA_VBAP-PSTYV.
W_ITEM-REASON_REJ = wa_VBAP-ABGRU.
APPEND W_ITEM TO IT_ITEM.
W_ITEMX-ITM_NUMBER = WA_VBAP-POSNR.
W_ITEMX-ITEM_CATEG = WA_VBAP-PSTYV.
W_ITEMX-REASON_REJ = '99'.
APPEND W_ITEMX TO IT_ITEMX.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = wa_VBAP-VBELN
order_header_inx = w_ordhinx
tables
return = it_return
ORDER_ITEM_IN = it_item
ORDER_ITEM_INX = it_itemx .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
Thanks,
Sandeep
08-21-2007 9:01 AM
You should always reward points for all the replies, even if it is very helpfull, or helpfull this will encourage the people who will try to solve your problem.
Following is the code, just try it , this should work.
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN type VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
ABGRU TYPE VBAP-ABGRU,
PSTYV TYPE VBAP-PSTYV,
END OF IT_VBAP.
DATA WA_VBAP like IT_VBAP.
DATA IT_ITEM TYPE STANDARD TABLE OF BAPISDITM.
DATA W_ITEM TYPE BAPISDITM.
DATA IT_ITEMX TYPE STANDARD TABLE OF BAPISDITMX.
DATA W_ITEMX TYPE BAPISDITMX.
DATA IT_RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA w_ordhinx type BAPISDH1X.
w_ordhinx-updateflag = 'U'.
W_ITEM-ITM_NUMBER = WA_VBAP-POSNR.
w_order_item_in-material = wa_vbap-matnr.
W_ITEM-ITEM_CATEG = WA_VBAP-PSTYV.
W_ITEM-REASON_REJ = '99'.
APPEND W_ITEM TO IT_ITEM.
w_order_item_inx-updateflag = 'X'.
W_ITEMX-ITM_NUMBER = 'X'.
w_order_item_inx-material = 'X'.
W_ITEMX-ITEM_CATEG = 'X'.
W_ITEMX-REASON_REJ = 'X'.
APPEND W_ITEMX TO IT_ITEMX.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = wa_VBAP-VBELN
order_header_inx = w_ordhinx
tables
return = it_return
ORDER_ITEM_IN = it_item
ORDER_ITEM_INX = it_itemx .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
Reward points if usefull.
Thanks,
Veerendranath.