2020 Oct 12 1:34 PM
Hello experts,
In selection screen there is:
1. A parameter
2. A radio group with 2 buttons
The parameter can be updated by a user, and also by pressing the radio button.
The question is in which event the code of updating the parameter should be written.
As mentioned in another question (' At SELECTION-SCREEN on RADIOBUTTON GROUP event') https://answers.sap.com/questions/13156222/at-selection-screen-on-radiobutton-group-event.html
ABAP fields are overwritten by their corresponding screen fields. Except for special cases. (input is disabled OR when the field was initially blank, and no data is input in it by a user).
This leads to a conclusion that it is better to update ABAP fields (which influence screen fields) after all screen fields were copied to ABAP fields. (in order not to overwrite the update). As far as I know:
The question is where is it better to write the code which updates an ABAP field? In AT SELECTION-SCREEN or AT SELECTION-SCREEN OUTPUT?
In the following code- Is it better to put the code in line 15 or in line 18?
REPORT ztry8.
PARAMETER p_add_1 RADIOBUTTON GROUP grp1 USER-COMMAND grp1_pressed DEFAULT 'X'.
PARAMETER p_add_2 RADIOBUTTON GROUP grp1 .
PARAMETER p_txt TYPE i.
AT SELECTION-SCREEN OUTPUT.
PERFORM add. "line 15
AT SELECTION-SCREEN.
PERFORM add. "line 18
FORM add.
IF p_add_1 = abap_true.
p_txt = p_txt + 1 . "line
ELSE.
p_txt = p_txt + 2 .
ENDIF.
ENDFORM. "add
Thank you
2020 Oct 12 2:28 PM
Hi ,
It is better to put at EVENT -
ATSELECTION-SCREEN as this is used for validations and performing some actions as mentioned in subroutine ( FORM add ) [when user enters the values in the fields of the selection screen and clicks on execution button, this event gets triggered. This event is basically for checking the value entered by the user for the field of the selection screen i.e data validity checking]
whereas EVENT-
ATSELECTION-SCREENOUTPUT is used for doing screen level changes on certain actions like dynamic screen modifications - it executes just like PBO Event of Module Pool Programing.
Ans : ATSELECTION-SCREEN
Regards,
Pavan
Hello experts,
In selection screen there is:
1. A parameter
2. A radio group with 2 buttons
The parameter can be updated by a user, and also by pressing the radio button.
The question is in which event the code of updating the parameter should be written.
As mentioned in another question (' At SELECTION-SCREEN on RADIOBUTTON GROUP event') https://answers.sap.com/questions/13156222/at-selection-screen-on-radiobutton-group-event.html
ABAP fields are overwritten by their corresponding screen fields. Except for special cases. (input is disabled OR when the field was initially blank, and no data is input in it by a user).
This leads to a conclusion that it is better to update ABAP fields (which influence screen fields) after all screen fields were copied to ABAP fields. (in order not to overwrite the update). As far as I know:
The question is where is it better to write the code which updates an ABAP field? In AT SELECTION-SCREEN or AT SELECTION-SCREEN OUTPUT?
In the following code- Is it better to put the code in line 15 or in line 18?
REPORT ztry8.
PARAMETER p_add_1 RADIOBUTTON GROUP grp1 USER-COMMAND grp1_pressed DEFAULT 'X'.
PARAMETER p_add_2 RADIOBUTTON GROUP grp1 .
PARAMETER p_txt TYPE i.
AT SELECTION-SCREEN OUTPUT.
PERFORM add. "line 15
AT SELECTION-SCREEN.
PERFORM add. "line 18
FORM add.
IF p_add_1 = abap_true.
p_txt = p_txt + 1 . "line
ELSE.
p_txt = p_txt + 2 .
ENDIF.
ENDFORM. "add
Thank you
2020 Oct 12 1:42 PM
The event AT SELECTION-SCREEN itself is raised as the last event in selection screen processing if all the input values were passed to the program. All user input can be checked in this event block. Sending a warning or an error message in the event block makes all the screen fields ready for input once again.
OUTPUT
This event is raised by the dynpro event PBO of a selection screen. In the event block, the selection screen can be prepared using assignments to the data objects of parameters and selection criteria and using dynamic screen modifications.
2020 Oct 12 2:28 PM
Hi ,
It is better to put at EVENT -
ATSELECTION-SCREEN as this is used for validations and performing some actions as mentioned in subroutine ( FORM add ) [when user enters the values in the fields of the selection screen and clicks on execution button, this event gets triggered. This event is basically for checking the value entered by the user for the field of the selection screen i.e data validity checking]
whereas EVENT-
ATSELECTION-SCREENOUTPUT is used for doing screen level changes on certain actions like dynamic screen modifications - it executes just like PBO Event of Module Pool Programing.
Ans : ATSELECTION-SCREEN
Regards,
Pavan
2020 Oct 22 6:52 PM
2020 Oct 12 4:13 PM
For sure, choose one or the other, don't mix modification at both PBO and PAI, that would be a mess.
I guess it's better to do it in the PAI because, if there's no error, further processing like call screen, update database, etc., may need to have the updated value (that would happen too late if you update it in the PBO).
Note that if an error message is sent (in the PAI obviously) you don't go through the PBO.
2020 Oct 13 7:23 AM
sandra.rossi , Just to be sure I understood you.
You wrote: Note that if an error message is sent (in the PAI obviously) you don't go through the PBO.
Do you mean that if the message has the type 'E' (like line 20 in the following code), than the process is stopped and PBO is not raised. But if the message has the type 'I' (like line 21 in the following code),than PBO is raised?
REPORT ztry8.
PARAMETER p_add_1 RADIOBUTTON GROUP grp1 USER-COMMAND grp1_pressed DEFAULT 'X'.
PARAMETER p_add_2 RADIOBUTTON GROUP grp1 .
PARAMETER p_txt TYPE i.
AT SELECTION-SCREEN OUTPUT.
PERFORM add. "line 15
MESSAGE 'pbo 2' TYPE 'I'.
AT SELECTION-SCREEN.
PERFORM add. "line 18
* MESSAGE 'pai' TYPE 'E'. "LINE 20
MESSAGE 'pai' TYPE 'I'. "LINE 21
FORM add.
IF p_add_1 = abap_true.
p_txt = p_txt + 1 . "line
ELSE.
p_txt = p_txt + 2 .
ENDIF.
ENDFORM. "add
2020 Oct 13 8:20 AM
That should take you 2 seconds to test, no need to spend 2 minutes to write the question 😉
2020 Oct 13 8:50 AM
sandra.rossi I tested it before asking. And I noticed that the above is true. I just wanted to insure that this is what you meant
2020 Oct 22 6:57 PM