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: 

AT SELECTION

Former Member
0 Kudos

Hai,

What is the difference between AT SELECTION-SCREEN ON <FIELD> AND AT SELECTION-SCREEN.

I need explanation with real time example

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi uday,

At selection-screen on <field> is used to validate a perticular field only.

at selection-screen is used to validate the multiple fileds which are designed in selection scren.

Ex: for At selection screen.

SELECT SINGLE lifnr

FROM lfa1

INTO lv_lifnr

WHERE lifnr EQ p_lifnr.

IF sy-subrc NE 0 .

MESSAGE e899(fi) WITH text-006.

ELSE.

CLEAR: lv_lifnr.

ENDIF.

<b><i>reward points if useful</i></b>

Chandra

Message was edited by:

Chandrasekhar Velpula

7 REPLIES 7

Former Member
0 Kudos

Hi,

AT SELECTION-SCREEN ON <FIELD> works when u change only the <field>

AT SELECTION-SCREEN works when u change any parameter or select-options.

rgs

Former Member
0 Kudos

hi uday,

At selection-screen on <field> is used to validate a perticular field only.

at selection-screen is used to validate the multiple fileds which are designed in selection scren.

Ex: for At selection screen.

SELECT SINGLE lifnr

FROM lfa1

INTO lv_lifnr

WHERE lifnr EQ p_lifnr.

IF sy-subrc NE 0 .

MESSAGE e899(fi) WITH text-006.

ELSE.

CLEAR: lv_lifnr.

ENDIF.

<b><i>reward points if useful</i></b>

Chandra

Message was edited by:

Chandrasekhar Velpula

Former Member
0 Kudos

Hi

The basic form of the selection screen events is the AT SELECTION-SCREEN event. This event occurs after the runtime environment has passed all input data from the selection screen to the ABAP program. The other selection screen events allow programmers to modify the selection screen before it is sent and specifically check user input.

At Selection-screen On Field is triggered in PAI of selection-screens.

- The input fields can b checked,in the corresponding event block. If an error message occurs within this event block, the corresponding field is made ready for input again on the selection screen.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/at_selec.htm

<b>Reward if usefull</b>

Former Member
0 Kudos

Hi Udaya Kumar,

AT SELECTION-SCREEN : This is the place where we can execute some piece of code before the execution of actuall program. Example authorization-sceck, validation of selection-screen fields, etc.

AT SELECTION-SCREEN ON <FIELD>: we will use this, when we are checking the value present in the selct-option or parameter is valid or not. in that block, we can write code for validation. simply we can say it is for VALIDATION.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Former Member
0 Kudos

Hi

At Selection Screen is triggered for a particular field or the field specified in the

As Selection Screen <field >

Whereas At selection screen validated the whole selection screen ..

for eg after Executing ...

Hope this helps .

Praveen

Former Member
0 Kudos

AT SELECTION-SCREEN

This event only makes sense in reports, i.e. in programs set to type 1 in the attributes. Type 1 programs are started via a logical database and always have a selection screen where the user can specify the database selections.

The event is processed when the selection screen has been processed (at the end of PAI ).

If an error message ( MESSAGE Emnr ) is sent during the event, all fields on the selection screen become ready for input.

After further user input, AT SELECTION-SCREEN is executed again.

Note

You should only perform very expensive checks with AT SELECTION-SCREEN if the program is then started (not every time the user presses ENTER). Here, you can read the system field SSCRFIELDS-UCOMM (provided a statement TABLES SSCRFIELDS exists). If the field has one of the values 'ONLI' (= Execute) or 'PRIN' (= Execute and Print), the report is then started, i.e. the selection screen is closed and the processing continues with START-OF-SELECTION . Remember that the selection screen (and thus also AT SELECTION-SCREE N ) is also processed in variant maintenance and with SUBMIT VIA JOB . You can determine which of these applies by calling the function module RS_SUBMIT_INFO .

Addition 1

... ON psel

Effect

This event is assigned to the selection screen fields corresponding to the report parameter or selection criterion psel .

If the report starts an error dialog at this point, precisely these fields become ready for input.

*******************************************

AT SELECTION-SCREEN is the event triggered in the PAI of the selection screen.

AT SELECTION-SCREEN on field field_name is the event specific to the field and is triggered when u press enter in that field.

AT SELECTION-SCREEN is generic for all the screen elemenets present on the selection screen.

AT SELECTION-SCREEN ON FIELD is specific to that field for which it is defined.

