ABAP Reports
ABAP Reports
Report Components
Report Input Fields (Values)
Report Selection Screens (Visuals)
Report Selection Screen Events
SELECT-OPTIONS
Enables us to create value range and
complex selections for an input field instead of
just one single input value an input field .
PARAMETERS
DATA wa_flight TYPE dv_flights.
PARAMETERS pa_carr LIKE wa_flight-carrid.
PARAMETERS: pa_name AS CHECKBOX DEFAULT 'X',
pa_curr AS CHECKBOX DEFAULT 'X'.
PARAMETERS: pa_lim_1 RADIOBUTTON GROUP lim,
pa_lim_2 RADIOBUTTON GROUP lim DEFAULT 'X' ,
pa_lim_3 RADIOBUTTON GROUP lim.
1 input field
2 checkboxes, each can
be checked or unchecked
independently
1 set of radiobuttons, only
one can be selected at
a time from the GROUP
Reference:
See T-Code: BIBS
for more examples
PARAMETERS
* Check if any checkbox has been selected
CONSTANTS mark VALUE X.
IF pa_name EQ mark
ENDIF.
* Check which RADIOBUTTON has been selected
CASE mark.
WHEN pa_lim_1.
WHEN pa_lim_2.
WHEN pa_lim_3.
ENDCASE.
SELECT-OPTIONS
SELECT-OPTIONS so_car FOR wa_flight-carrid
DEFAULT AA.
This creates an internal table (with a header)
having the name so_car. The internal table has 4
columns SIGN, OPTION, LOW and HIGH.
SIGN I (Include), E (Exclude)
OPTION EQ (Equal), NE (Not equal), LE (Less
than or equal), LT (Less than), GE (Greater than
or equal), GT (Greater than), BT (Between), NB
(Not between), CP (Contains pattern), NP
(Contains pattern not)
LOW or both LOW & HIGH contain values
depending on OPTION value
SELECT-OPTIONS
SIGN
OPTION
LOW
EQ
CO
BT
AA
EQ
AB
BT
AF
HIGH
BA
AZ
The selection is union of all Includes minus the union of all Excludes.
= Union of (Value = CO, Value between AA and BA)
Minus
Union of (Value = AB, Value between AF and AZ)
= (AA, AB, AC, AF, AZ, BA, CO) Minus (AB, AF, AZ)
= (AA, AC, BA, CO)
Will select-options make querys where clause complicated for
programmer? No it is easy to use in any where clause as shown below
SAP takes care of the logic.
SELECT * FROM dv_flights INTO wa_flight WHERE carrid IN so_car.
SELECT-OPTIONS
OPTIONS (during definition of select-options)
DEFAULT AA [defaults the low value]
DEFAULT AA TO BA [defaults the low & high values]
MEMORY ID <pid> [saves selection screen input field value to memory
for later retrieval of the value to screen]
LOWER CASE [suppresses the conversion of input to upper case]
OBLIGATORY [makes the field a required field]
NO-EXTENSION [suppresses the possibility of multiple selections]
NO INTERVELS [suppresses the interval limit high]
MODIF ID <mod> [The name of modification group <mod> is a threecharacter variable name without quotation marks. Parameters
assigned to a modification group can be processed as an entire
group with the LOOP AT SCREEN and MODIFY SCREEN
statements Used for dynamic modifications to selection screen at
run time]
Title
Selection-screen block
(the colored/highlighted box)
SELECTIONSCREEN PUSHBUTTON
* Structure for pushbutton command
TABLES: sscrfields.
SELECTION-SCREEN PUSHBUTTON pos_low(20) push_det
USER-COMMAND details.
INITIALIZATION.
* Text for pushbuttons
push_det = 'Hide details'(p02).
AT SELECTION-SCREEN.
* Evaluate pushbutton command
CASE sscrfields-ucomm.
WHEN 'DETAILS'.
CHECK sy-dynnr = 1100.
IF switch = '1'.
switch = '0'.
ELSE.
switch = '1'.
ENDIF.
ENDCASE.
AT SELECTION-SCREEN
AT SELECTION-SCREEN ON <field>
AT SELECTION-SCREEN ON <select-table>
AT SELECTION-SCREEN ON RADIOBUTTON GROUP <group>
AT SELECTION-SCREEN ON BLOCK <block>
AT SELECTION-SCREEN ON HELP-REQUEST (F1)
AT SELECTION-SCREEN ON VALUE-REQUEST (F4)
AT SELECTION-SCREEN ON <field>
If an error message or warning message is displayed during this
event, the system makes only the above screen fields ready for
input
AT SELECTION-SCREEN ON <block>
This is available to check entry combinations of a logical group. All
fields in this block are made ready for input when an error
message is issued
SKIP
Use the SKIP statement to create a line feed. To
create several line feeds, specify the desired number
behind SKIP. SKIP 5 (This line creates five line feeds)
ULINE
Use the ULINE statement to create a line feed first
and then draw a horizontal line. This statement also
helps to make lists easier to read
Terminal Session 1
ABAP Memory
REPORT Z_EXPORT_ABAP_MEM.
PARAMETERS: myparam TYPE c LENGTH 4.
DATA: mydata(4) TYPE C.
START-OF-SELECTION.
mydata = myparam.
export mydata to memory id 'MYABAP_MEMORY'.
WRITE 'Value exported'.
WRITE mydata.
*SUBMIT Z_IMPORT_ABAP_MEM.
ABAP Memory
REPORT Z_IMPORT_ABAP_MEM.
*PARAMETERS: myparam TYPE c LENGTH 4.
DATA: mydata(4) TYPE C.
START-OF-SELECTION.
import mydata from memory id 'MYABAP_MEMORY'.
WRITE 'mydata = '.
WRITE mydata.
ABAP Memory
Notes:
After the export program is run, if the import program is run
1)
In the same window ABAP memory values are read
2)
Import program is called from the export program (SUBMIT)
ABAP memory values are read
3)
Called from a new session (external) created using the Creates
New Session button on the top menu - ABAP memory values are
NOT read
4)
Called from a new user logon (SAPgui) from the same or different
PC for the same user - ABAP memory values are NOT read
5)
Called from a new user logon (SAPgui) from the same or different
PC for a different user - ABAP memory values are NOT read
GET/SET parameters
These are also called SPA/GPA parameters
The most frequent use of GET/SET parameters
is to fill input fields on screens
These parameters are reset when you logoff the
sessions (exit)
These parameters can be set either for a
particular user or for a particular program using
the SET PARAMETER statement
Other ABAP programs can then retrieve the set
parameters using the GET PARAMETER
statement
GET/SET parameters
REPORT Z_SET_PARAMETER.
PARAMETERS: myparam1 TYPE c LENGTH 4 MEMORY ID ZMYID1.
PARAMETERS: myparam2 TYPE c LENGTH 4.
* INITIALIZATION.
* note: since there is no GET parameter here no values will be initialized (read)
* for myparam2 (myparam1 is fine as it is defined with MEMORY ID option).
START-OF-SELECTION.
* note: myparam2 but not myparam1 needs SET parameter cmd
* because myparam1 is defined with MEMORY ID option.
* SET PARAMETER ID 'ZMYID1' FIELD myparam1.
SET PARAMETER ID 'ZMYID2' FIELD myparam2.
WRITE 'Parameter [myparam1/myparam2]: '.
WRITE: myparam1, '/', myparam2.
*SUBMIT Z_GET_PARAMETER VIA SELECTION-SCREEN AND RETURN.
GET/SET parameters
REPORT Z_GET_PARAMETER.
PARAMETERS: myparam1 TYPE c LENGTH 4 MEMORY ID ZMYID1.
PARAMETERS: myparam2 TYPE c LENGTH 4.
INITIALIZATION.
* note: only myparam2 (but not myparam1) needs GET parameter
* command because myparam1 is defined with MEMORY ID option.
* GET PARAMETER ID 'ZMYID1' FIELD myparam1.
GET PARAMETER ID 'ZMYID2' FIELD myparam2.
* note: since there is no SET parameter here
* no values will be set for myparam2 (myparam1 is fine).
START-OF-SELECTION.
WRITE 'Parameter [myparam1/myparam2]: '.
WRITE: myparam1, '/', myparam2.
GET/SET parameters
Notes:
After the Set program is run, if the Get program is run
1)
In the same window SAP memory values are read
2)
Get program is called from the Set program (SUBMIT) SAP
memory values are read
3)
Get program called from a new session (external) created using the
Creates New Session button on the top menu - SAP memory
values are read
4)
Called from a new user logon (SAPgui) from the same or different
PC for the same user - SAP memory values are NOT read
5)
Called from a new user logon (SAPgui) from the same or different
PC for a different user - SAP memory values are NOT read
Variants
Variants allow you to reuse values entered
once on the selection screens. These are
helpful when:
The program is started frequently with same
values
The program is run in the background
Variants (continued)
A variant consists of two parts:
The values entered on the selection screen (example:
Value AA for airlines)
The attributes and display attributes of the
parameters and select-options (example: Making
some fields read-only or some not visible, etc)
Note: If you use the INITIALIZATION event to initialize
any variables in the program, the variant will not have
any effect on them (will get overwritten by the
initialization)
User-specific values B option (this option is used to enter userspecific values in a selection field)
Example:
ZBC405_C027393_SSCS_3E01
Example:
ZBC405_C027393_SSCS_3E01
Example:
ZBC405_C027393_SSCS_3E01
WHEN national.
* Radiobutton NATIONAL is marked
SELECT * FROM dv_flights INTO wa_flight
WHERE carrid IN so_car
AND connid IN so_con
AND fldate IN so_fdt
AND cityfrom IN so_start
AND cityto IN so_dest
AND countryto = dv_flights~countryfr
AND countryto = country.
WRITE: / wa_flight-carrid,
wa_flight-connid,
wa_flight-fldate,
wa_flight-countryfr,
wa_flight-cityfrom,
wa_flight-airpfrom,
wa_flight-countryto,
wa_flight-cityto,
wa_flight-airpto,
wa_flight-seatsmax,
wa_flight-seatsocc.
ENDSELECT.
Example:
ZBC405_C027393_SSCS_3E01
WHEN internat.
* Radiobutton INTERNAT is marked
SELECT * FROM dv_flights INTO wa_flight
WHERE carrid IN so_car
AND connid IN so_con
AND fldate IN so_fdt
AND cityfrom IN so_start
AND cityto IN so_dest
AND countryto <> dv_flights~countryfr.
WRITE: / wa_flight-carrid,
wa_flight-connid,
wa_flight-fldate,
wa_flight-countryfr,
wa_flight-cityfrom,
wa_flight-airpfrom,
wa_flight-countryto,
wa_flight-cityto,
wa_flight-airpto,
wa_flight-seatsmax,
wa_flight-seatsocc.
ENDSELECT.
ENDCASE.
Example:
ZBC405_C027393_SSCS_3E01
Example:
ZBC405_C027393_SSCS_3E01
*&-----------------------------------------------*& Event at selection-screen
*&-----------------------------------------------AT SELECTION-SCREEN.
* Evaluate pushbutton command
CASE sscrfields-ucomm.
WHEN 'DETAILS'.
CHECK sy-dynnr = 1100.
IF switch = '1'.
switch = '0'.
ELSE.
switch = '1'.
ENDIF.
ENDCASE.
Example: BC405_SSCS_3TOP
Example: BC405_SSCS_3TOP
SELNAME length 8 must contain the name of a parameter or selection criterion [selectoptions] for the selection screen in block capitals
KIND length 1 must contain the type of selection screen component (P for parameters, S
for selection criteria)
SIGN length 1 specifies whether the result of the row condition needs to be included for
each row (I Inclusive, E Exclusive)
OPTION length 2 specifies the comparison operators EQ (equal), NE (not equal), GT
(greater than), BT (between) and NB (not between)
LOW length 45 this is the lower limit of the range (in the case of parameters, the value
must be specified in LOW and all other components are ignored)
HIGH length 45 this is the lower limit of the range