Skip to Content
avatar image
Former Member

Triggering of enhancement codes upon changes on certain field only

Hi,

Considers the below statements in SAPMV45A, Screen 4900 (PAI module).

    CHAIN.

       FIELD: vbap-matnr,

              vbapd-matnr_g,

              rv45a-mabnr,

* IS2ERP Media enhancement

              vbap-idcodetype,                           "ISBN-Nr.

              vbap-ismidentcode,                         "ISBN-Nr.

              vbap-kdmat,

              vbap-posex

               MODULE vbap-posex_pruefen ON CHAIN-REQUEST.

     ENDCHAIN.

I implemented my code enhancement in module 'vbap-posex_pruefen'.

May I know is there a way to trigger the enhancement codes only when VBAP-KDMAT is changed (while changes on other fields such as vbap-matnr, vbap-posex etc will not trigger it)?

Kindly please let me know if you know how to achieve this.

Thank much, Nick

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 17, 2013 at 04:26 PM

    Hi Nicholas,

    Currently I am not over my system, so I can't tell you the correct answer, but would request you to look into the following proposed solutions :

    1. Check if system contains the unchanged value ( previous value ) in variable YVBAP, if yes, then you can put your piece in code inside If clause ( If YVBAP-posex_pruefe NE XVBAP-posex_pruefe ).

    2. Otherwise you can also check, if there is some Exit in PBO, if yes, set unchanged value in memory and then again check for the changed variable in PAI block.

    Hope it helps.

    Thanking You All.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 15, 2013 at 08:31 PM

    Why did you put an enhancement there? There is the whole bunch of user exits available in SD, they're well documented and may be used to compare old and new values. Google -> SD user exit site:sap.com

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 15, 2013 at 10:30 PM

    Hi Nicholas,

    If you want to do a change to a field in the Sales item level, then you can achieve it in the subroutine - USEREXIT_MOVE_FIELD_TO_VBAP in the INclude - MV45AFZZ..

    Since the above routine is triggered whenever you do changes to Sales line item. So you can introduce your check here

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Raja. Initially, I tried embedded my custom code into user exit MV45AFZZ (subroutine userexit_field_modification) before this. However, I found that when it triggers my custom code, it wouldn't select/highlight the line item that triggered it. I would like to focus on that specific line item (that triggers the custom code) so that user will aware of that line item and then made the necessary data input correction on it. Thanks.

  • avatar image
    Former Member
    Aug 16, 2013 at 01:11 AM

    Instead of having the code within the chain, you can use this:

    Field vbap-kdmat module vbap-posex_pruefen on request.

    The module will only be entered if the value of vbap-kdmat is changed or considered to be changed....

    Help says,

    FIELD dynp_field MODULE mod [ {ON INPUT}

                                | {ON REQUEST}

                                | {ON *-INPUT}

                                | {ON {CHAIN-INPUT|CHAIN-REQUEST}}

                                | {AT CURSOR-SELECTION}.

    Addition 2

    ... ON REQUEST

    Effect

    With this condition, module mod is called only if the value of the screen field dynp_field has been changed by input after the event PBO. It is considered as input if the existing input is overwritten with the same value or if the initial value of the field is entered explicitly. Besides user input, the following value input results in a call of mod:

    • Transfer of a default value set via System → User Profile → Hold Data. However, this requires the dynpro property Hold Data to be active.
       
    • Tansfer of a default value from the SAP Memory. This requires that in the PARAMETER-ID property of a screen element an SPA/GPA parameter is specified.
       
    • Transfer of data that is passed in the call of a dialog transaction using the addition USING of the DS:ABAP.CALL_TRANSACTION>CALL TRANSACTION statement.
       
    • Transfer of a default value predefined in the system or in the ABAP Dictionary for input/output fields of certain types.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Neil for your reply. My question is your suggested approach will involve the modification of SAPMV45A - Screen 4900, right? I am trying to avoid changing the SAP Screen as the changes might be lost when there is an upgrade in the future. Thanks again!

  • avatar image
    Former Member
    Aug 20, 2013 at 08:05 AM

    Thanks Ankit for your valuable suggestions. Initially, I was trying to use the YVBAP-KDMAT and XVBAP-KDMAT variables for comparison. However, I found that these two variables are sometimes not populated correctly (Do you know why?). Therefore, I chose to use your second suggested approach which is to store the previous unchanged value in Abap memory and then retrieve it for comparison against the latest changed value when user changed the CPN #. Thanks again, Ankit.

    Add comment
    10|10000 characters needed characters exceeded