Skip to Content
0
Mar 19, 2009 at 02:36 PM

Looking for a sort of "activity code" in transactions ME51N/ME52N/ME53N

303 Views

Hi all experts, got an - I hope - interesting question to ask you.

I have an user exit that is executed on every step done in creation/modify of a Purchase requisition. In this code (custom), executed from the transactions ME51(n)/ME52(n) and ME53(n) there's something like:

GET PARAMETER ID 'BAN' FIELD r_banfn. "Purchase Requisition number
GET PARAMETER ID 'BFC' FIELD r_frgab. "Release strategy

r_banfn should contain the number of the purchase requisition I'm working on. So far, so good.

The problem is that if in ANY transaction I press the New Document button, I can notice in debug that r_banfn contains the number of the purchase requisition that WAS active before pressing the "create new" button.

That's not good because that r_banfn value is then used to some checks, and should then be blank in case of creation of a new purchase requisitions.

I'm then asking you if there's a way in my user exit to distinguish between the two cases, which are:

-1- I'm modifying an existing purchase requisition (so, the field in r_banfn IS correct);

-2- I'm CREATING a new document (so, r_banfn value is NOT correct and should be set to blank).

This distinction must be coded into the previously cited user exit and should affect ME51(n), ME52(n) and ME53(n), from which the user can either create a new RdA or modify an existing one.

We tried to manage the situation as follow, but without success:

IF NOT r_banfn IS INITIAL.
  CALL FUNCTION 'ENQUEUE_EMEBANE'
       EXPORTING
            banfn          = r_banfn
       EXCEPTIONS
            foreign_lock   = 1
            system_failure = 2
            OTHERS         = 3.
  IF sy-subrc NE 0.
* Can't lock --> means I'm actually working in modify mode on it 
* leave it as is
  ELSE.
* locked --> that means I'm not working on this purchase requisition
* first dequeue the locked purchase req, then set r_banfn to blank.
    CALL FUNCTION 'DEQUEUE_EMEBANE'
         EXPORTING
              banfn = r_banfn.
*   clear the variable -> I'm in CREATE mode.
    CLEAR r_banfn.
  ENDIF.
ENDIF.

The code is quite self-explaining but doesn't work because it seems that the "enqueue" phase goes ok even tho we're working on modification on the purchase requisition.

I'm guessing if there's a sort of "activity code" (create? modify? view?) I can catch @ runtime to solve this task.

Thanks in advance, as usual 😉

Matteo

Edited by: Matteo Montalto on Mar 19, 2009 5:15 PM

Sorry, I edited the title in order to make it more explicative. :-P