I have a requirement where I need to restrict the PO Quantity, against an approved value, while creation or while changing.
For this, I have implemented a BADI ME_PROCESS_PO_CUST . When the user creates a PO (txn ME21N), I am chceking for the sy-tcode = ME21N and processing a block of code. If the user changes the created PO (txn ME22N) I am checking for the sy-tcode = ME22N and executing another block of code. Till this everything is working fine.
if sy-tcode = 'ME21N'. perform block A. elseif sy-tcode = 'ME22N' perform block B. endif.
But the problem arises, when the user creates a PO and tries to change it from transaction ME21N itself (through 'Other Purchase Order' button on the toolbar). This time the sy-tcode remains to be ME21N and therefore my ME21N block of code gets executed. This means eventhough the user is changing the PO (as normally done in ME22N), I am still executing the code of ME21N. And this gives me wrong results.
So, my question is, how do i identify whether the user is changing the PO directly from ME22N or he is changing it via ME21N -> Other Purchase Order button ?
Hope I am not confusing you guys !.
Please suggest some workarounds.