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-screen Events!

Former Member
0 Kudos

Hi!

Pls tell me the order of selection screen events in sequence

&&&

Pls give some sample program for validation of selection screen i/p without using search helps.

Thanks

1 ACCEPTED SOLUTION

varma_narayana
Active Contributor
0 Kudos

Hi

these are the events for Selection Screen in the sequence.

INITIALIZATION.

<For provding default values for fields>

AT SELECTION-SCREEN OUTPUT.

<MODIFYING THE SCREEN FIELD PROPERTIES>

AT SELECTION-SCREEN on VALUE-REQUEST FOR <FIELD>.

<TO GENERATE F4 HELP >

AT SELECTION-SCREEN on HELP-REQUEST FOR <FIELD>.

<TO GENERATE F1 HELP >

AT SELECTION-SCREEN.

or

AT SELECTION-SCREEN ON <FIELD>

<FOR VALIDATIONS>..

Regards..

14 REPLIES 14

Former Member
0 Kudos

hi..

Events are certain code that occurs at certain times in the program. This will define how your program should run.

Certain events such as AT command, for example AT SELECTION-SCREEN and AT LINE-SELECTION, etc., are used for interactive reporting.

Other events such as INITIALIZATION, START-OF-SELECTION, etc., define at what times the data selection occurs or what default values appear on the selection screen before the program is run.

NTIALIZATION.

START-OF –SELECTION.

END-OF-SELECTION.

AT USER-COMMAND.

AT LINE-SELECTION

AT PFFUNCTION KEY NUMBER

AT SELECTION-SCREEN

AT NEW FIELD

AT END OF FIELD

AT FIRST

AT LAST

AT FIELD GROUP

TOP OF PAGE

END OF PAGE

see this link

Not all 11 events are related to selection screen.

http://www.sap-img.com/abap/events-related-to-reporting.htm

Events will tell the application server when to process certain parts of code.

alex_m
Active Contributor

Former Member
0 Kudos

Hi,

<b>Events in Selection-Screen:</b>

INTIALIZATION.

START-OF –SELECTION.

END-OF-SELECTION.

AT USER-COMMAND.

AT LINE-SELECTION

AT PFFUNCTION KEY NUMBER

AT SELECTION-SCREEN

AT NEW FIELD

AT END OF FIELD

AT FIRST

AT LAST

AT FIELD GROUP

TOP OF PAGE

END OF PAGE

<b>Order Of Events:</b>

Initialization : triggered when the report is loaded in memory.

At selection-screen output : triggered when the selection screen is loaded in memory before being displayed.

At selection-screen : before leaving the selection screen.

start-of-selection : the first event for displaying the report.

This event keyword defines an event block whose event is triggered by the ABAP runtime environment

when calling the executable program selection screen processing of a selection screen.

In an executable program, all statements that are not declarations, and are listed before the first explicit processing block, are assigned to this event block.

If the program does not contain an explicitly defined event block START-OF-SELECTION,these statements form the complete event block START-OF-SELECTION.

If a program contains an explicitly defined event block START-OF-SELECTION,

these statements are added to the beginning of the event block.

If the program contains no explicitly defined event blocks,

these statements form the entire event block START-OF-SELECTION.

end-of-selection : after the start-of-selection is completed.

classiscal report events.

top-of-page : every time a new page is started in the list.

end-of-page : every time the list data reaches the footer region of the page.

interactive report events.

top of page during line selection : top of page event for secondary list.

at line-selection : evey time user dbl-clicks(F2) on the list data.

at pF<key> : function key from F5 to F12 to perform interactive action on the list.

at user-command

http://help.sap.com/saphelp_47x200/helpdata/en/56/1eb6c705ad11d2952f0000e8353423/content.htm

Regards,

Padmam.

0 Kudos

Hi,

The evetns are in this sequence

INITIALIZATION

AT SELECTION-SCREEN OUTPUT

AT SELECTION-SCREEN

AT USER-COMMAND

START-OF-SELECTION

END OF SELECTION

AT LINE SELECTION.

Sample code for field validation.

AT SELECTION-SCREEN on obj.

if obj is initial.

message 'please enter value' type 'E'.

endif.

Regards,

Sesh

/

0 Kudos

Hi!

I want sequence of at selection screen events

like pls arrange proper oder if i am wrong

<b>at selction screen o/p

at selection screen on field request

at selection screen on value request

at selection screen

what the use of these if i am all these events

at selection screen on field</b>

and so on.. if any pls mention..

