Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Program to update the reason of rejection (VBAP-ABGRU) field.

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi!

We were using BDC for a task like this in VA02...

Just create a recording in SM35 for it.

Regards

Tamá

11 REPLIES 11

Former Member
0 Kudos

Hi!

We were using BDC for a task like this in VA02...

Just create a recording in SM35 for it.

Regards

Tamá

0 Kudos

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.

Former Member
0 Kudos

BAPI is the Best Option.

BAPI_SALESORDER_CHANGE

and see the documentation of it.

Regards

Peram

0 Kudos

I have explored this option as well. Could you confirm by using this BAPI will if have any other side-effects??

0 Kudos

i dont think so ? y u got this kind of Q's ?

Regards

Peram

Former Member
0 Kudos

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.

0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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.