I.e we can use this statement for validation of that particular field only.

**************************************

AT SELECTION-SCREEN is triggered at least twice during actions on selection screens that are linked into another selection screen as a subscreen - first for the linked selection screen itself, and then for the linking selection screens.

The event AT SELECTION-SCREEN is the basic form of a whole series of events that occur while the selection screen is being processed.

The standard selection screen in an executable program or in the logical database linked to it is automatically called between the INITIALIZATION and START-OF-SELECTION events. When you call the selection screen, and when users interact with it, the ABAP runtime environment generates selection screen events, which occur between INITIALIZATION and START-OF-SELECTION.

You can define event blocks for these events in your program to change the selection screen or process user input.

Processing Single Fields

AT SELECTION-SCREEN ON <field>

is triggered when the contents of each individual input field are passed from the selection screen to the ABAP program. The input field <field> can be checked in the corresponding event block. If an error message occurs within this event block, the corresponding field is made ready for input again on the selection screen.

The program below is connected to the logical database F1S:

REPORT EVENT_DEMO.

NODES SPFLI.

AT SELECTION-SCREEN ON CITY_FR.

IF CARRID-LOW EQ 'AA' AND CITY_FR NE 'NEW YORK'.

MESSAGE E010(HB).

ENDIF.

for more details check this link...

http://help.sap.com/saphelp_46c/helpdata/en/9f/db9a2e35c111d1829f0000e829fbfe/frameset.htm

***********************************

1. If the report starts an error dialog at this point, precisely these fields become ready for input.

2. For READY for INPUT purpose,

we use

at selection-screen on field A.

3. other wise,

both events get fired.

4. to get a taste of it,just copy paste in new program.

execute, and press ENTER button.

REPORT abc.

PARAMETERS : a TYPE c.

PARAMETERS : b TYPE c.

AT SELECTION-SCREEN.

*----


this will not work

*IF a <> 'X'.

  • MESSAGE e999(yhr) WITH 'my error'.

*ENDIF.

*

AT SELECTION-SCREEN ON a.

IF a <> 'X'.

MESSAGE e999(yhr) WITH 'my error'.

ENDIF.

AT SELECTION-SCREEN ON b.

IF b <> 'X'.

MESSAGE e999(yhr) WITH 'my error'.

ENDIF.

**********************************************

• AT SELECTION-SCREEN

When user enters the values in the fields of selection screen and clicks on execute button, this event gets triggered. This event is basically for checking the values entered by the user for the fields of the selection screen i.e., data validity checking. This event is for entire selection screen. For example:

You are accepting carrid, connid, fldate from user and you don’t want to proceed if user enters no value for carrid and fldate. Using AT SELECTION-SCREEN can do this.

Select-options: carrid1 for sflight-carrid,

Connid1 for sflight-connid,

F1date1 for sflight-f1date.

AT SELECTION-SCREEN.

If carrid1-low ne ‘ ’ and fldate1-low = ‘ ’.

Error message.

Endif.

In this case, if both the fields are entered blank, then the user gets error message.

Basically, this event is for many fields on selection screen. Usually, it is for the fields which are logically related.

• AT SELECTION-SCREEN ON <field>

When you want to check for specific value of a field. For example, carrid should be in the range of ‘LH’ and ‘SQ’. This can be done in this event. Basically, this event is for checking individual fields. You can have many AT selection-screen events in your program (i.e., for each field specified in the Select-Options).

Select-Options carrid1 for sflight-carrid.

AT SELECTION-SCREEN.

If carrid1-low ne ‘LH’ and carrid1-high ne ‘SQ’.

Error message.

Endif.

Here the system will not proceed on entering wrong values.

mahaboob_pathan
Contributor
0 Kudos

Hi,

In AT SELECTION-SCREEN.

validations of selection screen are done.

eg:

select single * from vbak where vbeln eq p_vbeln.

if sy-subrc<>0

message E000(message class name).

endif.

AT SELECTION-SCREEN ON <FIELD>

When you want to check for specific value of a field.

For ORT01 should be in the range of ‘DE'

This can be done in this event. Basically, this event is for checking individual fields. You can have many AT selection-screen events in your program (i.e., for each field specified in the Select-Options).

AT SELECTION-SCREEN ON p_ORT01.

If ORT01EQ 'DE.

MESSAGE E001 WITH 'SUCCESSFULL'.

ELSE.

Error message.

Endif.

Here the system will not proceed on entering wrong values