Looking for your reply.

Thanks

Rahul.

Former Member
0 Kudos

Hi

selection-screen: begin of block b with frame.

selection-screen : begin of block b1 with frame title text-001.

select-options:s_bukrs for t001-bukrs no intervals no-extension

obligatory,

s_vkorg for tvko-vkorg no intervals no-extension,

s_vtweg for tvtw-vtweg no intervals no-extension,

s_spart for tspa-spart no intervals no-extension,

s_werks for t001w-werks no intervals no-extension,

s_kunag for kna1-kunnr,

s_vbeln for vbuk-vbeln,

s_fkart for tvfk-fkart,

s_fkdat for vbrk-fkdat obligatory.

selection-screen begin of line.

selection-screen comment 1(20) text-008.

selection-screen end of line.

selection-screen begin of line.

parameters p_cust type c radiobutton group cust.

selection-screen comment 3(20) text-004 for field p_cust.

selection-screen end of line.

selection-screen begin of line.

parameters p_mode type c radiobutton group cust.

selection-screen comment 3(20) text-006 for field p_mode.

selection-screen end of line.

selection-screen begin of line.

parameters p_dens type c radiobutton group cust.

selection-screen comment 3(20) text-007 for field p_dens.

selection-screen end of line.

selection-screen: end of block b1.

selection-screen : begin of block b2 with frame title text-002.

parameters: p_dwnlod as checkbox,

p_file like rlgrap-filename. " default 'C:\zesdr001'.

selection-screen: end of block b2.

selection-screen: end of block b.

*******At Selection Screen********************************************

<b>at selection-screen.

  • At Selection Screen on Value Request

at selection-screen on value-request for p_file.

perform f4_help.

  • Checking for the input values of selection screen.

perform screen_check.</b>

&----


*& Form screen_check

&----


  • Ckecking for Selection Screen fields Validation

----


form screen_check.

  • Validation of Sales Organization

clear tvko.

if not s_vkorg-low is initial.

select vkorg from tvko up to 1 rows

into tvko-vkorg

where vkorg in s_vkorg.

endselect.

if sy-subrc ne 0.

message e009. " Invalid Sales Organization

endif.

endif.

  • Validation of Distribution Channel

clear tvtw.

if not s_vtweg-low is initial.

select vtweg from tvtw up to 1 rows

into tvtw-vtweg

where vtweg in s_vtweg.

endselect.

if sy-subrc ne 0.

message e010. " Invalid Distribution Channel

endif.

endif.

  • Validation of Division

clear tspa.

if not s_spart-low is initial.

select spart from tspa up to 1 rows

into tspa-spart

where spart in s_spart.

endselect.

if sy-subrc ne 0.

message e011. " Invalid Division

endif.

endif.

  • Validation for company code

clear t001.

if not s_bukrs-low is initial.

select single bukrs from t001

into t001-bukrs

where bukrs in s_bukrs.

if sy-subrc <> 0.

message e007. " Enter valid Company Code

endif.

endif.

  • Validation of billing Document Type

clear tvfk.

if not s_fkart is initial.

select fkart from tvfk up to 1 rows

into tvfk-fkart

where fkart in s_fkart.

endselect.

if sy-subrc ne 0.

message e012. " Invalid Billing Document Type

endif.

endif.

  • Validation of Billing Document Number

clear vbuk.

if not s_vbeln is initial.

select vbeln from vbuk up to 1 rows

into vbuk-vbeln

where vbeln in s_vbeln and

vbtyp = 'M'.

endselect.

if sy-subrc ne 0.

message e013. " Invalid Billing Doc Number

endif.

endif.

  • Validation of Customer

clear kna1.

if not s_kunag is initial.

select kunnr from kna1 up to 1 rows

into kna1-kunnr

where kunnr in s_kunag.

endselect.

if sy-subrc ne 0.

message e014. " Invalid Customer Number

endif.

endif.

  • Validation of Plant

clear t001w.

if not s_werks is initial.

select werks from t001w up to 1 rows

into t001w-werks

where werks in s_werks.

endselect.

if sy-subrc ne 0.

message e004. " Invalid Plant Number

endif.

endif.

  • Validation for File path to download

if p_dwnlod = 'X'.

if p_file is initial.

message e006. " Enter the Valid file path to Download

endif.

endif.

endform. "screen_check

&----


*& Form f4_help

&----


  • To Get F4 Help to Select File Name

----


form f4_help.

call function 'F4_FILENAME'

exporting

program_name = sy-cprog

