Application Development and Automation 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: 
Read only

At selection-screen event

Former Member
0 Likes
2,842

Please give an example of using At selection-screen event.

(diff options)

Please give an example of using At selection-screen event.

(diff options)

9 REPLIES 9
Read only

Former Member
0 Likes
1,534

AT SELECTION-SCREEN ON SO_BELNR.

IF SO_BELNR IS NOT INITIAL.

SELECT SINGLE * FROM BKPF WHERE BELNR IN SO_BELNR.

IF BKPF-BELNR IS INITIAL.

MESSAGE 'Please enter Correct Doc Number ' TYPE 'E'.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
1,534

Hi,

REPORT EVENT_DEMO.

SELECTION-SCREEN BEGIN OF BLOCK PART1 WITH FRAME.

PARAMETERS: NUMBER1 TYPE I,

NUMBER2 TYPE I,

NUMBER3 TYPE I.

SELECTION-SCREEN END OF BLOCK PART1.

SELECTION-SCREEN BEGIN OF BLOCK PART2 WITH FRAME.

PARAMETERS: NUMBER4 TYPE I,

NUMBER5 TYPE I,

NUMBER6 TYPE I.

SELECTION-SCREEN END OF BLOCK PART2.

AT SELECTION-SCREEN ON BLOCK PART1.

IF NUMBER3 LT NUMBER2 OR

NUMBER3 LT NUMBER1 OR

NUMBER2 LT NUMBER1.

MESSAGE E020(HB).

ENDIF.

AT SELECTION-SCREEN ON BLOCK PART2.

IF NUMBER6 LT NUMBER5 OR

NUMBER6 LT NUMBER4 OR

NUMBER5 LT NUMBER4.

MESSAGE E030(HB).

ENDIF.

Look at the link --> http://www.sapbrainsonline.com/ARTICLES/TECHNICAL/ABAP/AT%20SELECTION-SCREEN%20Command.html

Read only

Former Member
0 Likes
1,534

Hi

sample program for screen validation under AT SELECTION-SCREEN

REPORT ZNNR_REPORT NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 100 LINE-COUNT 65(4).

******DATA DECLARATIONS**********

DATA : BEGIN OF IT_PLANT OCCURS 0,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARC-WERKS,

PSTAT LIKE MARC-PSTAT,

EKGRP LIKE MARC-EKGRP,

END OF IT_PLANT.

DATA : BEGIN OF IT_PONO OCCURS 0,

EBELN LIKE EKKO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

END OF IT_PONO.

TABLES EKKO.

********END OF DATA DECLARATIONS*********

********SELECTION SCREEN DESIGN ***********

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.

SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R2 RADIOBUTTON GROUP G1.

SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK B2.

******END OF SELECTION SCREEN DESIGN****************

*********INITIALIZATION OF SELECTION SCREEN ELEMENTS.*****

INITIALIZATION.

P_WERKS = '1000'.

S_EBELN-LOW = '4500016926'.

S_EBELN-OPTION = 'EQ'.

S_EBELN-SIGN = 'I'.

APPEND S_EBELN.

CLEAR S_EBELN.

************END OF INITIALIZATION***********************

***********SCREEN MODIFICATIONS*******************

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

********END OF SCREEN MODIFICATIONS*****************

****************SCREEN VALIDATIONS ******************

at selection-screen.

*SELECT SINGLE **

FROM EKKO

INTO EKKO

WHERE EBELN IN S_EBELN.

IF SY-SUBRC <> 0.

SET CURSOR FIELD 'S_EBELN-LOW'.

MESSAGE E999 WITH TEXT-005.

ENDIF.

*********end of screen validation******************

Read only

Former Member
0 Likes
1,534

hi,

tables: ekko..

types: begin of ty_ekko,

ebeln type ebeln,

lifnr type elifn,

bedat type ebdat,

statu type estak,

waers type waers,

end of ty_ekko,

data: it_ekko type table of ty_ekko,

wa_ekko type ty_ekko.

********SELECTION SCREEN***********

selection-screen: begin of block b1.

select-options: s_docu for ekko-ebeln,

s_date for ekko-bedat,

s_cust for ekko-lifnr.

selection-screen: end of block b1.

*******AT SELECTION-SCREEN*************

at selection-screen.

if s_docu is initial and s_date is initial and s_cust is initial.

message w000(0) with ' RECORD NOT FOUND'.

