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: 

Exit or BADI to find out PO Change

former_member182337
Participant
0 Kudos

Hello,

I would like to get the changed information of a PO. For example,i login to ME22n and change quantity of a PO item. Example : From 10 to 20. When i press the back button standard SAP throws the message that the PO has been changed and if you wish to save it.

I would like to get that standard message when i click on a custom button inside my PO.Everytime the user changes one or the other entry and on click of the custom button the message "PO has been changed. Do you wish to save" should appear. How will i find out if the PO has been changed. Are there any methods for the same?

Regards,

Prem

6 REPLIES 6

former_member182337
Participant
0 Kudos

Any suggestions?

0 Kudos

Prem,

As far as my understanding goes, there is no direct way of checking if the PO is changed. If its changed from SRM, there is a BADI you can make use of. Since you are changing the PO in R3 itself,  you need to use BBP_PO_GETDETAIL to get the existing PO and check with the data available in the changed PO, field by field.

Let me know if you need more info.

Thanks,

Sreekanth


0 Kudos

Please check out this Document written by me.

Search this way.. You can find the relevant BADI you want.

http://scn.sap.com/docs/DOC-33611

Hope this helps..

Former Member
0 Kudos

dear prem,

There is a better way of achieving this functionality.There is a system variable SY-DATAR.

If any value is changed in the screen it will have 'X'.Otherwise it will be initial.

Depending upon the flag you can throw message at your custom tab

Thanks

goudham

0 Kudos

Hi Goudham,

The are some issues with SY-DATAR solution in my opinion:

1. when you change some field (eg. quantity in item overview) and then change some tabstrips in item or header (where you will not change anything) field SY-DATAR will be cleared. That means you would have it set only when pressing SAVE button immediately after changing the field content.

2. even when having this field set, you have no information which field was actually changed, so you have to find it out yourself.

That's why I would propose following approach:

- Make use of Badi: ME_PROCESS_PO_CUST. You have a method OPEN which is triggered each time you open a PO. You have access to IM_HEADER (of type: IF_PURCHASE_ORDER_MM) which allows you to access both Header & Items data. Read those data, and save it as open_header and open_items in class which implements your Badi.

- While saving you can use another method of this Badi: POST. In that method you have access to IM_HEADER element again, however it will contain 'changed' data. That means, all you have to do is to get post_header and post_items and compare it to your initial structures saved in class (in OPEN method).

- I would recommend to make use of cl_abap_typedesc to get components of structures, and loop at them comparing fields content.

Best regards,

Marcin Cudo

0 Kudos

Thanks for sharing. This is very helpful.