dynpro_number = syst-dynnr

field_name = 'P_FILE'

importing

file_name = p_file.

endform. " f4_help

Reward points for useful Answers

Regards

Anji

varma_narayana
Active Contributor
0 Kudos

Hi

these are the events for Selection Screen in the sequence.

INITIALIZATION.

<For provding default values for fields>

AT SELECTION-SCREEN OUTPUT.

<MODIFYING THE SCREEN FIELD PROPERTIES>

AT SELECTION-SCREEN on VALUE-REQUEST FOR <FIELD>.

<TO GENERATE F4 HELP >

AT SELECTION-SCREEN on HELP-REQUEST FOR <FIELD>.

<TO GENERATE F1 HELP >

AT SELECTION-SCREEN.

or

AT SELECTION-SCREEN ON <FIELD>

<FOR VALIDATIONS>..

Regards..

Former Member
0 Kudos

Hi Rahul

Basic form

AT SELECTION-SCREEN.

Additions

1. ... ON psel

2. ... ON END OF sel

3. ... ON VALUE-REQUEST FOR psel_low_high .

4. ... ON HELP-REQUEST FOR psel_low_high

5. ... ON RADIOBUTTON GROUP radi

6. ... ON BLOCK block

7. ... OUTPUT

Effect

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.

Addition 2

... ON END OF sel

Effect

For each selection criterion sel on the selection screen, you can call a further screen by pressing a pushbutton. On this screen, you can enter any number of single values and ranges for the selection criterion sel .

When this screen has been processed (i.e. at the end of PAI for this screen), the event AT SELECTION-SCREEN ON END OF sel is executed.

At this point, all the values entered are available in the internal table sel .

Addition 3

... ON VALUE-REQUEST FOR psel_low_high

Effect

With this addition, the field psel_low_high is either the name of a report parameter or of the form sel-LOW or sel-HIGH , where sel is the name of a selection criterion. The effect of this is twofold:

The pushbutton for F4 (Possible entries) appears beside the appropriate field.

When the user selects this pushbutton or presses F4 for the field, the event is executed. You can thus implement a self-programmed possible entries routine for the input/output fields of the selection screen. If the program contains such an event and the user presses F4 , the system processes this rather than displaying the check table or the fixed values of the Dictionary field - even if the report parameter or the selection option with LIKE or FOR points to a Dictionary field. You can, for example, use the CALL SCREEN statement to display a selection list of possible values. The contents of the field psel_low_high at the end of this processing block are copied to the appropriate input/output field.

This addition is only allowed with report-specific parameters (PARAMETERS ) or selection options (SELECT-OPTIONS ). For database-specific parameters or selection options, you can achieve the same effect by using the addition VALUE-REQUEST FOR ... with the key word PARAMETERS or SELECT-OPTIONS in the include DBxyzSEL (where xyz = name of logical database). In this case, you must program the value help in the database program SAPDBxyz .

Addition 4

... ON HELP-REQUEST FOR psel_low_high

Effect

As with the addition ON VALUE-REQUEST the field psel_low_high is either the name of a report parameter or of the form sel-LOW or sel-HIGH , where sel is the name of a selection criterion. When the user presses F1 on the relevant field, the subsequent processing block is executed. You can thus implement a self-programmed help for the input/output fields of the selection screen. If the program contains such an event and the user presses F1 , the system processes this rather than displaying the documentation of the Dictionary field - even if the report parameter or the selection option with LIKE or FOR points to a Dictionary field.

This addition is only allowed with report-specific parameters (PARAMETERS ) or selection options (SELECT-OPTIONS ). For database-specific parameters or selection options, you can achieve the same effect by using the addition HELP-REQUEST FOR ... with the key word PARAMETERS or SELECT-OPTIONS in the include DBxyzSEL (where xyz = name of logical database). In this case, you must program the help in the database program SAPDBxyz .

Addition 5

... ON RADIOBUTTON GROUP radi

<u><b>Effect</b></u>

This event is assigned to the radio button groups on the selection screen defined by PARAMETERS par RADIOBUTTON GROUP radi .

If the report starts an error dialog at this point, precisely these fields of the radio button group radi become ready for input again.

<b>

Addition 6</b>

... ON BLOCK block

Effect

<b><i>This event is assigned to the blocks on the selection screen defined by SELECTION-SCREEN BEGIN/END OF BLOCK block .

If the report starts an error dialog at this point, precisely these fields of the block block become ready for input again.</i></b>

<u><b>Note</b></u>

