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: 

Update an input field after a click on Enter

bzakaria
Participant

Hello,

In an abap program, I have a dynpro which contains an input field and an output field. I want to know how to update the output field after entering data on the input field and click on 'Enter' on the keyboard by the user .

Example: the user enters the customer code and after a click on 'Enter' the customer name is displayed in the output field.

Regards,

1 ACCEPTED SOLUTION

TharinduB1
Explorer

Hi Zakaria,

Implement your logic inside Process After Input Module.

eg.

Inside user command module add the code segment to select customer name as like below.

SELECT name1 from KNA1 into var1 WHERE KUNNR = var2.
9 REPLIES 9

michael_piesche
Active Contributor

This is how it will work for you, let me know if you need further information:

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) FOR FIELD f_input. " attribute description if wanted
PARAMETERS: f_input TYPE char10.                 " your input value with your data type
SELECTION-SCREEN COMMENT (02) dummy.             " to leave some space
SELECTION-SCREEN COMMENT (30) f_output.          " your output description
SELECTION-SCREEN END OF LINE.



AT SELECTION-SCREEN OUTPUT. " this is triggered when pressed 'ENTER'
  " set your logic here to fill f_output based on f_input
  f_output = 'Test'

TharinduB1
Explorer

Hi Zakaria,

Implement your logic inside Process After Input Module.

eg.

Inside user command module add the code segment to select customer name as like below.

SELECT name1 from KNA1 into var1 WHERE KUNNR = var2.

former_member1716
Active Contributor

bzakaria,

If its a Report Program:

You could write your code in the event AT SELECTION SCREEN. Your understanding on events is very important to write the code. Below are the two events that may confuse you, their understanding can give you a clarity.

AT SELECTION SCREEN OUTPUT --> This Event is triggered before the screen is displayed. You cannot write your logic here because when this event is triggered your user still would have not entered any value.

AT SELECTION SCREEN --> This event is used to validate your inputs which are entered in the screen. This event will be suitable for your requirement since you want to extract the text based on the input.

AT SELECTION SCREEN.
* Write a select Query that will fetch the text for the customer code and feed it to the output field

Two Points you need to handle:

1) There can be a scenario where the customer code is empty, in that case ensure your select query does not run unnecessarily.

2) The customer code value entered can be wrong as well, so its important you validate the customer code before you write a query for fetching the text.

If its a Module Pool program:

You have to write your Code in the event PROCESS AFTER INPUT of the screen.The above consideration will hold true here as well.

Regards!

0 Kudos

This is a bit confusing. It's perfectly possible to use screens other than a selection screen in a report program..

bzakaria
Participant
0 Kudos

michael.piesche , th_budunwela44 , satishkumarbalasubramanian

Thank you for your help.

I would like to know how to distinguish between the input fields. because my case is that I have 4 input fields and 4 output fields, each output field displays the designation of an input field.

Today when clicks on 'Enter' in an input field: 4 requests are executed.

regards,

bzakaria , please follow the community guidelines:

  1. Dont use the Answer function when asking a question and not giving an answer to your problem
  2. If your original question is answered, please mark it as answered and close it
  3. For any new questions different from your original, please open another question

And when you do open another question, try to be more specific on the content of your request:

  • Familarize yourself with the SAP Documentation on Selection Screen Processing
  • The enter command is not 'registered' to a field that has a focus, it will trigger a whole lot of events for the entire session
  • What do you mean by "4 requests are executed"? Please show coding.
  • If performance of the 'requests' takes to much time, which of right now I doubt, you could store the last requested value in global variables and only perform a request again, if the value has changed

venkateswaran_k
Active Contributor
0 Kudos

Dear Zakaria

If you have four input fields as you said, then you need to add the IF condition as below:

AT SELECTION-SCREEN OUTPUT.
IF NOT input_field_1 is INITIAL.
   "write your select or display statement for input_field_1 here.
ENDIF.
IF NOT input_field_2 is INITIAL.
   "write your select or display statement for input_field_1 here.
ENDIF.
.......
.......

Regards,

Venkat

Patrick_vN
Active Contributor
0 Kudos

In the Process After Input of your screen, you can link a certain module to a field and add further syntax to limit it to data-changes or -inputs in said field.

Some sample code below, and I suggest you look up these statements:

FIELD [input-field] MODULE [corresponding-module].

If you want to trigger the same module for different fields, that can be done as well with the CHAIN-ENDCHAIN statements.

Now if I'm mistaken and you're working with a selection screen, then forget what I said and check Michael Piesche's posts.

Good luck

venkateswaran_k
Active Contributor
0 Kudos

Hi

Is your problem resolved?