SELECTION-SCREEN ( SAP ABAP Keyword)


SELECTION-SCREEN is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details.

SELECTION-SCREEN

Variants

1. SELECTION-SCREEN BEGIN OF LINE.
2. SELECTION-SCREEN END OF LINE.
3. SELECTION-SCREEN SKIP n.
4. SELECTION-SCREEN ULINE.
5. SELECTION-SCREEN POSITION pos.
6. SELECTION-SCREEN COMMENT fmt name.
7. SELECTION-SCREEN PUSHBUTTON fmt name USER-COMMAND ucom.
8. SELECTION-SCREEN BEGIN OF BLOCK block.
9. SELECTION-SCREEN END OF BLOCK block.
10. SELECTION-SCREEN FUNCTION KEY n.
11. SELECTION-SCREEN BEGIN OF VERSION ver TEXT-xxx.
12. SELECTION-SCREEN END OF VERSION ver.
13. SELECTION-SCREEN EXCLUDE … .
14. SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE dbtab.
15. SELECTION-SCREEN FIELD SELECTION FOR TABLE dbtab.

Effect
The
key word SELECTION-SCREEN only makes sense in reports, i.e. programs
specified as type “1″ in the attributes. You use it to design the
selection screen in the program or logical database access routine.

The
selection screen is normally generated from the SELECT-OPTIONS and
PARAMETERS statements in the report and logical database access
routine. Each of these objects occupies a separate line on the
selection screen.

SELECTION-SCREEN allows you to form blocks,
combine several parameters and comments together on one line, generate
pushbuttons on the screen or activate them in the application toolbar,
as well as insert blank lines, underscore lines and comments.

Like
SELECT-OPTIONS and PARAMETERS , you can use SELECTION-SCREEN statements
in reports and in the include program DBldbSEL of the logical database
ldb assigned to the report in the attributes. Some variants are defined
only for logical databases and can therefore only be used in the
include program DBldbSEL .

Variant 1
SELECTION-SCREEN BEGIN OF LINE.
Variant 2
SELECTION-SCREEN END OF LINE.

Effect
Allows
you to combine several parameters and comments specified between the
SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE
statements and output them on one line. As a result, there is no
automatic new line for each PARAMETER and no selection texts are
displayed.

Example

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(10) TEXT-001.
PARAMETERS: P1(3), P2(5), P3(1).
SELECTION-SCREEN END OF LINE.

Selection screen:

Comment ___ _____ _

Note
You
cannot order SELECT-OPTIONS between SELECTION-SCREEN BEGIN OF LINE and
SELECTION-SCREEN END OF LINE because several objects are generated on
the selection screen for a SELECT-OPTION (e.g. fields for the lower and
upper limits of ranges).

Variant 3
SELECTION-SCREEN SKIP n.

Additions

1. … FOR TABLE dbtab
2. … ID id

Effect
Generates n blank lines (see also SKIP ).

You must specify a value for n between 1 and 9. If you want to output just one blank line, you can omit n .

Addition 1
… FOR TABLE dbtab

