Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

ABAP STATMENTS FOR DEFINING THE SELECTION SCREENS

1>parameters
2>select-options
3>selection-screen

the standard selection screen of the executable program is predefined and has
screen number 1000.

parameters are used for simple queries of single value only.

syntax for parameters

parameter <name>[length] type <type>| like <variable> [decimal <no>].

if the parameter refers to data types from the dictionary, it adopts all the
attributes of the dictionary field.
parameters can only refer to the fields of database tables views and structures.

F1 = field help
F4 = possible entries help

parameters p_bukrs type bukrs obligatory.


when obligatory is defined with the parameters for particular field , the user
cannot contine with the program without entering a value in this field on the
selection-screen.

parameter <name> type <data type> value check.


parameters p_bukrs like knb1-bukrs obligatory value check.

the user can only enter the company code that are in t001.
the possible entries help of the input field for p_bukrs display the allowed values.

paramater <name> as checkbox.

defining the radiobuttons.


parameter <name>(1) type c
parameter <name> radiobutton group <g1>.

parameter <name> is created with type C and length 1, and assigned to group
<g1>.
each radiobutton group has atleast 2 radionuttons and by default the first radio
button from the group is selected.

the value of the selected checkbox or radiobutton is 'X' and to deselect is


'SPACE'.

select-options:
range of input

4 components of select-options
low =lower value
high = higher value
sign = I -> inclusive and E ->exclusive
option = these are possible operations
-if high is empty you can use EQ,NE,GT,LE,LT,CP,NP
-if high is filled you can use BT(between) NB(not between)

syntaxselect-options <name> for <variable>.

providing default values.

data : v_bukrs type bukrs.

select-options : s_bukrs for v_bukrs default '1000' to '5000'


option BT sign I.

restricting entry to one row


select-options : s_kunnr for v_kunnr NO-EXTENSION.

resticting entry to single field


select-options : s_kunnr for v_kunnr NO INTERVALS.

EX:

data : v_bukrs type bukrs,


v_kunnr type kunnr,
v_lifnr type lifnr.

select-options B_bukrs for v_bukrs


default '1000' to '5000'
option BT sign I.
select-options s_kunnr for v_kunnr NO-EXTENSION
select-options s_lifnr for V_lifnr NO INTERVALs

formating the selection screen

the selection screens that you define when you use the PARAMETERS or SELECTOPTIONS statments on their own has a standard layout in which all parameters
apper line by line.
this type of layout may not be always sufficent.

SELECTION-SCREEN statment has its own formating option that you can use to
define the layout of the parameter and selection criteria and display comments
and underline on the screen .

selection-screen skip [<1>].


value can range from 1 to 9.

to place an underline on the selection screen

selection-screen uline [[/]<pos(length)>].

comments:
selection-screen comment [[/]<pos(length)> <comment here> {for field <f1>}].

the statment writes the comment on the selection screen.


{for field <f1>} to assign a field label to the comment .
<f> can be the name of the parameter or select-option.

BLOCKS of ELEMENTS.
SELECTION-SCREEN BEGIN OF BLOCK <BLOCK> [WITH FRAME [] TITLE
<title>].
-----

selection-screen end of block <block>.

TRY TO EXECUTE THE PROGRAM BELOW AND UNDERSTAND.


----------------------------------------

REPORT ZDEMO1.

TYPES : BEGIN OF ty_mara ,


matnr type matnr,
mtart TYPE mtart,
END OF ty_mara.

DATA : wa_mara TYPE ty_mara,


it_mara TYPE TABLE OF ty_mara.

data : v_matnr TYPE matnr ,


v_mtart TYPE mtart.

SELECTION-SCREEN BEGIN OF BLOCK b1 with FRAME TITLE text-001.

SELECT-OPTIONS : s_matnr for v_matnr . " MATERIAL NUMBER

SELECTION-SCREEN END OF BLOCK b1.

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

PARAMETER : rb_raw RADIOBUTTON GROUP g1, " RAW


rb_sfin RADIOBUTTON GROUP g1, " SEMI FINISHED
rb_fin RADIOBUTTON GROUP g1, " FINISHED
rb_samp RADIOBUTTON GROUP g1. " SAMPLE

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.

PARAMETER : cb_disp as CHECKBOX ,


cb_file as CHECKBOX .

SELECTION-SCREEN END OF BLOCK b3.

if rb_raw = 'X'.
v_mtart = 'ROH'.

ELSEIF rb_sfin = 'X'.


v_mtart = 'FERT'.

ELSEIF rb_fin = 'X'.


v_mtart = 'FERT'.

ELSEIF rb_samp = 'X'.


v_mtart = 'AEM'.

ENDIF.

SELECT matnr mtart INTO TABLE it_mara


FROM mara
WHERE matnr IN s_matnr.

if cb_disp = 'X'.
WRITE : / 'material no', 20 'material type'.
ULINE.

loop at it_mara INTO wa_mara.


WRITE : / wa_mara-matnr , 20 wa_mara-mtart .
ENDLOOP.

ELSEIF cb_file = 'X'.

CALL FUNCTION 'GUI_DOWNLOAD'


EXPORTING
*

BIN_FILESIZE
filename

=
= 'D:\material.txt'

FILETYPE

= 'ASC'

APPEND

=''

WRITE_FIELD_SEPARATOR

= 'X'

HEADER

= '00'

TRUNC_TRAILING_BLANKS

WRITE_LF

= 'X'

=''

COL_SELECT

COL_SELECT_MASK

DAT_MODE

CONFIRM_OVERWRITE

NO_AUTH_CHECK

CODEPAGE

IGNORE_CERR

= ABAP_TRUE

REPLACEMENT

= '#'

WRITE_BOM

TRUNC_TRAILING_BLANKS_EOL

WK1_N_FORMAT

WK1_N_SIZE

WK1_T_FORMAT

WK1_T_SIZE

*
*

=''
=''
=''
=''
=''
=''

=''
= 'X'

=''
=''
=''
=''

IMPORTING
FILELENGTH

tables
data_tab

*
*

= it_mara

FIELDNAMES

EXCEPTIONS

FILE_WRITE_ERROR

=1

NO_BATCH

GUI_REFUSE_FILETRANSFER

INVALID_TYPE

NO_AUTHORITY

UNKNOWN_ERROR

HEADER_NOT_ALLOWED

=2
=3

=4
=5
=6
=7

SEPARATOR_NOT_ALLOWED

=8

FILESIZE_NOT_ALLOWED

HEADER_TOO_LONG

DP_ERROR_CREATE

DP_ERROR_SEND

= 12

DP_ERROR_WRITE

= 13

UNKNOWN_DP_ERROR

ACCESS_DENIED

DP_OUT_OF_MEMORY

DISK_FULL

DP_TIMEOUT

FILE_NOT_FOUND

DATAPROVIDER_EXCEPTION

= 20

CONTROL_FLUSH_ERROR

= 21

OTHERS

=9
= 10
= 11

= 14
= 15
= 16
= 17
= 18
= 19

= 22

.
IF sy-subrc = 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*

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


MESSAGE 'download successfull' TYPE 'I'.
ENDIF.

ENDIF.

You might also like