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: 

Triggering of enhancement codes upon changes on certain field only

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

10 REPLIES 10

Jelena
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thanks Jelena. I tried embedded my custom code into user exit MV45AFZZ 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.

Jelena
Active Contributor
0 Kudos

User exit to check VBAP values is USEREXIT_CHECK_VBAP in MV45AFZB. It's not going to highlight the whole line item, but I believe it should position the cursor on the item in question. I don't have it implemented in the current system, so can't confirm, unfortunately.

Former Member
0 Kudos

Hi Jelena, thanks for your suggestion!

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

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!

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.