endif.

select single * from ekko where ebeln in s_docu and bedat in s_date and lifnr in s_cust.

if sy-subrc <> 0.

message w000(0) with ' RECORD NOT FOUND'.

endif.

Read only

Former Member
0 Likes
1,534

hi,

these are different selection screen options

Different Types of Selection Screens

What is:

1. at selection-screen on field

2. at selection-screen output

3. at selection-screen block

4. at selection-screen on value-request

5. at selection-screen on help-request and their difference?

For knowing Selection-screens:

First you must have right understanding of Events.

- Events are introduced by Event Keyword. They end when again next processs begins.

Selection-screens are special screen defined in ABAP.

- This ABAP at run time only controls the flow logic of Selection-screens. The PBO and PAI triggers the num of. selection-screens.

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 OUTPUT is trigerred in PBO of selection-screen.

- This allows you to modify the Selection-screen, before it is displayed.

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.

At Selection-screen On Block is trigerred in PAI event.

- You define a block by enclosing the declarations of the elements in the block between the statements SELECTION-SCREEN BEGIN OF BLOCK block - END OF BLOCK block. You can use this event block to check the consistency of the input fields in the block.

At Selection-screen On value request.

- This event is trigerred for F4 help.

At Selection-screen On help request .

- This event is triggered when the user clicks F1 for help on fileds.

Regards,

kavitha

Read only

Former Member
0 Likes
1,534

Hi Khanna,

In report programs to create a screen you will selectionscreen

like

selection-screen:begin of block b.

parameters:name(10) type c.

selection-screen:end of block b.

then you will get a selection screen when you execute the program and after entering any value for parameter name you will get the report output.

let us take the following report.

selection-screen:begin of block b.

parameters:name(10) type c.

selection-screen:end of block b.

at selection-screen.

if name = 'SAI'.

*use capital letters only because screen returns the value in caps only like i entered 'sai' on the screen but i have to check for 'SAI'

message i000(0) with 'hi'.

else.

message i000(0) with 'you'.

endif.

end-of-selection.

write: / name.

in the above program you first craeted the selection screen.after that you used at selection-screen and after that end-of-selection.

at selection-screen use.

to perform any validations on the inputs that you had given on the selection-screen you will use at selection-screen.

here we created a parameter NAME on the selection-screen.to check the value means validate the input for this field you entered we use at selection-screen.

why i am using message means we r unable to print anything on the selection-screen so we have to display a message for validations.

now carefully observe the above programs.

i think now you'r doubt is clarified.

there are some extentions to at selection-screen.if you want clear explanation of those also post a question immediately.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 11, 2008 11:50 AM

Read only

Former Member
Read only

Former Member
0 Likes
1,534

This code may help you to understand.

TABLES: vbak.

-- STRUCTURE DECLARATIONS -


TYPES: BEGIN OF k_sal_ord,

vbeln TYPE vbak-vbeln,

erdat TYPE vbak-erdat,

auart TYPE vbak-auart,

vbeln1 TYPE vbap-vbeln,

posnr TYPE vbap-posnr,

matnr TYPE vbap-matnr,

kwmeng TYPE vbap-kwmeng,

netpr TYPE vbap-netpr,

END OF k_sal_ord.

-- INTERNAL TABLE DECLARATIONS -


DATA: i_sal_ord TYPE STANDARD TABLE OF k_sal_ord.

DATA: w_sal_ord TYPE k_sal_ord.

DATA: auart TYPE vbak-auart.

SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

SELECT-OPTIONS : s_erdat FOR vbak-erdat .

SELECT-OPTIONS : s_auart FOR vbak-auart.

SELECT-OPTIONS : s_vbeln FOR vbak-vbeln.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN END OF SCREEN 100.

AT SELECTION-SCREEN ON s_auart.

IF s_auart IS NOT INITIAL.

SELECT SINGLE auart FROM vbak INTO auart1

WHERE auart EQ s_auart-low.

IF sy-subrc NE 0 .

MESSAGE e000 WITH text-002.

ELSE.

CLEAR auart1.

SELECT SINGLE auart FROM vbak INTO auart1

WHERE auart EQ s_auart-high.

IF s_auart-high IS NOT INITIAL.

IF sy-subrc NE 0 .

MESSAGE e001 WITH text-003.

ENDIF.

ENDIF.

ENDIF.

ENDIF.