In which sequence are the events AT SELECTION-SCREEN ON psel ... , AT SELECTION-SCREEN ON RADIOBUTTON GROUP ... , AT SELECTION-SCREEN ON BLOCK ... , AT SELECTION-SCREEN processed?

<i>The AT SELECTION-SCREEN ON psel ... events assigned to the parameters or selection options are executed in the sequence they are declared in the program, i.e. in the sequence they appear on the selection screen.

The events assigned to the radio button groups are executed according to the first parameter of the radio button group.

The events assigned to the blocks are executed "from the inside to the outside".</i>

<b>Example</b>


SELECT-OPTIONS SEL0 FOR SY-TVAR0.

SELECTION-SCREEN BEGIN OF BLOCK BL0.

SELECT-OPTIONS SEL1 FOR SY-TVAR1.

SELECTION-SCREEN BEGIN OF BLOCK BL1.

PARAMETERS P0 RADIOBUTTON GROUP RADI.

PARAMETERS P1 RADIOBUTTON GROUP RADI.

SELECTION-SCREEN BEGIN OF BLOCK BL2.

PARAMETERS P3.

SELECTION-SCREEN END   OF BLOCK BL2.

SELECT-OPTIONS SEL2 FOR SY-TVAR2.

SELECTION-SCREEN END   OF BLOCK BL1.

SELECTION-SCREEN END   OF BLOCK BL0.

<b>Sequence:</b>


AT SELECTION-SCREEN ON... 
SEL0 
SEL1 
RADIOBUTTON GROUP RADI 
P3 
BLOCK BL2 
SEL2 
BLOCK BL1 
BLOCK BL0

AT SELECTION-SCREEN is executed at the very end.

<b>Addition 7</b>

... OUTPUT

<u>Effect</u>

<b>This event is executed at PBO of the selection screen every time the user presses ENTER - in contrast to INITIALIZATION . Therefore, this event is not suitable for setting selection screen default values. Also, since AT SELECTION-SCREEN OUTPUT is first executed after the variant is imported (if a variant is used) and after adopting any values specified under SUBMIT in the WITH clause, changing the report parameters or the selection options in AT SELECTION-SCREEN OUTPUT would destroy the specified values.

Here, however, you can use LOOP AT SCREEN or MODIFY SCREEN to change the input/output attributes of selection screen fields.</b>

<u><b>Example</b></u>

<b>Output all fields of the

SELECT-OPTION NAME

highlighted:</b>


SELECT-OPTIONS NAME FOR SY-REPID MODIF ID XYZ.

 ....

 AT SELECTION-SCREEN OUTPUT.

 LOOP AT SCREEN.

     CHECK SCREEN-GROUP1 = 'XYZ'.

     SCREEN-INTENSIFIED = '1'.

     MODIFY SCREEN.

  ENDLOOP.

<i><b>The addition MODIF ID XYZ to the key word SELECT-OPTIONS assigns all fields of the selection option NAME to a group you can read in the field SCREEN-GROUP1 . At PBO of the selection screen, all these fields are then set to highlighted.

</b></i>

check these links

http://help.sap.com/saphelp_nw2004s/helpdata/en/56/1eb6c705ad11d2952f0000e8353423/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/10/e7dbde82ba11d295a40000e8353423/content.htm

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

can i use both

at selection screen

& at selection screen on field

whats their individual purpose on same program.

Thanks

0 Kudos

Hi Rahul

Validation on Selection-screen fields ,if user enter some wrong value ,then we have show message ..

you can write simple code

tables mara.

parameters p_matnr like mara-matnr.

at selection-screen on p_matnr.

select single matnr from mara into mara-matnr

where matnr = p_matnr.

if sy-subrc ne 0.

*message

endif.

check this link

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba66935c111d1829f0000e829fbfe/content.htm

Reward all helpfull answers

Regards

Pavan

0 Kudos

Hi Pavan!

Can i use both

at selection screen

&

at selection screen on field

in same program if so whats the requirement for fulling these two on the same program

Hope u understood my issue

0 Kudos

Hi,

yes you can use both. see the following example.

SELECTION-SCREEN : BEGIN OF BLOCK bl4 WITH FRAME TITLE text-001.

PARAMETERS : rb_today RADIOBUTTON GROUP date USER-COMMAND ucomm,

rb_cntm RADIOBUTTON GROUP date ,

rb_cntyr RADIOBUTTON GROUP date,

rb_all RADIOBUTTON GROUP date,

rb_past RADIOBUTTON GROUP date,

