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: 

Get selected screen field in standard screen.

ronaldo_aparecido
Contributor
0 Kudos

Hi experts.

I'm working in XD02 / XD01 transaction.

WHen the user input data in postal check and click ENTER my badi is called with my code and it works ok.

My problem is :When the user input field in other field (country for example) and click enter then my badi is called and do my validation again.

I NEED A WAY TO KNOW IN MY BADI ( BY CODIFICATION)  IF THE ENTER IS CLICKED IN FIELD POSTAL CHECK OR IN OTHER FIELD THEN I CAN PUT A 'IF ' TO DO OR NOT MY VALIDATION.

COULD YOU HELP ME?

THANKS.

3 REPLIES 3

guilherme_frisoni
Contributor
0 Kudos

Hi Ronaldo,

try to use GET CURSOR FIELD. It depends when your BADI is called.

But for your request, maybe a field exit is a proper way to achieve this.

Regards,

Frisoni

Juwin
Active Contributor
0 Kudos

Your validation shouldn't be coded on what the user clicked, but it should be on what the value is in the screen field.


What if the user didn't press any Enter anywhere and just updates the value on the screen field and presses save? The cursor may not be on the postal code field at that time.

If your concern is that the code in BADI is being executed repeatedly for each user action, and if you feel that it is unnecessary, you should check if the value in the screen field has changed before executing the custom code. That can be done by storing the value of field in a global variable and comparing against it before executing the validation code again.

My advice is, don't code specific to cursor position or user commands.

Thanks,

Juwin

former_member185414
Active Contributor
0 Kudos

Hi Ronaldo,

My approach to your problem would be based on screen programming.

I will first get the postal code value from the database table in my exit.

Then I will read the current value of postal code

data: <fs_postal> type AD_PSTCD1.

assign ('(SAPMF02D)ADDR1_DATA-POST_CODE1') to <fs_postal>.

          If sy-subrc = 0.

" Do the checking that whether the old postal code and new postal code are different, if yes then you should trigger your validation, else skip.

          endif.

PS: There can be a scenario when the user enters the new post code which is same as the old post code and above logic will not trigger for validation. In this case my assumption is that if the old post code was valid then the new one which is same as the old one is also valid and there is no need to do any validation again.

BR.