Effect
This
addition is allowed only in the database include program DBldbSEL . It
is, in fact, a requirement. If you use SELECTION-SCREEN SKIP in
DBldbSEL , you must assign the statement to a table (or to a field -
see the variant COMMENT .
This assignment is necessary in order to
restrict the SELECTION-SCREEN statements for a report selection screen
to those relevant for the tables used in the report, i.e. those which
refer to a table used in the report. Any SELECTION-SCREEN statement
assigned to a table not used in the report with the addition FOR TABLE
dbtab are ignored when the report selection screen is generated.

Note
A
table dbtab of the logical database ldb is considered as “used in the
report” if it is either declared in a TABLES statement or its position
in the database hierarchy lies somewhere between the root and a table
dbtab_2 declared in the report.

Example
Hierarchy of logical database ldb :

SPFLI
|
—- SAPLANE
|
—- SFLIGHT
|
—- SBOOK

In the report:

TABLES SFLIGHT.

Tables considered as “used” include SFLIGHT (since it is
declared directly), as well as SAPLANE and SPFLI (since
they lie on the path from the hierarchy root ” SPFLI ” to the
declared table SFLIGHT ). The table SBOOK is not
considered as used, i.e. all the SELECTION-SCREEN statements
qualified with the addition ” FOR TABLE SBOOK ” in DBldbSEL
are ignored.

Addition 2
… ID id

Effect
This
addition is allowed only in the database include program DBldbSEL . It
is used to identify a SELECTION-SCREEN object (in this case blank
lines) via an ID which can be up to 3 characters long. This ID is then
specified in SELECTION-SCREEN EXCLUDE IDS id in order to exclude the
object from a selection screen version.

Variant 4
SELECTION-SCREEN ULINE.

Additions

1. … fmt
2. … FOR TABLE dbtab
3. … MODIF ID mod
4. … ID id

Effect
Generates an underline (see also ULINE ).

Addition 1
… fmt

Effect
Format
specification with the form /pos(len) , pos(len) or (len) . The slash (
/ ) generates a new line and is therefore not allowed between BEGIN OF
LINE and END OF LINE . The effect of the statement is to underscore the
current line starting from the position pos for the length len . The
variant (len) (without position specification) is allowed only between
BEGIN OF LINE and END OF LINE . In this case, the current position in
the line is used. See also WRITE .
You can specify the position pos
as a number (in this case, it is relative to the frame if the statement
comes between SELECTION-SCREEN BEGIN OF BLOCK … WITH FRAME … and
SELECTION-SCREEN END OF BLOCK … ). Also allowed are the symbolic
positions POS_LOW and POS_HIGH . These are the positions at which the
input fields of the SELECT-OPTI ONS are output ( POS_LOW is also the
position of PARAMETERS .

Note
Format specifications which do
not generate a new line can produce overlapping objects on the
selection screen. Therefore, you should be particularly careful with
position and length specifications.

Example

SELECTION-SCREEN ULINE /1(10).
SELECTION-SCREEN ULINE POS_LOW(10).
SELECTION-SCREEN ULINE POS_HIGH(10).

This generates three underscore blocks, each with a length of 10, on one line.

Addition 2
… FOR TABLE dbtab

Effect
See variant 3 ( SELECTION-SCREEN SKIP ).

Addition 3
… MODIF ID mod

Effect
The
specified modification group ( SCREEN-GROUP1 ) is assigned to the
underscore. You can use this under AT SELECTION-SCREEN in the report or
in the PAI routine of the database program SAPDBldb to modify the
screen.

Note
The name of the modification group must be specified without quotation marks. It can be up to three characters long.

Addition 4
… ID id

Effect
See variant 3 ( SELECTION-SCREEN SKIP )

Variant 5
SELECTION-SCREEN POSITION pos.

Addition

… FOR TABLE dbtab

Effect
Outputs the parameter starting from the position pos .
This variant is allowed only between SELECTION-SCREEN BEGIN OF LINE< /> and SELECTION-SCREEN END OF LINE .
As
with the addition ULINE , you can specify the position as fixed (if
necessary relative to the frame) or symbolically in the form POS_LOW or
POS_HIGH .

Addition
… FOR TABLE dbtab

Effect
See variant 3 ( SELECTION-SCREEN SKIP )

Variant 6
SELECTION-SCREEN COMMENT fmt name.

Additions

1. … FOR TABLE dbtab
2. … FOR FIELD f
3. … MODIF ID mod
4. … ID id

Effect
Generates a comment on the selection screen. For the name name , there are two options:
name
takes the form TEXT-xxx where xxx is a three-character name for a text
symbol. In this case, the contents of the text symbol are displayed at
runtime, i.e. the text cannot be changed dynamically. name is another
eight-character name. Here, you create a field with the name name in
the length specified in the format fmt< /> and it is then
generated as an output field on the selection screen. The contents of
these comments must therefore be set at runtime (e.g. at INITIALIZATION
or – in the case of comments in the database include program DBldbSEL -
in the routine INIT of the database program SAPDBldb . They can also be
changed when the selection screen is being processed.

Note
The field name is generated automatically and so cannot be defined with DATA .
With comments, you must always specify a format fmt (see variant ULINE ).

Note
You must program a new line yourself via the format fmt .

Addition 1
… FOR TABLE dbtab

Note
See variation 3 (SELECTION-SCREEN SKIP).

Addition 2
… FOR FIELD f

Effect
Since
the comment is assigned to a parameteror a select-option , the help
display shows the documentation of the reference field if this
parameter or selection option.
In addition, the comment is suppressed if the reference object was set to ‘invisible’ via a selection variant.

Note
In
database access routines, the comment is generated whenever the
reference field is output. Therefore, you should not use the addition
FOR TABLE with this variant.

Example

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(20) TEXT-001
FOR FIELD PARM.
SELECTION-SCREEN POSITION POS_LOW.
PARAMETERS PARM LIKE SAPLANE-PLANETYPE.
SELECTION-SCREEN END OF LINE.

This
code displays a 20-byte long comment followed by the parameter at the
normal position ( POS_LOW ) on the same line. If the user presses F1
for both objects, the documentation of SAPLANE-PLANETYPE is displayed.

Addition 3
… MODIF ID mod

Effect
See variant 4 ( SELECTION-SCREEN ULINE )

Addition 4
… ID id

Effect
See variant 3 ( SELECTION-SCREEN SKIP )

Variant 7
SELECTION-SCREEN PUSHBUTTON fmt name USER-COMMAND ucom.

Additions

1. … FOR TABLE dbtab
2. … MODIF ID mod
3. … ID id

Effect
Generates
a pushbutton on the selection screen. Also specified is the user
command ucom (without quotation marks) which can be up to 4 characters
long. This is generated when the user presses the button. Apart from
this, the syntax is largely similar to that of SELECTION-SCREEN COMMENT
:

For the name name , there are two options:
name takes the
form TEXT-xxx where xxx is a three-character name for a text symbol. In
this case, the contents of the text symbol are displayed at runtime,
i.e. the text cannot be changed dynamically. name is another
eight-character name. Here, you create a field with the name name in
the length specified in the format fmt< /> and it is then
generated as an output field on the selection screen. The contents of
these comments must therefore be set at runtime (e.g. at INITIALIZATION
or – in the case of comments in the database include program DBldbSEL -
in the routine INIT of the database program SAPDBldb . They can also be
changed when the selection screen is being processed.

Note
The field name is generated automatically and so cannot be defined with DATA .
With pushbuttons, you must always specify a format fmt (see variant ULINE ).

Note
You must program a new line yourself via the format fmt .
The
best way to respond to the user pressing the pushbutton is in the event
AT SELECTION-SCREEN or – in the case of pushbuttons in the database
include program DBldbSEL – in the routine PAI (with FNAME = ‘*’ and
MARK = SPACE ) in the database program SAPDBldb . Here, the field
SSCRFIELDS-UCOMM contains the user command ucom (the table SSCRFIELDS
must be declared with the TABLES statement).

Addition 1
… FOR TABLE dbtab

Effect
See variant 3 ( SELECTION-SCREEN SKIP )

Addition 2
… MODIF ID mod

Effect
See variant 4 ( SELECTION-SCREEN ULINE )

Addition 3
… ID id

Effect
See variant 3 ( SELECTION-SCREEN SKIP )

Example

TABLES SSCRFIELDS.

SELECTION-SCREEN PUSHBUTTON /10(20) CHARLY USER-COMMAND ABCD.

INITIALIZATION.

MOVE ‘My text’ TO CHARLY.

AT SELECTION-SCREEN.

IF SSCRFIELDS-UCOMM = ‘ABCD’.

ENDIF.

The
selection screen displays a pushbutton with the text ‘My text’ . With
AT SELECTION-SCREEN , the field SSCRFIELDS-UCOMM contains ABCD after
the user has pressed the button.

Variant 8
SELECTION-SCREEN BEGIN OF BLOCK block.

Additions

1. … WITH FRAME
2. … TITLE title
3. … NO INTERVALS

Effect
Starts
a logical block on the selection screen. If you use the addition WITH
FRAME , a frame is generated around the block. The addition TITLE title
is allowed only in conjunction with WITH FRAME .

For the title title ,there are two options (see also the variants COMMENT and PUSHBUTTON ):
title
takes the form TEXT-xxx where xxx is a three-character name for a text
symbol. In this case, the contents of the text symbol are displayed at
runtime, i.e. the text cannot be changed dynamically. title is another
eight-character name. Here, you create a field with the name title in
the length specified in the format fmt< /> and it is then
generated as an output field on the selection screen. The contents of
these comments must therefore be set at runtime (e.g. at INITIALIZATION
or – in the case of comments in the database include program DBldbSEL -
in the routine INIT of the database program SAPDBldb . They can also be
changed when the selection screen is being processed.

Note
The field title is generated automatically and so cannot be defined with DATA .
At
runtime, the event AT SELECTION-SCREEN ON BLOCK block is executed for
every block in the PAI module of the selection screen (with database-
specific blocks, the PAI module in the program SAPDBldb is also
executed with the parameters FNAME = BLOCK_block and MARK = SPACE ). If
this produces an error message, just the fields of this block are ready
for input.
You can nest blocks. The maximum nesting depth for blocks with frames is 5.

Addition 3
… NO INTERVALS

Effect
Displays
all SELECT-OPTIONS within the block in simplified form without a ‘to’
field on the selection screen (like the addition ” NO INTERVALS ” with
SELECT-OPTIONS ). If the block has a frame, this is correspondingly
small.

Note
In the case of blocks without frames, the
attribute ” NO INTERVALS ” is not inherited by subordinate blocks.
However, all subordinate blocks of blocks with frames inherit this
attribute because the generated frame is smaller and there is no space
for the ‘to’ field.

Variant 9
SELECTION-SCREEN END OF BLOCK block.

Effect
Closes
the block opened by SELECTION-SCREEN BEGIN OF BLOCK block . If the
block has a frame, the frame is closed here. Blocks opened in the
include program DBldbSEL must also be closed there.

Note
Blocks
defined in the database include program DBldbSEL must also be close
there. As with SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END
OF LINE , you cannot use the addition FOR TABLE with blocks. Instead,
the objects in the blocks (selection options , parameters , comments,
underscores …) are omitted if the table to which they belong is not
used in the report (see note under variant SELECTION-SCREEN SKIP ).
Empty blocks (possibly with frames) are also omitted.

Example

TABLES SAPLANE.

SELECTION-SCREEN BEGIN OF BLOCK CHARLY
WITH FRAME TITLE TEXT-001.
PARAMETERS PARM(5).
SELECT-OPTIONS SEL FOR SAPLANE-PLANETYPE.
SELECTION-SCREEN END OF BLOCK CHARLY.

(Let TEXT-001 contain ‘Block Charly’ ).

Selection screen:

–Block Charly———————————–
| PARM _____ |
| SEL ________ bis ________ |
————————————————-

Variant 10
SELECTION-SCREEN FUNCTION KEY n.

Additions

1. … FOR TABLE dbtab
2. … ID id

Effect
With
this variant, you can activate up to 5 function keys in the application
toolbar on the selection screen ( n is one of the numbers 1 to 5).
At runtime, the text must be placed in the Dictionary field SSCRFIELDS-FUNCTXT_01 or … SSCRFIELDS-FUNCTXT_05 .
The
function code placed in the field SSCRFIELDS-UCOMM is ‘FC01′ or …
‘FC05′ . You can read this function code under AT SELECTION-SCREEN or
in the PAI module of the database access program SAPDBldb .

Addition 1
… FOR TABLE dbtab

Effect
See variant 3 ( SELECTION-SCREEN SKIP )

Addition 2
… ID id

Effect
See variant 3 ( SELECTION-SCREEN SKIP )

Example

TABLES SSCRFIELDS.

SELECTION-SCREEN FUNCTION KEY 1.

INITIALIZATION.

MOVE ‘My text’ TO SSCRFIELDS-FUNCTXT_01.

AT SELECTION-SCREEN.

IF SSCRFIELDS-UCOMM = ‘FC01′.

ENDIF.

The
selection screen displays a pushbutton with the text ‘My text’ . With
AT SELECTION-SCREEN , the field SSCRFIELDS-UCOMM contains FC01 after
the user has pressed the button.

Variant 11
SELECTION-SCREEN BEGIN OF VERSION ver TEXT-xxx.
Variant 12
SELECTION-SCREEN END OF VERSION ver.
Variant 13
SELECTION-SCREEN EXCLUDE … .

Effect
Defines
a selection screen version (with a three-character name ver ). These
variants are only allowed in the database include program DBldbSEL .
Between BEGIN OF VERSION and END OF VERSION , you can exclude selection
screen objects for the version ver , i.e. remove them from the
selection screen with SELECTION-SCREEN EXCLUDE. .

For a report,
you activate a selection screen by making an entry in the attributes.
If the database access program SAPDBldb itself has a selection screen
version in the attributen, this applies for all reports which use this
logical database and have attributes where no separate selection screen
version is declared.

The text symbol TEXT -xxx is used merely to
facilitate selection of a selection screen version via F4 help when
maintaining the attributes.

Additions
(to SELECTION-SCREEN EXCLUDE )

1. … PARAMETERS par
2. … SELECT-OPTIONS sel
3. … RADIOBUTTON GROUPS radi
4. … BLOCKS block
5. … IDS id

Effect
Excludes
selection screen objects between SELECTION-SCREEN BEGIN and END OF
VERSION . This allows you to exclude individual parameters or selection
options , radiobutton groups , blocks defined by SELECTION-SCREEN
BEGIN/END OF BLOCK and other objects such as comments and underscores
specified by the addition ID id .

Note
The database program SAPDBldb can get the active version for the current report with the function module RS_SELSCREEN_VERSION .

Example
PARAMETERS PAR_1 LIKE dbfield_1 FOR TABLE dbtab_1.
SELECT-OPTIONS SEL_1 FOR dbfield_01.
SELECT-OPTIONS SEL_2 FOR dbfield_02.
SELECT-OPTIONS SEL_3 FOR dbfield_03.

SELECTION-SCREEN COMMENT /10(20) TEXT-100 FOR TABLE dbtab_1 ID 001.
SELECTION-SCREEN COMMENT /8(30) TEXT-200 FOR TABLE dbtab_2 ID 002.

PARAMETERS PAR_2 LIKE dbfield_1 FOR TABLE dbtab_2.
PARAMETERS PAR_3 LIKE dbfield_1 FOR TABLE dbtab_2.

SELECTION-SCREEN BEGIN OF VERSION ABC TEXT-008.

SELECTION-SCREEN EXCLUDE PARAMETERS: PAR_1, PAR_3.
SELECTION-SCREEN EXCLUDE SELECT-OPTIONS: SEL_2.
SELECTION-SCREEN EXCLUDE IDS: 001.

SELECTION-SCREEN END OF VERSION ABC.
If
the report attributes (or the attributes of the database program
SAPDBldb ) contain the selection screen version ABC , the parameters
PAR_1 and PAR_3 , the selection option SEL_2 and the comment with the
text number 100 ( ID 001 ) are not displayed on the selection screen.
When you maintain the attributes, the text symbol 008 of SAPDBldb is
displayed if you press F4 on the field ‘Selection screen version’.

Variant 14
SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE dbtab.

Addition

… ID id

Effect
This
variant is allowed only in the database include program DBldbSEL . It
informs you for which logical database tables additional selections are
supported. If one of these tables is active in the report (i.e. it is
declared under TABLES or lies somewhere on the path from the root of
the database hierarchy to a table declared with TABLES ), a psuhbutton
called ‘Dynamic selections’ appears on the selection screen. On
pressing this button, the user branches to a dialog Taste where it is
possible to enter selections for the fields of the relevant tables in
the logical database. You can define the field list in two different
ways:
Via a selection view defined for the purpose:

You can
maintain selection views within the logical database maintenance
transaction. They consist of a set of fields from logical database
tables which are divided into groups. It is also possible to preselect
fields. Customers can overlay these selection views with their own
(i.e. in this case, the system searches first for the customer
selection view and only accesses the SAP selektion view if no
customer-specific view exists).
If a preselection has already been
made in the selection view, the user immediately sees the selection
screen for the preselected fields and can enter selections. Otherwise,
a fields must be selected first.
Via all fields of all tables

In
this case, the user must first choose the tables and then select the
fields for which additional selections are to be made before branching
to the selection screen to enter the dynamic selections.
The
database access programm SAPDBldb then receives the WHERE clauses
generated from the user entries in the form of a complex data object
DYN_SEL .

Addition
… ID id

Effect
Similar to the
addition 2 ( SKIP ). This allows you to exclude tables from the
possibility of dynamic selection via the selection screen versions.

Note
The exact definition of the object DYN_SEL is stored in the TYPE-POOL RSDS and is as follows:

TYPES: BEGIN OF RSDS_WHERE,
TABLENAME LIKE RSDSTABS-PRIM_TAB,
WHERE_TAB LIKE RSDSWHERE OCCURS 5,
END OF RSDS_WHERE.

TYPES: BEGIN OF RSDS_TYPE,
CLAUSES TYPE RSDS_WHERE OCCURS 5,
TEXPR TYPE RSDS_TEXPR,
TRANGE TYPE RSDS_TRANGE,
END OF RSDS_TYPE.

DATA DYN_SEL TYPE RSDS_TYPE.

The
object DYN_SEL thus contains a component ( CLAUSES ) which is an
internal table. Each line of this internal table contains a table name
( TABLENAME ) and another table ( WHERE_TAB ) which contains the WHERE
clauses for the table ( TABLENAME ).
You can find the structure of the other components in the type pool RSDS .
TEXPR
contains the selections in a format which allows storage and can be
used for the “freely callable” function modules when entering dynamic
selections ( FREE_SELECTIONS_INIT , FREE_SELECTIONS_DIALOG ). TRANGE
contains the selections in the form of RANGES tables which can be used
with the IN operator in SELECT , CHECK and IF .

Note
Neither
the TYPE-POOL RSDS nor the declaration of DYN_SEL must appear in the
database program. Both are automatically included by the system.
In the database program SAPDBldb , an access to a table XXXX could look something like below:

FORM PUT_XXXX.

DATA L_DS_CLAUSES TYPE RSDS_WHERE.

MOVE ‘XXXX’ TO L_DS_CLAUSES-TABLENAME.
READ TABLE DYN_SEL-CLAUSES WITH KEY L_DS_CLAUSES-TABLENAME
INTO L_DS_CLAUSES.

SELECT * FROM XXXX
WHERE field1 IN …
AND field2 ….

AND (L_DS_CLAUSES-WHERE_TAB).
PUT XXXX.
ENDSELECT.
ENDFORM.

Note
If
the table L_DS_CLAUSES-WHERE_TAB is empty, i.e. if no dynamic
selections are entered for the table XXXX , the addition … AND
(L_DS_CLAUSES-WHERE_TAB) is ignored during the SELECT .

Variant 15
SELECTION-SCREEN FIELD SELECTION FOR TABLE dbtab.

Addition

… ID id

Effect
This
variant is allowed only in the database include program DBldbSEL . It
informs you for which logical database tables field selection is
supported.
For these tables, you can fill just those database fields
which the report actually needs. In the report, you determine these
fields with GET dbtab FIELDS f1 … fn or GET dbtab LATE FIELDS f1 …
fn (the field list is then supplemented by the key fields of the table
dbtab ).
By restricting to the really necessary field, you
considerably improve performance. The database access program SAPDBldb
receives the desired fields for the dynamic field selection in the form
of an internal table SELECT_FIELDS .

Note
The exact definition of the object SELECT_FIELDS is stored in the TYPE-POOL RSFS and looks something like below:

TYPES: BEGIN OF RSFS_TAB_FIELDS,
TABLENAME LIKE RSDSTABS-PRIM_TAB,
FIELDS LIKE RSFS_STRUC OCCURS 10,
END OF RSFS_TAB_FIELDS.

TYPES: RSFS_FIELDS TYPE RSFS_TAB_FIELDS OCCURS 10.

DATA SELECT_FIELDS TYPE RSFS_FIELDS.

SELECT_FIELDS
is thus an internal table. Each line of this internal table contains a
table name ( TABLENAME ) and another internal table ( FIELDS ) which
contains the desired fields of the table ( TABLENAME ).

Note
Neither
the TYPE-POOL RSFS nor the declaration of SELECT_FIELDS has to appear
in the database program. Both are automatically included by the system.
Unlike the objects connected with the addition DYNAMIC SELECTIONS ,
SELECT_FIELDS is also available in the report.
In the database program SAPDBldb , an access to a table XXXX could look something like below:

FORM PUT_XXXX.

DATA L_TAB_FIELDS TYPE RSFS_TAB_FIELDS.

MOVE ‘XXXX’ TO L_TAB_FIELDS-TABLENAME.
READ TABLE SELECT_FIELDS WITH KEY L_TAB_FIELDS-TABLENAME
INTO L_TAB_FIELDS.

SELECT (L_TAB_FIELDS-FIELDS)
INTO CORRESPONDING FIELDS OF XXXX
FROM XXXX
WHERE field1 IN …
AND field2 ….

PUT XXXX.
ENDSELECT.
ENDFORM.

Note
If
the table L_TAB_FIEDLS is empty, i.e. if no dynamic selections are
entered for the table XXXX , SELECT (L_TAB_FIELDS) … works like
SELECT * … , i.e. all fields of the table XXXX are filled.
The
internal table SELECT_FIELDS already contains values when the routine
INIT is executed in the database program or when the INITIALIZATION
processing is executed in the report. It can be manipulated by the
appropriate program if it is absolutely necessary to fill another field
for the logical database.