rb_fut RADIOBUTTON GROUP date,

rb_kdat RADIOBUTTON GROUP date DEFAULT 'X'.

SELECT-OPTIONS: s_d_ran FOR hrp1001-begda.

*parameters: s_d_ran type hrp1001-endda.

SELECTION-SCREEN : END OF BLOCK bl4.

SELECTION-SCREEN : BEGIN OF BLOCK bl2 WITH FRAME TITLE text-002.

SELECT-OPTIONS: s_org_id FOR hrp1001-sobid NO INTERVALS,

s_ps_sat FOR hrp1007-status NO INTERVALS,

s_per_ar FOR hrp1008-persa NO INTERVALS,

s_pos_no FOR hrp1000-objid NO INTERVALS.

SELECTION-SCREEN : END OF BLOCK bl2.

  • DATA : flag TYPE c VALUE '0'.

*selection-screen output

AT SELECTION-SCREEN OUTPUT.

*disable the date range selection screen option

IF rb_today EQ 'X' OR

rb_cntm EQ 'X' OR

rb_cntyr EQ 'X' OR

rb_past EQ 'X' OR

rb_all EQ 'X' OR

rb_fut EQ 'X'.

LOOP AT SCREEN.

IF screen-name EQ 'S_D_RAN-LOW' .

  • AND if SCREEN-NAME eq 'S_D_RAN-HIGH'.

screen-input = '0'.

MODIFY SCREEN.

EXIT.

ENDIF.

ENDLOOP.

LOOP AT SCREEN.

IF screen-name EQ 'S_D_RAN-HIGH'.

screen-input = '0'.

screen-required = '0'.

MODIFY SCREEN.

CLEAR screen.

EXIT.

ENDIF.

ENDLOOP.

  • ELSE.

  • IF rb_kdat EQ 'X' AND flag EQ '1'.

  • flag = '0'.

  • LOOP AT SCREEN.

  • IF screen-name EQ 'S_D_RAN-LOW' .

  • screen-input = '1'.

  • screen-required = '1'.

  • MODIFY SCREEN.

  • CLEAR screen.

*

*

  • EXIT.

*

  • ENDIF.

  • ENDLOOP.

  • ENDIF.

ENDIF.

*/at selection screen for validation and setting date for s_d_ran option

AT SELECTION-SCREEN.

*making date range as mand.,

IF rb_kdat = 'X'.

IF s_d_ran-low IS INITIAL.

MESSAGE text-010 TYPE 'S'.

STOP.

ENDIF.

ENDIF.

*intinalization of date parmeter

PERFORM setting_date.

        • // providing F4 help to org id.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_org_id-low.

PERFORM f_help.

FORM f_help .

DATA : lv_org_id TYPE hrobjid.

CALL FUNCTION 'RHP0_POPUP_F4_SEARK'

EXPORTING

f4 = 'X'

plvar = '01'

otype = 'O'

begda = '19000101'

endda = '99991231'

multi_select = 'X'

easy = 'X'

CHANGING

objid = lv_org_id

EXCEPTIONS

cancelled = 1

object_not_valid = 2

error = 3

OTHERS = 4.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

s_org_id-low = lv_org_id.

ENDFORM. " f_help

regards,

Ruchika

0 Kudos

Hi,

U can use both in the same program.

But,if u r using AT SELECTION-SCREEN ,then AT SELECTION-SCREEN <fld name> has less effect.

Consider, u r having multiple input fields.If u r writing codings in AT SELECTION-SCREEN means while pressing Enter at the first Input field it will take u to the next screen.U can't able to give values for the other Input Fields.

Consider u r writing codings in AT SELECTION-SCREEN <fld name> means after pressing Enter in that Field , the control will goes to the next screen.

Regards,

Padmam.

0 Kudos

Hi Rahul

I think there i sno need to use both the statements at a time

<u><b>for your info i'm providing a general view on at selection screen and at selection screen on fiels</b></u>

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.

<b>In the PAI event of the selection screen, the event

AT SELECTION-SCREEN ON field

event is triggered. 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.</b>

<u><b>Example</b></u>

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

.

If the user enters “AA” in the first input field, but not NEW YORK for the departure city, an error message is displayed in the status line until the user enters the correct city.

and check this link

http://www.sapfans.com/sapfans/alex.htm

http://help.sap.com/saphelp_nw04/helpdata/en/56/1eb6c705ad11d2952f0000e8353423/content.htm

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

Reward all helpfull answers

Regards

Pavan