Skip to Content
0
Jun 05, 2009 at 08:57 AM

Uexits and field mod. of a structure passed by ref: workarounds wanted

283 Views

Hi all experts,

for a requirement I have to inhibit a field of a purchase requisition from being modified (in ME5xN) under certain circumstances. I found the only user exit that seems quite good for the task, but here comes the problem.

The userexit is EXIT_SAPLMEREQ_005, which works on the following parameters:

FUNCTION EXIT_SAPLMEREQ_005.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(IM_REQ_ITEM) TYPE REF TO  IF_PURCHASE_REQUISITION_ITEM
*"     REFERENCE(IM_DATA_NEW) TYPE  MEREQ_ITEM
*"     REFERENCE(IM_DATA_OLD) TYPE  MEREQ_ITEM
*"     REFERENCE(IM_DATA_PERSISTENT) TYPE  MEREQ_ITEM
*"     REFERENCE(IM_FULL_CHECK) TYPE  SY-CALLD
*"     REFERENCE(IM_ITEM_HAS_ERRORS) TYPE  SY-CALLD
*"  EXPORTING
*"     REFERENCE(EX_MESSAGES) TYPE  MEREQ_T_BAPIRET2
*"     REFERENCE(EX_RECHECK_ITEM) TYPE  SY-CALLD
*"----------------------------------------------------------------------

INCLUDE ZXM02U05 .

ENDFUNCTION.

And here's the sketch I'd like to include in the ZXM02U05 report:

IF IM_DATA_PERSISTENT-ZST_SRM <> space 
AND IM_DATA_NEW-EPROFILE <> SPACE.
* these are the prerequisites
  IF IM_DATA_PERSISTENT-PSTYP <> im_data_new-PSTYP.
* I should avoid this situation: give an error msg 
* AND replace the new value of PSTYP with the previous one.  
    MESSAGE e009(zsrm) INTO wa_messages-message.
    wa_messages-type = 'E'.
    wa_messages-id = 'ZSRM'.
    wa_messages-number = 009.
    APPEND wa_messages TO ex_messages.
* HERE COMES THE TROUBLE... since the structures are
* available via ref., they are "greyish" in debug mode, so
* there's no way to make the following assignment work:
    im_data_new-PSTYP = IM_DATA_PERSISTENT-PSTYP.
  ENDIF.
ENDIF.

As explained in the code, I'm looking for a workaround in order to resume the previous value (stored in IM_DATA_PERSISTENT, but also in IM_DATA_OLD) AND give an error message. This is the desiderata since a changed PSTYP value throws a sequence of custom checks that bring - among the other consequences - a field lock on the PSTYP value. So I'd like to get outside this usr exit with an unmodified PSTYP value, if prerequisites and condition sussist.

Any hint or suggest is welcome , thanks a lot for your help.