From 4fe73d73ff0916b3902ea4f4b33b2493cb0d0a1f Mon Sep 17 00:00:00 2001
From: danrega <16720986+danrega@users.noreply.github.com>
Date: Fri, 3 Nov 2023 10:23:23 +0100
Subject: [PATCH] Add selection screen/list example
---
.../zdemo_abap_event_blocks.prog.abap | 403 ++++++++++++++
.../zdemo_abap_event_blocks.prog.xml | 23 +
.../zdemo_abap_lists.prog.abap | 515 ++++++++++++++++++
.../zdemo_abap_lists.prog.xml | 23 +
.../zdemo_abap_selscr_lists_intro.prog.abap | 100 ++++
.../zdemo_abap_selscr_lists_intro.prog.xml | 23 +
.../zdemo_abap_selscr_parameters.prog.abap | 224 ++++++++
.../zdemo_abap_selscr_parameters.prog.xml | 23 +
.../zdemo_abap_selscr_select_opt.prog.abap | 142 +++++
.../zdemo_abap_selscr_select_opt.prog.xml | 23 +
.../zdemo_abap_selscr_standalone.prog.abap | 218 ++++++++
.../zdemo_abap_selscr_standalone.prog.xml | 23 +
.../zdemo_abap_selscr_stmts_var.prog.abap | 263 +++++++++
.../zdemo_abap_selscr_stmts_var.prog.xml | 23 +
14 files changed, 2026 insertions(+)
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.abap
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.xml
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.abap
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.xml
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.abap
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.xml
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.abap
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.xml
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.abap
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.xml
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.abap
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.xml
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.abap
create mode 100644 src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.xml
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.abap b/src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.abap
new file mode 100644
index 0000000..3804fb0
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.abap
@@ -0,0 +1,403 @@
+***********************************************************************
+*
+* ABAP cheat sheet: Selection screens and classic lists
+* Example: Event blocks
+*
+* -------------------------- PURPOSE ----------------------------------
+* - Example that demonstrates event blocks
+* - The main purpose of the example to visualize the calling of the
+* events. Internal tables are filled during the events to log the
+* event name and the time stamp when it is called. The tables
+* are then output. It is implemented in such a way that it consists
+* only of a basic list and a details list. Note the selection screen
+* comments displayed.
+* Includes:
+* - Program constructor: LOAD-OF-PROGRAM
+* - Reporting events: INITIALIZATION, START-OF-SELECTION
+* - Selection screen events: AT SELECTION-SCREEN ...
+* - List events: AT LINE-SELECTION, AT USER-COMMAND, TOP-OF-PAGE,
+* END-OF-PAGE
+*
+* Notes:
+* A selection of additions is used. For more additions and details,
+* see the ABAP Keyword Documentation.
+*
+* ----------------------- GETTING STARTED -----------------------------
+* - Open the program with the ABAP development tools for Eclipse (ADT).
+* - Choose F8 to run the program.
+*
+* ----------------------------- NOTE -----------------------------------
+* The code presented in this class is intended only to support the ABAP
+* cheat sheets. It is not intended for direct use in a production system
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
+* errors or their consequences that may occur when using the the example
+* code.
+*
+***********************************************************************
+
+"LINE-COUNT: Specifies the page length for the basic list
+"Number in parentheses: Lines that are reserved for the page footer,
+"which can be specified in the END-OF-PAGE event block.
+PROGRAM LINE-COUNT 20(3).
+
+TYPES: BEGIN OF st,
+ id TYPE c LENGTH 3,
+ event_block TYPE c LENGTH 50,
+ time TYPE utclong,
+ END OF st.
+DATA: counter_line TYPE i,
+ reporting_and_selscr_log TYPE TABLE OF st WITH EMPTY KEY,
+ list_log TYPE TABLE OF st WITH EMPTY KEY,
+ counter TYPE i,
+ tstmp TYPE utclong.
+
+SELECTION-SCREEN COMMENT /1(70) intro.
+SELECTION-SCREEN SKIP.
+
+SELECTION-SCREEN BEGIN OF BLOCK blk.
+ PARAMETERS: number1 TYPE string DEFAULT `1` VISIBLE LENGTH 5 .
+ PARAMETERS: number2 TYPE string DEFAULT `2` VISIBLE LENGTH 5 .
+SELECTION-SCREEN END OF BLOCK blk.
+
+PARAMETERS: plus RADIOBUTTON GROUP grp DEFAULT 'X',
+ minus RADIOBUTTON GROUP grp,
+ multiply RADIOBUTTON GROUP grp,
+ divide RADIOBUTTON GROUP grp.
+
+SELECTION-SCREEN SKIP 2.
+SELECTION-SCREEN COMMENT /1(70) note.
+
+"Local class with methods used in the example in various places
+CLASS demo DEFINITION.
+ PUBLIC SECTION.
+ CLASS-METHODS:
+ sel_screen_evt IMPORTING evt TYPE string,
+ write_line IMPORTING evt TYPE string
+ utc TYPE utclong,
+ counter,
+ list_evt IMPORTING evt TYPE string,
+ write_rep_sel_log,
+ write_list_log.
+ CLASS-DATA: li_wa LIKE LINE OF list_log,
+ sel_wa LIKE LINE OF reporting_and_selscr_log.
+ENDCLASS.
+
+CLASS demo IMPLEMENTATION.
+ METHOD counter.
+ IF counter = 0.
+ counter = 1.
+ ELSE.
+ counter += 1.
+ ENDIF.
+ ENDMETHOD.
+
+ METHOD sel_screen_evt.
+ counter( ).
+ APPEND VALUE #( id = counter event_block = evt time = utclong_current( ) ) TO reporting_and_selscr_log.
+ ENDMETHOD.
+
+ METHOD list_evt.
+ counter( ).
+ APPEND VALUE #( id = counter event_block = evt time = utclong_current( ) ) TO list_log.
+ ENDMETHOD.
+
+ METHOD write_line.
+ counter( ).
+ WRITE: /3(*) counter,
+ 15 evt,
+ 60 utc.
+ ENDMETHOD.
+
+ METHOD write_rep_sel_log.
+ SKIP.
+ WRITE / '********** Log entries for reporting and selection screen events **********' COLOR 2.
+
+ FORMAT COLOR 2.
+ WRITE: /3 'ID', 15 'Event Block', 60 'Time' .
+ FORMAT COLOR OFF.
+ LOOP AT reporting_and_selscr_log INTO sel_wa.
+ WRITE: / sel_wa-id UNDER 'ID',
+ sel_wa-event_block UNDER 'Event Block',
+ sel_wa-time UNDER 'Time'.
+ ENDLOOP.
+ ENDMETHOD.
+
+ METHOD write_list_log.
+ WRITE / '********** Log entries for list events **********' COLOR 2.
+
+ FORMAT COLOR 2.
+ WRITE: /3 'ID', 15 'Event Block', 60 'Time' .
+ FORMAT COLOR OFF.
+ LOOP AT list_log INTO li_wa.
+ WRITE: / li_wa-id UNDER 'ID',
+ li_wa-event_block UNDER 'Event Block',
+ li_wa-time UNDER 'Time'.
+ ENDLOOP.
+ ENDMETHOD.
+ENDCLASS.
+
+**********************************************************************
+
+LOAD-OF-PROGRAM.
+
+ "Called when a program is loaded into the internal session
+ "When you call an executable programs with SUBMIT, it is recommended that
+ "you use the INITIALIZATION event for initializing data objects, since the
+ "initial values for parameters and selection criteria are set after LOAD-OF-PROGRAM.
+
+ demo=>sel_screen_evt( `LOAD-OF-PROGRAM` ).
+
+**********************************************************************
+
+INITIALIZATION.
+
+ "Called immediately after LOAD-OF-PROGRAM and before the selection
+ "screen processing of an existing standard selection screen.
+ "You can initialize the input fields of the selection screen here.
+
+ demo=>sel_screen_evt( `INITIALIZATION` ).
+ intro = 'Enter two integers and select a radio button for a calculation.'.
+ note = 'The Back/Exit/Cancel buttons raise the ON EXIT-COMMAND event.'.
+
+**********************************************************************
+
+AT SELECTION-SCREEN OUTPUT.
+ "Called by the dynpro event PBO of a selection screen
+ "Can be used for screen modifications.
+
+ demo=>sel_screen_evt( `AT SELECTION-SCREEN OUTPUT` ).
+
+ LOOP AT SCREEN INTO DATA(wa).
+ IF wa-name = 'INTRO'.
+ wa-intensified = '1'.
+ MODIFY SCREEN FROM wa.
+ ENDIF.
+
+ ENDLOOP.
+
+**********************************************************************
+
+AT SELECTION-SCREEN ON RADIOBUTTON GROUP grp.
+
+ "Called when the values for a radio button group was passed
+
+ demo=>sel_screen_evt( `AT SELECTION-SCREEN ON RADIOBUTTON GROUP` ).
+
+ CASE 'X'.
+ WHEN plus.
+ MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be +' TYPE 'I'.
+ WHEN minus.
+ MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be -' TYPE 'I'.
+ WHEN multiply.
+ MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be *' TYPE 'I'.
+ WHEN divide.
+ MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be /' TYPE 'I'.
+ ENDCASE.
+
+**********************************************************************
+
+AT SELECTION-SCREEN ON BLOCK blk.
+
+ "Called when all input for a block is passed to the program
+
+ demo=>sel_screen_evt( `AT SELECTION-SCREEN ON BLOCK blk` ).
+
+ CONDENSE number1 NO-GAPS.
+ CONDENSE number2 NO-GAPS.
+ FIND PCRE `\D` IN number1.
+ DATA(subrc) = sy-subrc.
+ FIND PCRE `\D` IN number2.
+ IF subrc = 0
+ OR sy-subrc = 0.
+ MESSAGE 'Event AT SELECTION-SCREEN ON BLOCK is called. Provide correct integer values.' TYPE 'E'.
+ ENDIF.
+
+**********************************************************************
+
+AT SELECTION-SCREEN ON number1.
+
+ "Called when values for a parameter (which is the case here) or selection criteria were passed to the program
+
+ demo=>sel_screen_evt( `AT SELECTION-SCREEN ON number1.` ).
+
+ IF number1 IS INITIAL.
+ MESSAGE 'Event AT SELECTION-SCREEN ON is called. Please make an entry for number1' TYPE 'E'.
+ ENDIF.
+
+**********************************************************************
+
+AT SELECTION-SCREEN ON number2.
+
+ "Called when values for a parameter (which is the case here) or selection criteria were passed to the program
+
+ demo=>sel_screen_evt( `AT SELECTION-SCREEN ON number2.` ).
+
+ IF number2 IS INITIAL.
+ MESSAGE 'Please make an entry for number2' TYPE 'E'.
+ ENDIF.
+
+**********************************************************************
+
+AT SELECTION-SCREEN ON EXIT-COMMAND.
+
+ "Called in case of Back, Exit, or Cancel
+
+ MESSAGE 'Event AT SELECTION-SCREEN ON EXIT-COMMAND is called. See you.' TYPE 'I'.
+
+**********************************************************************
+
+AT SELECTION-SCREEN.
+
+ "Called as last event in the selection screen processing when all
+ "input values are passed to the program
+
+ demo=>sel_screen_evt( `AT SELECTION-SCREEN` ).
+
+ IF number2 = 0 AND
+ divide = 'X'.
+ MESSAGE 'Event AT SELECTION-SCREEN is called. Zero division is not possible.' TYPE 'E'.
+ ENDIF.
+
+**********************************************************************
+
+START-OF-SELECTION.
+
+ "Called during the processing of an executable program after selection
+ "screen processing
+
+ "SET USER-COMMAND: The following statement is included for demonstration
+ "purposes. It programmatically raises a list event with a specified function
+ "code.
+ "Such a statement can be used when creating a list. After the list has been
+ "created, but before the current list is displayed, the runtime
+ "framework responds as if a user action had been performed in the
+ "displayed list with the specified function code.
+ SET USER-COMMAND 'START'.
+
+ demo=>sel_screen_evt( `START-OF-SELECTION` ).
+
+ WRITE / 'This is the basic list showing the content of a log table (mostly reporting and selection screen events). Double-click a line in this list to display more events in a details list.' COLOR 4.
+ SKIP.
+ WRITE / '************************** Calculation result **************************' COLOR 2.
+
+ IF plus = 'X'.
+ WRITE / |{ number1 } + { number2 } = { number1 + number2 }|.
+ ENDIF.
+
+ IF minus = 'X'.
+ WRITE / |{ number1 } - { number2 } = { number1 - number2 }|.
+ ENDIF.
+
+ IF multiply = 'X'.
+ TRY.
+ WRITE / |{ number1 } * { number2 } = { number1 * number2 }|.
+ CATCH cx_sy_arithmetic_error INTO DATA(error).
+ WRITE / |{ number1 } * { number2 } = ??? Error in multiplication: { error->get_text( ) }| COLOR COL_NEGATIVE.
+ ENDTRY.
+ ENDIF.
+
+ IF divide = 'X'.
+ TRY.
+ WRITE / |{ number1 } / { number2 } = { CONV decfloat34( number1 / number2 ) DECIMALS = 3 }|.
+ IF number1 = 0 AND number2 = 0.
+ WRITE / `No zero division error? Note that ABAP "allows" zero division if the first number is also 0 :)` COLOR COL_NEGATIVE.
+ ENDIF.
+ CATCH cx_sy_zerodivide INTO error.
+ WRITE / |{ number1 } / { number2 } = ??? Error in division: { error->get_text( ) }| COLOR COL_NEGATIVE.
+ ENDTRY.
+ ENDIF.
+
+ IF reporting_and_selscr_log IS NOT INITIAL.
+ demo=>write_rep_sel_log( ).
+ ENDIF.
+
+**********************************************************************
+
+AT LINE-SELECTION.
+
+ "Called when
+ "- a screen list is displayed and
+ "- the screen cursor is on a list line and
+ "- a function is selected using the function code PICK
+
+ demo=>list_evt( evt = `AT LINE-SELECTION` ).
+
+ "SET USER-COMMAND: The following statement is included for demonstration
+ "purposes. It programmatically raises a list event with a specified function
+ "code.
+ SET USER-COMMAND 'LINE'.
+
+ IF sy-lsind <= 1.
+ WRITE / 'This is a details list. It shows the content of another log table (mostly list events). Clicking in this list does nothing meaningful.' COLOR 4.
+ WRITE / 'You may want to go back to the basic list, double-click a line there to come back here, and see more log entries added for list events.' COLOR 4.
+ WRITE / 'When the counter reaches 40, the program is restarted :)' COLOR 4.
+ SKIP.
+ WRITE / `************** Some sy Components **************` COLOR 2.
+ WRITE / |Content of clicked line (sy-lisel): "{ sy-lisel }"|.
+ WRITE / |Number of clicked line (sy-lilli): "{ sy-lilli }"|.
+ WRITE / |List level of the current list (sy-lsind): "{ sy-lsind }"|.
+ SKIP.
+ IF list_log IS NOT INITIAL.
+ demo=>write_list_log( ).
+ ENDIF.
+ ENDIF.
+
+**********************************************************************
+
+AT USER-COMMAND.
+
+ "Called when a function with a user-defined function code is selected when a screen list is displayed
+ "Note: PICK does not raised the AT USER-COMMAND event. Instead, it raises the AT LINE-SELECTION event.
+
+ CASE sy-ucomm.
+ WHEN 'START'.
+ demo=>list_evt( `AT USER-COMMAND (Function code: START)` ).
+ MESSAGE |AT USER-COMMAND event raised (Function code: START). Counter value: { counter }.| TYPE 'I'.
+ WHEN 'LINE'.
+ demo=>list_evt( `AT USER-COMMAND (Function code: LINE)` ).
+ MESSAGE |AT USER-COMMAND event raised (Function code: LINE). Counter value: { counter }.| TYPE 'I'.
+ IF counter >= 40.
+ MESSAGE |The counter has reached the threshold. The program will be started again using a SUBMIT statement.| TYPE 'I'.
+ SUBMIT (sy-repid) VIA SELECTION-SCREEN.
+ ENDIF.
+ ENDCASE.
+
+**********************************************************************
+
+TOP-OF-PAGE.
+
+ "Called when a basic list is created and when a new page begins
+
+ tstmp = utclong_current( ).
+ demo=>counter( ).
+ APPEND VALUE #( id = counter event_block = |TOP-OF-PAGE| time = tstmp ) TO list_log.
+ WRITE: / |********************* Title inserted at TOP-OF-PAGE event ({ counter }) *********************|.
+
+**********************************************************************
+
+TOP-OF-PAGE DURING LINE-SELECTION.
+
+ "Called when details lists are created
+
+ tstmp = utclong_current( ).
+ demo=>counter( ).
+ APPEND VALUE #( id = counter event_block = |TOP-OF-PAGE DURING LINE-SELECTION| time = tstmp ) TO list_log.
+ WRITE: / |********************* Title inserted at TOP-OF-PAGE DURING LINE-SELECTION event ({ counter }) *********************|.
+
+**********************************************************************
+
+END-OF-PAGE.
+
+ "Called when the end of a page is reached, for example, if the specified number of lines in the
+ "LINE-COUNT addition has been reached
+
+ tstmp = utclong_current( ).
+ demo=>counter( ).
+ APPEND VALUE #( id = counter event_block = |END-OF-PAGE| time = tstmp ) TO list_log.
+ WRITE: / |********************* Footer inserted at END-OF-PAGE event ({ counter }) *********************|.
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.xml b/src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.xml
new file mode 100644
index 0000000..94daf02
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_event_blocks.prog.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ ZDEMO_ABAP_EVENT_BLOCKS
+ S
+ D$
+ 1
+ X
+ D$S
+ X
+
+
+ -
+ R
+ Event blocks (ABAP cheat sheet: Selection Screens/Classic Lists)
+ 64
+
+
+
+
+
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.abap b/src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.abap
new file mode 100644
index 0000000..7e97914
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.abap
@@ -0,0 +1,515 @@
+***********************************************************************
+*
+* ABAP cheat sheet: Selection screens and classic lists
+* Example: Classic lists
+*
+* -------------------------- PURPOSE ----------------------------------
+* Example that demonstrates various ABAP statements in the context of
+* classic lists
+* Includes:
+* - Creating lists: WRITE, FORMAT, ULINE, SET BLANK LINES, SKIP,
+* NEW-LINE, HIDE, HOTSPOT, RESERVE/BACK
+* - Reading and modifying in lists: READ LINE, MODIFY LINE
+*
+* Notes:
+* - A selection of additions is used. For more additions and details,
+* see the ABAP Keyword Documentation.
+* - See the ABAP cheat sheet for other statements used here, for example,
+* the ones related to event blocks such as START-OF-SELECTION.
+*
+* ----------------------- GETTING STARTED -----------------------------
+* - Open the program with the ABAP development tools for Eclipse (ADT).
+* - Choose F8 to run the program.
+*
+* ----------------------------- NOTE -----------------------------------
+* The code presented in this class is intended only to support the ABAP
+* cheat sheets. It is not intended for direct use in a production system
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
+* errors or their consequences that may occur when using the the example
+* code.
+*
+***********************************************************************
+
+PROGRAM.
+
+TYPES: BEGIN OF str,
+ statement TYPE string,
+ line_content TYPE string,
+ END OF str.
+
+DATA: count TYPE i,
+ line LIKE sy-linno,
+ linno1 LIKE sy-linno,
+ linno2 LIKE sy-linno,
+ linno_int LIKE sy-linno,
+ linno_copy LIKE sy-linno,
+ linno_mod1 LIKE sy-linno,
+ linno_mod2 LIKE sy-linno,
+ linno_input LIKE sy-linno,
+ lisel_copy LIKE sy-lisel,
+ square TYPE i,
+ cube TYPE i,
+ int_for_back LIKE sy-colno,
+ itab TYPE string_table,
+ str_tab TYPE string_table,
+ lisel_tab TYPE string_table,
+ str TYPE string,
+ input_int TYPE c LENGTH 3 VALUE 3,
+ read_line TYPE c LENGTH 1,
+ num TYPE i,
+ char TYPE c LENGTH 10,
+ tab TYPE TABLE OF str WITH EMPTY KEY,
+ var LIKE input_int,
+ int TYPE i,
+ li LIKE LINE OF tab,
+ chck1 TYPE c LENGTH 1 VALUE 'X',
+ chck2 TYPE c LENGTH 1 VALUE ' ',
+ input TYPE c LENGTH 20 VALUE 'Make an entry here',
+ dc34 TYPE decfloat34 VALUE ' 1.2345 ',
+ txt TYPE string VALUE `abap`,
+ some_text TYPE string VALUE `Hi, `,
+ abc TYPE c LENGTH 5 VALUE 'abcde',
+ dc TYPE decfloat34 VALUE '1.2345'.
+
+**********************************************************************
+
+INITIALIZATION.
+
+ itab = VALUE #( ( `a` ) ( `b` ) ( `` ) ( `` ) ( `c` ) ).
+
+**********************************************************************
+
+START-OF-SELECTION.
+
+ "WRITE using an unnamed data object
+ WRITE 'Hello ABAP.'.
+ "Named data objects
+ "Note: The text is written right after the previous text in one line.
+ WRITE some_text && sy-uname.
+
+ WRITE / '****************** WRITE: Positioning output ******************'.
+ "/: Writes to a new line
+ WRITE / 'new line'.
+ "Specifying the output position (and output in new line)
+ WRITE /5 'positioned'.
+ "Specifying the length, no position specified means the output is
+ "written from the first column on
+ WRITE /(3) 'not displayed completely'.
+ "Specifying both length and position
+ WRITE /5(30) 'this is displayed completely'.
+ "Position/length only specified as numeric literals as above, then the
+ "addition AT can be omitted
+ WRITE AT /3(12) 'lorem ipsum'.
+ "Length specifications with * or **. In that case, the output length
+ "depends on the data type of the data object. There are special rules.
+ "See the ABAP Kwyword Documentation for the details.
+ WRITE /(*) dc34.
+ WRITE /1(**) dc34.
+
+ WRITE / '****************** WRITE: Further specification options ******************'.
+ "There are many further specification options, among them function calls, string
+ "expressions, method calls to be specified after WRITE.
+
+ "String template
+ WRITE / |{ txt WIDTH = 20 ALIGN = RIGHT CASE = UPPER }|.
+ "The following statement uses a chained statement with colon.
+ WRITE: / |{ 1 + 2 }|, "String template includes an arithmetic calculation
+ / to_upper( txt ). "Function call
+ "Concatenation using &&
+ WRITE / `conc` && `atenated`.
+ "Method call (returns a random integer between 1 and 10)
+ "Note the * specification. The returned value is of type i. Specifying *
+ "for the length means the length required to output the current value
+ "is used. You may want to try the following code snippet by removing (*).
+ WRITE /(*) cl_abap_random_int=>create(
+ seed = cl_abap_random=>seed( )
+ min = 1
+ max = 10 )->get_next( ).
+
+ WRITE / '****************** WRITE: UNDER addition ******************'.
+ "UNDER: Puts the output in the position of previous output
+ "Note: If the output is written in the same line in which the previous output
+ "is displayed, this output is overwritten.
+
+ WRITE /5(5) abc.
+ WRITE / 'fghij' UNDER abc.
+
+ WRITE / '****************** WRITE: NO-GAP addition ******************'.
+ WRITE / 'g'.
+ WRITE 'ap1'. "Output: g ap1
+ WRITE: / 'g' NO-GAP, 'ap2'. "Output: gap2
+
+ WRITE / '****************** WRITE: QUICKINFO addition ******************'.
+ "QUICKINFO: Creates a tooltip for the output
+ WRITE / 'Hover over the following output and check the tooltip:'.
+ WRITE: (*) sy-uname QUICKINFO 'User name',
+ '/',
+ (*) sy-datum QUICKINFO 'Current date',
+ '/',
+ (*) sy-uzeit QUICKINFO 'Current time'.
+
+ WRITE / '****************** WRITE: Special list elements ******************'.
+ "INPUT
+ WRITE / input INPUT.
+ linno_input = sy-linno.
+
+ "AS CHECKBOX
+ "The value (blank, X) is stored in the list buffer and can be evaluated during
+ "a list event.
+ WRITE: / chck1 AS CHECKBOX, 'Checkbox 1',
+ / chck2 AS CHECKBOX, 'Checkbox 2'.
+
+ "AS ICON: Outputting icons
+ "Check the type pool ICON for names of predefined icons.
+ WRITE / icon_green_light AS ICON.
+ WRITE / icon_red_light AS ICON.
+ WRITE / icon_yellow_light AS ICON.
+ WRITE / icon_activate AS ICON.
+
+ "AS SYMBOL: Outputting symbols
+ "Check the type pool SYM for names of predefined icons.
+ WRITE / sym_left_hand AS SYMBOL.
+ WRITE / sym_caution AS SYMBOL.
+
+ "AS LINE: Outputting corners, crosses, lines, and T sections
+ "Check the type pool LINE for names of predefined icons.
+ WRITE: /10 line_horizontal_line AS LINE NO-GAP,
+ line_space AS LINE NO-GAP,
+ line_vertical_line AS LINE NO-GAP.
+
+ WRITE / '****************** WRITE: Formatting options ******************'.
+ "The following examples show a selection. Various other additions are
+ "available that deal with currency, unit, date and time-related formatting,
+ "among others. See the ABAP Keyword Documentation.
+ WRITE /(10) 'X' RIGHT-JUSTIFIED.
+ WRITE /(10) 'X' CENTERED.
+ WRITE /(10) ` X`.
+ WRITE /(10) ` X` LEFT-JUSTIFIED.
+ WRITE /(*) dc DECIMALS 2.
+
+ "Colors
+ "The commented out value stands for the value that can also be directly
+ "specified in the syntax (except 0) or contained in a data object.
+ "There are several additions with many options.
+ WRITE / 'COL_BACKGROUND (0)' COLOR COL_BACKGROUND. "0 (GUI dependent)
+ WRITE / 'COL_HEADING (1)' COLOR COL_HEADING. "1 (gray-blue)
+ WRITE / 'COL_HEADING (1)' COLOR 1.
+ WRITE / 'COL_NORMAL (2)' COLOR COL_NORMAL. "2 (light gray)
+
+ WRITE / 'COL_TOTAL (3)' COLOR COL_TOTAL. "3 (yellow)
+ WRITE / 'COL_KEY (4)' COLOR COL_KEY. "4 (blue-green)
+ WRITE / 'COL_POSITIVE (5)' COLOR COL_POSITIVE. "5 (green)
+ WRITE / 'COL_NEGATIVE (6)' COLOR COL_NEGATIVE. "6 (red)
+ WRITE / 'COL_GROUP (7)' COLOR COL_GROUP. "7 (purple/orange)
+ WRITE / 'COLOR 7 OFF' COLOR 7 OFF. "default color
+
+ "Setting the intensity of the background color.
+ WRITE / 'COLOR 7 INTENSIFIED OFF' COLOR 7 INTENSIFIED OFF.
+
+ "INVERSE: When ON, the foreground, i.e. the output is displayed
+ "in the selected color.
+ WRITE / 'COLOR 7 INVERSE ON' COLOR 7 INVERSE ON.
+
+ WRITE / '****************** FORMAT ******************'.
+ "FORMAT: For applying settings (COLOR, INTENSIFIED, INVERSE ...)
+ "on all of the following output statements up to a definition
+ "with new settings
+
+ WRITE / '****************** FORMAT: FRAMES addition ******************'.
+ "FRAMES: Defines whether the - and | characters are converted to line elements,
+ "producing continuous lines.
+ FORMAT FRAMES ON.
+ WRITE: / '----',
+ / '| |',
+ / '----'.
+ FORMAT FRAMES OFF.
+
+ WRITE / '****************** FORMAT: COLOR addition ******************'.
+
+ "This example shows the already covered COLOR addition with FORMAT
+ "statements.
+ FORMAT COLOR COL_POSITIVE.
+ WRITE / 'ABC'.
+ WRITE / 'DEF'.
+ WRITE / 'GHI'.
+ FORMAT COLOR OFF.
+ WRITE / 'This is the first WRITE after a new setting with FORMAT ... OFF'.
+
+ WRITE / '****************** FORMAT: RESET addition ******************'.
+ "This addition sets all formatting settings for which the corresponding addition is
+ "not specified in the same FORMAT statement to the state OFF (exception: FRAMES).
+ "In the following example, note the effect of the RESET addition (apart from
+ "resetting the previously set COLOR and INVERSE addition:
+ "- INTENSIFIED ON is the state after the program start by default.
+ "- Now, with the reset, the state is INTENSIFIED OFF.
+ "- See the effect for all the WRITE statements that follow and that have
+ " the COLOR addition specified.
+ FORMAT COLOR 7 INVERSE ON.
+ WRITE / 'ABC'.
+ WRITE / 'DEF'.
+ FORMAT RESET.
+ WRITE / 'GHI'.
+ WRITE / 'JKL'.
+
+ WRITE / '****************** ULINE ******************'.
+ "ULINE: Creating a horizontal line
+ ULINE.
+ "More additions are available such as for the position and length.
+ ULINE AT 5(20).
+
+ WRITE / '****************** SET BLANK LINES ******************'.
+ "SET BLANK LINES: Specifying if blank lines created using WRITE are displayed
+ WRITE / 'SET BLANK LINES OFF.' COLOR 2.
+ SET BLANK LINES OFF.
+ LOOP AT itab INTO DATA(wa).
+ WRITE / wa.
+ ENDLOOP.
+
+ WRITE / 'SET BLANK LINES ON.' COLOR 3.
+ SET BLANK LINES ON.
+ LOOP AT itab INTO wa.
+ WRITE / wa.
+ ENDLOOP.
+
+ ULINE.
+
+ WRITE / '****************** SKIP ******************'.
+ "SKIP: Positions the list cursor explicitly
+ WRITE / 'SKIP' COLOR 4.
+ SKIP.
+ WRITE / 'SKIP 3' COLOR 5.
+ SKIP 3.
+ ULINE.
+ WRITE / 'SKIP TO LINE' COLOR 6.
+ WRITE / 'Text A'.
+ WRITE / 'Text B'.
+ line = sy-linno. "The line number of the previous output is retrieved.
+ WRITE / 'Text C'.
+ SKIP TO LINE line.
+ WRITE / 'Text D' COLOR 7.
+ WRITE / 'Text E'.
+ ULINE.
+
+ WRITE / '****************** NEW-LINE ******************'.
+ "NEW-LINE: Setting list cursor to the first position of the next line.
+ "Additions are available to affect the scrolling behavior.
+ WRITE / 'Next statement is NEW-LINE'.
+ NEW-LINE.
+ WRITE 'WRITE statement without /'.
+ ULINE.
+
+ WRITE / '****************** HIDE/HOTSPOT ******************'.
+ "The example contains a DO loop. In this loop, WRITE statements output
+ "the sy-index value (1 to 10). Based on the sy-index value, calculations
+ "are performed. The result is hidden using HIDE. When you click a line
+ "in the basic list in this very section, the hidden values are displayed
+ "in the details list.
+ WRITE / 'For the values of square and cube, click a line in this section.'.
+ linno1 = sy-linno.
+ FORMAT HOTSPOT ON.
+ DO 10 TIMES.
+ square = sy-index ** 2.
+ cube = sy-index ** 3.
+ WRITE / sy-index.
+ "Storing the content of a the variables together with the current list line.
+ HIDE: square, cube.
+ ENDDO.
+ FORMAT HOTSPOT OFF.
+ linno2 = sy-linno.
+
+ WRITE / '****************** RESERVE/BACK ******************'.
+ "RESERVE is demonstrated here with BACK.
+ "Consider the RESERVE 5 LINES statements as defining a block of
+ "5 lines. When using BACK after RESERVE, e.g. after a loop, you
+ "can put the suqsequent output to the first line of this block of lines.
+ WRITE / 'RESERVE without BACK:'.
+ int_for_back = sy-colno.
+ ULINE AT /(int_for_back).
+
+ RESERVE 5 LINES.
+
+ DO 5 TIMES.
+ WRITE / sy-index.
+ ENDDO.
+
+ int_for_back = sy-colno.
+
+ WRITE AT int_for_back ' <- This is not number 1.'.
+ SKIP.
+
+ WRITE / 'RESERVE with BACK:'.
+ int_for_back = sy-colno.
+ ULINE AT /(int_for_back).
+
+ RESERVE 5 LINES.
+
+ DO 5 TIMES.
+ WRITE / sy-index.
+ ENDDO.
+
+ int_for_back = sy-colno.
+
+ BACK.
+ WRITE AT int_for_back ' <- This should be number 1.'.
+
+ SKIP 5.
+
+ WRITE / '****************** READ LINE ******************'.
+ "READ LINE: Assigning the content of a line stored in the
+ "list buffer to the system field sy-lisel. Plus, it allows
+ "other target fields to be specified.
+
+ "In the example, you can provide an integer in an input field
+ "on whose basis a READ LINE statement is executed.
+
+ WRITE / 'Insert a number representing a line number from which to read: '.
+ FORMAT INPUT.
+ WRITE / input_int.
+ linno_int = sy-linno.
+ FORMAT INPUT OFF.
+
+ WRITE / '****************** MODIFY LINE ******************'.
+ "MODIFY LINE: Overwrites a line stored in the list buffer with the
+ "content of the sy-lisel system field Plus, it allows additional
+ "modifications.
+
+ "In the example, you can click 7 times in the very section on whose
+ "basis a MODIFY LINE statement is executed.
+ WRITE / 'Click 7 times on any line in this section starting from "1 A" to explore the effect of MODIFY LINE statements.'.
+
+ SKIP.
+ linno_mod1 = sy-linno.
+ DO 10 TIMES.
+ num += 1.
+ char &&= 'A'.
+ WRITE /10(*) num.
+ WRITE 15 char.
+ ENDDO.
+ linno_mod2 = sy-linno.
+
+**********************************************************************
+
+AT LINE-SELECTION.
+
+ "The purpose of the following implementation is to avoid multiple
+ "details lists when clicking lines.
+
+ IF sy-lsind = 1
+ AND sy-lilli BETWEEN linno_mod1 AND linno_mod2.
+
+ CASE count.
+ WHEN 0.
+ MODIFY CURRENT LINE LINE VALUE FROM 'Overwritten'.
+ WHEN 1.
+ MODIFY CURRENT LINE FIELD VALUE char FROM 'BBBB'.
+ WHEN 2.
+ MODIFY CURRENT LINE FIELD VALUE num FROM '#' char FROM 'CCCC'.
+ WHEN 3.
+ MODIFY CURRENT LINE FIELD FORMAT char COLOR 3.
+ WHEN 4.
+ MODIFY CURRENT LINE LINE FORMAT COLOR 4.
+ WHEN 5.
+ MODIFY CURRENT LINE FIELD FORMAT num COLOR 5 char COLOR 6
+ LINE FORMAT COLOR 7.
+ WHEN 6.
+ linno_copy = linno_mod1.
+ WHILE linno_copy <= linno_mod2.
+ MODIFY LINE linno_copy LINE VALUE FROM ':)' LINE FORMAT COLOR 3.
+ linno_copy += 1.
+ IF sy-index = 11.
+ EXIT.
+ ENDIF.
+ ENDWHILE.
+ WHEN OTHERS.
+ EXIT.
+ ENDCASE.
+ count += 1.
+
+ ELSEIF sy-lsind = 1
+ AND sy-lilli NOT BETWEEN linno_mod1 AND linno_mod2.
+ WRITE / `************************ Information about the line you clicked ************************` COLOR 7 INTENSIFIED OFF.
+ SKIP.
+ WRITE / |Line content (sy-lisel): "{ sy-lisel }"|.
+ WRITE / |Line number (sy-lilli): "{ sy-lilli }"|.
+ SKIP.
+ ULINE.
+ SKIP.
+ WRITE / `************************ HIDE statements ************************` COLOR 7 INTENSIFIED OFF.
+ SKIP.
+
+ IF sy-lilli NOT BETWEEN linno1 + 1 AND linno2.
+ WRITE / |You have clicked on line { sy-lilli } and not on a line between line { linno1 + 1 } and line { linno2 }.|.
+ WRITE / `For exploring the effect of HIDE and displaying the values of 'square' and 'cube', click a line in the HIDE/HOTSPOT section of the basic list.`.
+ ELSE.
+ WRITE: / |square: { square }|.
+ WRITE: / |cube: { cube }|.
+ ENDIF.
+
+ "READ LINE
+ CLEAR str_tab.
+ CLEAR lisel_tab.
+ SKIP.
+ ULINE.
+ SKIP.
+ WRITE / `************************ READ LINE statements ************************` COLOR 7 INTENSIFIED OFF.
+ SKIP.
+
+ READ CURRENT LINE.
+ IF sy-subrc <> 0.
+ lisel_copy = sy-lisel.
+ APPEND VALUE #( statement = |READ CURRENT LINE. (sy-lisel contains line content)| line_content = |ERROR: Line does not exist| ) TO tab.
+ ELSE.
+ lisel_copy = sy-lisel.
+ APPEND VALUE #( statement = |READ CURRENT LINE. (sy-lisel contains line content)| line_content = |sy-lisel: "{ lisel_copy }"| ) TO tab.
+ ENDIF.
+
+ "Put the entire line content (current line) of the read result in a data object
+ READ CURRENT LINE LINE VALUE INTO str.
+ IF sy-subrc <> 0.
+ APPEND VALUE #( statement = `READ CURRENT LINE LINE VALUE INTO ...` line_content = `ERROR: Line does not exist` ) TO tab.
+ ELSE.
+ APPEND VALUE #( statement = `READ CURRENT LINE LINE VALUE INTO ...` line_content = |str: "{ lisel_copy }"| ) TO tab.
+ ENDIF.
+
+ "Specific line
+ TRY.
+ "Put concrete field values (specified line) of the read result in data objects
+ READ LINE linno_int FIELD VALUE input_int INTO var.
+ APPEND VALUE #( statement = |READ LINE { linno_int } FIELD VALUE ... INTO var. (Line of the input field)| line_content = |var: "{ var }"| ) TO tab.
+ int = var.
+
+ "Read entire line content
+ READ LINE int.
+ IF sy-subrc = 0.
+ lisel_copy = sy-lisel.
+ APPEND VALUE #( statement = |READ LINE { int }. (sy-lisel contains line content)| line_content = |sy-lisel: "{ lisel_copy }"| ) TO tab.
+ ELSE.
+ APPEND VALUE #( statement = |READ LINE { int }.| line_content = |ERROR: Line { int } does not exist| ) TO tab.
+ ENDIF.
+ CATCH cx_root.
+ APPEND VALUE #( statement = |READ LINE { var }.| line_content = |ERROR: That statement does not work. Insert an integer value.| ) TO tab.
+ ENDTRY.
+
+ IF tab IS NOT INITIAL.
+ LOOP AT tab INTO li.
+ WRITE: / li-statement COLOR 2,
+ / li-line_content.
+ SKIP.
+ ENDLOOP.
+ ENDIF.
+
+ CLEAR: tab, input, str.
+
+ ULINE.
+ SKIP.
+ WRITE / `************************ MODIFY LINE statements ************************` COLOR 7 INTENSIFIED OFF.
+ SKIP.
+ WRITE / `To explore MODIFY LINE statements, click the lines in the MODIFY LINE section of the basic list.`.
+ SKIP.
+ ENDIF.
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.xml b/src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.xml
new file mode 100644
index 0000000..9913c92
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_lists.prog.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ ZDEMO_ABAP_LISTS
+ S
+ D$
+ 1
+ X
+ D$S
+ X
+
+
+ -
+ R
+ Classic Lists (ABAP Cheat Sheet: Selection Screens/Classic Lists)
+ 65
+
+
+
+
+
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.abap b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.abap
new file mode 100644
index 0000000..cba1d2f
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.abap
@@ -0,0 +1,100 @@
+***********************************************************************
+*
+* ABAP cheat sheet: Selection screens and classic lists
+*
+*
+* -------------------------- PURPOSE ----------------------------------
+* This program can be used for starting the selection screen and
+* classic list programs contained in the repository.
+*
+* ----------------------- GETTING STARTED -----------------------------
+* - Open the program with the ABAP development tools for Eclipse (ADT).
+* - Choose F8 to run the program.
+*
+* ----------------------------- NOTE -----------------------------------
+* The code presented in this class is intended only to support the ABAP
+* cheat sheets. It is not intended for direct use in a production system
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
+* errors or their consequences that may occur when using the the example
+* code.
+*
+***********************************************************************
+
+PROGRAM.
+
+TYPES: BEGIN OF reps_str,
+ number TYPE i,
+ report LIKE sy-repid,
+ END OF reps_str.
+
+DATA: rep LIKE sy-repid,
+ reports TYPE TABLE OF reps_str WITH EMPTY KEY,
+ allowed TYPE string.
+
+SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE title.
+ SELECTION-SCREEN BEGIN OF LINE.
+ SELECTION-SCREEN COMMENT (25) lbl FOR FIELD report.
+ PARAMETERS report TYPE i AS LISTBOX VISIBLE LENGTH 60.
+ SELECTION-SCREEN END OF LINE.
+SELECTION-SCREEN END OF BLOCK bl.
+
+**********************************************************************
+
+INITIALIZATION.
+ title = 'Select and run a program'.
+ lbl = 'Program:'.
+
+ reports = VALUE #(
+ ( number = 1 report = 'ZDEMO_ABAP_SELSCR_PARAMETERS' )
+ ( number = 2 report = 'ZDEMO_ABAP_SELSCR_SELECT_OPT' )
+ ( number = 3 report = 'ZDEMO_ABAP_SELSCR_STANDALONE' )
+ ( number = 4 report = 'ZDEMO_ABAP_SELSCR_STMTS_VAR' )
+ ( number = 5 report = 'ZDEMO_ABAP_LISTS' )
+ ( number = 6 report = 'ZDEMO_ABAP_EVENT_BLOCKS' )
+ ).
+
+**********************************************************************
+
+AT SELECTION-SCREEN OUTPUT.
+ CALL FUNCTION 'VRM_SET_VALUES'
+ EXPORTING
+ id = CONV vrm_id( 'REPORT' )
+ values = VALUE vrm_values(
+ ( key = 1 text = 'Selection screens: PARAMETERS (zdemo_abap_selscr_parameters)' )
+ ( key = 2 text = 'Selection screens: SELECT-OPTIONS (zdemo_abap_selscr_select_opt)' )
+ ( key = 3 text = 'Selection screens: SELECTION-SCREEN (zdemo_abap_selscr_standalone)' )
+ ( key = 4 text = 'Selection screens: SELECTION-SCREEN Variants (zdemo_abap_selscr_stmts_var)' )
+ ( key = 5 text = 'Lists: Creating Lists (zdemo_abap_lists)' )
+ ( key = 6 text = 'Event blocks (zdemo_abap_event_blocks)' ) ).
+
+**********************************************************************
+
+START-OF-SELECTION.
+
+ IF report BETWEEN 1 AND 6.
+ "Dynamic programming check: Only submit program if its name is available
+ "in the allow list
+ TRY.
+ rep = reports[ number = report ]-report.
+ allowed = cl_abap_dyn_prg=>check_whitelist_tab(
+ val = rep
+ whitelist = VALUE #( ( `ZDEMO_ABAP_SELSCR_PARAMETERS` )
+ ( `ZDEMO_ABAP_SELSCR_SELECT_OPT` )
+ ( `ZDEMO_ABAP_SELSCR_STANDALONE` )
+ ( `ZDEMO_ABAP_SELSCR_STMTS_VAR` )
+ ( `ZDEMO_ABAP_LISTS` )
+ ( `ZDEMO_ABAP_EVENT_BLOCKS` ) ) ).
+
+ SUBMIT (rep) AND RETURN VIA SELECTION-SCREEN.
+ CATCH cx_root INTO DATA(err).
+ MESSAGE |Error: { err->get_text( ) }| TYPE 'E'.
+ ENDTRY.
+ ELSE.
+ MESSAGE 'Please select a program.' TYPE 'I' DISPLAY LIKE 'E'.
+ ENDIF.
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.xml b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.xml
new file mode 100644
index 0000000..0c2447b
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_lists_intro.prog.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ ZDEMO_ABAP_SELSCR_LISTS_INTRO
+ S
+ D$
+ 1
+ X
+ D$S
+ X
+
+
+ -
+ R
+ ABAP Cheat Sheet: Selection Screen/Classic List Examples Intro
+ 62
+
+
+
+
+
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.abap b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.abap
new file mode 100644
index 0000000..4db5077
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.abap
@@ -0,0 +1,224 @@
+***********************************************************************
+*
+* ABAP cheat sheet: Selection screens and classic lists
+* Example: PARAMETERS statements
+*
+* -------------------------- PURPOSE ----------------------------------
+* Example that demonstrates PARAMETERS statements in standard selection
+* screens
+*
+* Notes:
+* - A selection of additions is used. For more additions and details,
+* see the ABAP Keyword Documentation.
+* - The MODIF ID addition is possible for PARAMETERS. This is also true
+* for SELECTION-SCREEN statements. See the details in that example.
+* - See the ABAP cheat sheet for other statements used here, for example,
+* the ones related to event blocks such as START-OF-SELECTION.
+*
+* ----------------------- GETTING STARTED -----------------------------
+* - Open the program with the ABAP development tools for Eclipse (ADT).
+* - Choose F8 to run the program.
+*
+* ----------------------------- NOTE -----------------------------------
+* The code presented in this class is intended only to support the ABAP
+* cheat sheets. It is not intended for direct use in a production system
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
+* errors or their consequences that may occur when using the the example
+* code.
+*
+***********************************************************************
+
+PROGRAM.
+
+****************************** Type options ******************************
+
+"Displaying some explanatory text on the standard selection screen
+"The actual text content is assigned to the variable in the INITIALIZATION
+"event block.
+SELECTION-SCREEN COMMENT /1(70) t1.
+
+"Referring to a built-in type with TYPE
+"In this case, a variable length character string can be inserted in the
+"generated input field. Note the LOWER CASE addition further down.
+PARAMETERS p_str TYPE string.
+
+"Referring to an existing data object with the LIKE addition.
+"When referencing to a data type from the ABAP Dictionary after LIKE,
+"you can benefit from things such as input help (if available).
+DATA dobj TYPE i.
+PARAMETERS plikedo LIKE dobj.
+
+"Dynamic spefication of data object in parentheses after LIKE
+"You can reference to a data type from the ABAP Dictionary. some_dobj in
+"the example may be the name of a component of a database table,
+"provided in capital letters.
+DATA some_dobj TYPE c LENGTH 50 VALUE 'ZDEMO_ABAP_CARR-CARRID'.
+PARAMETERS p_dyn LIKE (some_dobj).
+
+"Length specifications
+"Similar to declarations with DATA, the length can be specified for data
+"types with generic length (i.e. the types c, n, p, and x).
+PARAMETERS p_c1 TYPE c LENGTH 1.
+PARAMETERS p_n5 TYPE n LENGTH 5.
+
+"You may also see specifications in which the length is specified in parentheses.
+"For better readability, specifying LENGTH explicitly is recommended.
+PARAMETERS pbracket(2) TYPE c.
+"No length specified means LENGTH 1 by default
+PARAMETERS p_no_len TYPE c.
+"No explicit type specification means TYPE c by default
+PARAMETERS plenonl1(40).
+PARAMETERS plenonl2 LENGTH 40.
+"No explicit type and length specification means TYPE c LENGTH 1 by default
+PARAMETERS pnothing.
+
+****************************** Value options ******************************
+
+SELECTION-SCREEN COMMENT /1(70) t2.
+
+"DEFAULT: Defining a start value (can also be a data object instead of a literal)
+PARAMETERS pdefault TYPE i DEFAULT 12345.
+
+"LOWER CASE: Prevents the effect of capitalizing the entry made when the content
+"is transported to the data object
+PARAMETERS p_upper TYPE string DEFAULT `Hello World`. "Value you insert will be capitalized.
+PARAMETERS p_lower TYPE string DEFAULT `Hello World` LOWER CASE.
+
+"Note: There are more additions available, e.g. for linking the parameter to search help,
+"or checking against fixed values defined in the domain of the data type, and so on.
+"You can also perform your custom input checks in event blocks.
+
+****************************** Screen options ******************************
+
+SELECTION-SCREEN COMMENT /1(70) t3.
+
+"OBLIGATORY: Declaring the input field as a required field
+"If there is no entry, the program cannot proceed when choosing Execute.
+"A message is displayed.
+PARAMETERS p_oblig TYPE string OBLIGATORY.
+
+"NO-DISPLAY: Hiding the input field on the selection screen
+"A value can be supplied when calling the program with SUBMIT and the WITH addition.
+"Note that with the NO-DISPLAY addition, the parameter can have any data types except
+"for reference/enumerated types, unlike in the other additions which require flat
+"types (except type string).
+PARAMETERS p_nodisp TYPE string NO-DISPLAY.
+
+"VISIBLE LENGTH: Defining the visible length of the field
+PARAMETERS p_vislen TYPE c LENGTH 5 VISIBLE LENGTH 3.
+
+"AS CHECKBOX: Displaying input fields as checkbox
+"Type c and length 1 is expected, but the explicit length specification is not allowed.
+"The checkbox is selected if the value has the value X or x.
+PARAMETERS p_check1 AS CHECKBOX. "Implicit type c
+"Explicit type specification (but no explicit length), select by default
+PARAMETERS p_check2 TYPE c AS CHECKBOX DEFAULT 'X'.
+
+"RADIOBUTTON GROUP: Defining a radio button group for parameters
+"Note:
+"- Group name can have a maximum of four characters
+"- Regarding the data type, the same applies as for AS CHECKBOX
+"- Only one parameter can be defined with the DEFAULT addition
+"- If DEFAULT is not specified, the first parameter of the group is set to the value X
+"- You can also use chained statements
+PARAMETERS: p_radio1 RADIOBUTTON GROUP rbgr,
+ p_radio2 TYPE c RADIOBUTTON GROUP rbgr, "Explicit type specification
+ p_radio3 RADIOBUTTON GROUP rbgr DEFAULT 'X'. "Set this radio button as selected
+
+"AS LISTBOX VISIBLE LENGTH: Creating a dropdown list box
+"You can use the function module VRM_SET_VALUES by passing a suitable list at the
+"events AT SELECTION-SCREEN OUTPUT or AT SELECTION-SCREEN ON VALUE-REQUEST.
+PARAMETERS plistbox TYPE i AS LISTBOX VISIBLE LENGTH 10 OBLIGATORY.
+
+*********************** Assigning function codes ***********************
+
+"The AS CHECKBOX, RADIOBUTTON GROUP, AS LISTBOX additions can be combined
+"with the addition USER-COMMAND. That means, on selection, the event
+"AT SELECTION-SCREEN is raised and you can evaluate the function code there.
+"Note: To enable it, include the statement 'TABLES sscrfields.' in the code.
+"When the button is clicked, the event AT SELECTION-SCREEN is raised and the
+"function code ('cmd', 'rbcm' in the example) is passed to the 'ucomm' component
+"in the interface work area 'sscrfields' which can be evaluated and reacted upon
+"accordingly.
+"Before exploring the effect in the example, make entries for the
+"obligatory input fields first, then choose the checkbox/radio buttons.
+
+SELECTION-SCREEN COMMENT /1(70) t4.
+
+TABLES sscrfields.
+PARAMETERS pchckcmd AS CHECKBOX USER-COMMAND cmd.
+PARAMETERS: prad1cmd RADIOBUTTON GROUP grp USER-COMMAND rbcm,
+ prad2cmd RADIOBUTTON GROUP grp.
+
+**********************************************************************
+INITIALIZATION.
+
+ t1 = 'PARAMETERS: Demonstrating various type options:'.
+ t2 = 'Demonstrating value options:'.
+ t3 = 'Demonstrating screen options:'.
+ t4 = 'Click these screen elements to explore the USER-COMMAND addition.'.
+
+**********************************************************************
+
+AT SELECTION-SCREEN.
+
+ CASE sscrfields-ucomm.
+ WHEN 'CMD'.
+ MESSAGE |Hallo { sy-uname }.| TYPE 'I'.
+ WHEN 'RBCM'.
+ MESSAGE |Today's date: { sy-datum DATE = ISO }| TYPE 'I'.
+ ENDCASE.
+
+**********************************************************************
+
+AT SELECTION-SCREEN OUTPUT.
+
+ "This is relevant for the AS LISTBOX VISIBLE LENGTH addition.
+ "Note:
+ "- The function module VRM_SET_VALUES is used
+ "- Column TEXT: What is displayed in the list box
+ "- Colum KEY: When a line is selected, the KEY value is added to the
+ " parameter
+ "In the example, the numbers 1 - 10 are added as values.
+ CALL FUNCTION 'VRM_SET_VALUES'
+ EXPORTING
+ id = CONV vrm_id( 'PLISTBOX' )
+ values = VALUE vrm_values(
+ FOR i = 1 UNTIL i > 10
+ ( key = i text = |Value { i }| ) ).
+
+**********************************************************************
+
+START-OF-SELECTION.
+
+ "Creating a classic list
+ WRITE / `This list displays the values provided on the selection screen.`.
+ SKIP.
+ WRITE / |p_str: "{ p_str }"| .
+ WRITE / |plikedo: "{ plikedo }"| .
+ WRITE / |p_dyn: "{ p_dyn }"| .
+ WRITE / |p_c1: "{ p_c1 }"| .
+ WRITE / |p_n5: "{ p_n5 }"| .
+ WRITE / |pbracket: "{ pbracket }"| .
+ WRITE / |p_no_len: "{ p_no_len }"| .
+ WRITE / |plenonl1: "{ plenonl1 }"| .
+ WRITE / |plenonl2: "{ plenonl2 }"| .
+ WRITE / |pnothing: "{ pnothing }"| .
+ WRITE / |pdefault: "{ pdefault }"| .
+ WRITE / |p_upper: "{ p_upper }"| .
+ WRITE / |p_lower: "{ p_lower }"| .
+ WRITE / |p_oblig: "{ p_oblig }"| .
+ WRITE / |p_nodisp: "{ p_nodisp }"| .
+ WRITE / |p_vislen: "{ p_vislen }"| .
+ WRITE / |p_check1: "{ p_check1 }"| .
+ WRITE / |p_check2: "{ p_check2 }"| .
+ WRITE / |Radio button selected: "{ COND #( WHEN p_radio1 = 'X' THEN 'p_radio1' WHEN p_radio2 = 'X' THEN 'p_radio2' ELSE 'p_radio3' ) }"| .
+ WRITE / |plistbox: "{ plistbox }"| .
+ WRITE / |pchckcmd: "{ pchckcmd }"| .
+ WRITE / |Radio button selected: "{ COND #( WHEN prad1cmd = 'X' THEN 'prad1cmd' ELSE 'prad2cmd' ) }"| .
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.xml b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.xml
new file mode 100644
index 0000000..39c2b9a
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_parameters.prog.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ ZDEMO_ABAP_SELSCR_PARAMETERS
+ S
+ D$
+ 1
+ X
+ D$S
+ X
+
+
+ -
+ R
+ PARAMETERS (ABAP Cheat Sheet: Selection Screens/Classic Lists)
+ 62
+
+
+
+
+
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.abap b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.abap
new file mode 100644
index 0000000..b38b0c5
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.abap
@@ -0,0 +1,142 @@
+***********************************************************************
+*
+* ABAP cheat sheet: Selection screens and classic lists
+* Example: SELECT-OPTIONS statements
+*
+* -------------------------- PURPOSE ----------------------------------
+* Example that demonstrates SELECT-OPTIONS statements in standard
+* selection screens
+*
+* Notes:
+* - A selection of additions is used. For more additions and details,
+* see the ABAP Keyword Documentation.
+* - See the ABAP cheat sheet for other statements used here, for example,
+* the ones related to event blocks such as START-OF-SELECTION.
+*
+* ----------------------- GETTING STARTED -----------------------------
+* - Open the program with the ABAP development tools for Eclipse (ADT).
+* - Choose F8 to run the program.
+*
+* ----------------------------- NOTE -----------------------------------
+* The code presented in this class is intended only to support the ABAP
+* cheat sheets. It is not intended for direct use in a production system
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
+* errors or their consequences that may occur when using the the example
+* code.
+*
+***********************************************************************
+
+PROGRAM.
+
+DATA int TYPE i.
+DATA int_tab TYPE TABLE OF i WITH EMPTY KEY.
+DATA selcriteria TYPE string_table.
+DATA str TYPE string.
+FIELD-SYMBOLS TYPE ANY TABLE.
+
+"SELECT-OPTIONS statements demonstrating various additions
+
+"The following statement creates two input fields that can be
+"used to specify selection criteria on the selection screen.
+"In addition, the Multiple Selection button is available to
+"further specify the selection criteria, e.g. what to include,
+"exclude, etc.. As in all examples, an internal table of type
+"TYPE RANGE OF whose contents can be evaluated.
+"The FOR addition is followed by an already declared data object.
+SELECT-OPTIONS a FOR int.
+
+"NO-DISPLAY: Hides
+SELECT-OPTIONS b FOR int NO-DISPLAY.
+
+"NO-EXTENSION: The Multiple Selection button is not created on
+"the selection screen
+SELECT-OPTIONS c FOR int NO-EXTENSION.
+
+"NO INTERVALS: Only one input field. Intervals can still be
+"selected using the Multiple Selection button.
+SELECT-OPTIONS d FOR int NO INTERVALS.
+
+"Additions can be combined
+SELECT-OPTIONS e FOR int NO-EXTENSION NO INTERVALS.
+
+"DEFAULT ... TO ...: Providing start values for the columns in
+"the first line of the selection table (low and high values)
+SELECT-OPTIONS f FOR int NO-EXTENSION DEFAULT 3 TO 10.
+SELECT-OPTIONS g FOR int DEFAULT 5 TO 9.
+
+"DEFAULT ... OPTION ... SIGN ...: Providing further start values.
+"See the details in the ABAP cheat sheet.
+SELECT-OPTIONS h FOR int DEFAULT 4 TO 8 OPTION NB SIGN I.
+
+**********************************************************************
+
+INITIALIZATION.
+
+ "Providing start values for data objects
+ "The following internal table is filled and used as a data source
+ "for a SELECT statement.
+ int_tab = VALUE #( FOR i = 1 UNTIL i > 20 ( i ) ).
+ "This table is filled here with the names from above. The table is looped
+ "over in the START-OF-SELECTION event block to cover all SELECT-OPTIONS
+ "from above.
+ selcriteria = VALUE #( ( `A` ) ( `B` ) ( `C` ) ( `D` )
+ ( `E` ) ( `F` ) ( `G` ) ( `H` ) ).
+
+**********************************************************************
+
+START-OF-SELECTION.
+
+ "Creating a classic list
+ WRITE / `Data was retrieved from an internal table using a SELECT statement based on selection criteria.`.
+ WRITE / `The table has the following content:`.
+
+ LOOP AT int_tab INTO int.
+ WRITE |{ int }|.
+ ENDLOOP.
+ SKIP 2.
+
+ LOOP AT selcriteria INTO str.
+ CASE str.
+ "For historical reasons, the selection table is a table with header line.
+ "Therefore, if you want to address the table content (beyond the use in a
+ "SELECT ... WHERE ... IN ... statement), use the syntax `...[]`.
+ WHEN `A`.
+ ASSIGN a[] TO .
+ WHEN `B`.
+ ASSIGN b[] TO .
+ WHEN `C`.
+ ASSIGN c[] TO .
+ WHEN `D`.
+ ASSIGN d[] TO .
+ WHEN `E`.
+ ASSIGN e[] TO .
+ WHEN `F`.
+ ASSIGN f[] TO .
+ WHEN `G`.
+ ASSIGN g[] TO .
+ WHEN `H`.
+ ASSIGN h[] TO .
+ ENDCASE.
+
+ WRITE / |Result for selection options specified for "{ str }":| COLOR 2.
+ SKIP.
+
+ SELECT *
+ FROM @int_tab AS tab
+ WHERE table_line IN @
+ INTO @int.
+ WRITE |{ int }|.
+ ENDSELECT.
+
+ IF IS INITIAL.
+ WRITE `(No selection criteria were provided. Therefore, all table lines are respected.)`.
+ ENDIF.
+
+ SKIP.
+ ENDLOOP.
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.xml b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.xml
new file mode 100644
index 0000000..e0811ed
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_select_opt.prog.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ ZDEMO_ABAP_SELSCR_SELECT_OPT
+ S
+ D$
+ 1
+ X
+ D$S
+ X
+
+
+ -
+ R
+ SELECT-OPTIONS (ABAP Cheat Sheet: Selection Screens/Classic Lists)
+ 66
+
+
+
+
+
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.abap b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.abap
new file mode 100644
index 0000000..d78ce63
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.abap
@@ -0,0 +1,218 @@
+***********************************************************************
+*
+* ABAP cheat sheet: Selection screens and classic lists
+* Example: Creating standalone selection screens
+*
+* -------------------------- PURPOSE ----------------------------------
+* - Example that demonstrates standalone selection screens
+* - In the example, calculations are performed based on user input.
+* Includes:
+* - Creating selection screens as regular dynpros with
+* SELECTION-SCREEN BEGIN/END OF SCREEN ... statements
+* - Creating selection screens as subscreen dynpros with the AS SUBSCREEN
+* addition
+* - Calling standalone selection screen with CALL SELECTION-SCREEN
+* statements
+* - Using variants of the SELECTION-SCREEN statements that do not create
+* selection screens, but are used to modify the layout
+* - INCLUDE addition for reusing already created elements
+*
+* Notes:
+* - A selection of additions is used. For more additions and details,
+* see the ABAP Keyword Documentation.
+* - See the ABAP cheat sheet for other statements used here, for example,
+* the ones related to event blocks such as START-OF-SELECTION.
+*
+* ----------------------- GETTING STARTED -----------------------------
+* - Open the program with the ABAP development tools for Eclipse (ADT).
+* - Choose F8 to run the program.
+*
+* ----------------------------- NOTE -----------------------------------
+* The code presented in this class is intended only to support the ABAP
+* cheat sheets. It is not intended for direct use in a production system
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
+* errors or their consequences that may occur when using the the example
+* code.
+*
+***********************************************************************
+
+PROGRAM.
+
+"Creating standalone selection screens as regular dynpros
+"The dynpro number must be unique in the program. Do not use 1000.
+SELECTION-SCREEN BEGIN OF SCREEN 9810.
+ "Here go all PARAMETERS, SELECT-OPTIONS, and SELECTION-SCREEN statements
+ "to define the screen elements of the standalone selection screen.
+ SELECTION-SCREEN COMMENT /1(70) t1.
+ PARAMETERS number1 TYPE i OBLIGATORY.
+SELECTION-SCREEN END OF SCREEN 9810.
+
+"AS WINDOW/TITLE: The following selection screen is displayed in a modal
+"dialog box. Plus, a title is specified.
+SELECTION-SCREEN BEGIN OF SCREEN 9820 TITLE title1 AS WINDOW.
+ SELECTION-SCREEN COMMENT /1(70) t2.
+ PARAMETERS number2 TYPE i OBLIGATORY.
+SELECTION-SCREEN END OF SCREEN 9820.
+
+"Creating a standalone selection screens as subscreen dynpro
+"They can be included in other dynpros or selection screens, or in
+"subscreen areas or tab pages. The following example covers the latter.
+"Note: The selection screens as subscreen dynpros cannot be called
+"explicitly.
+
+"The following two selection screens are included in tab pages
+"further down.
+SELECTION-SCREEN BEGIN OF SCREEN 9830 AS SUBSCREEN.
+ PARAMETERS: number3 TYPE i OBLIGATORY,
+ number4 TYPE i OBLIGATORY.
+SELECTION-SCREEN END OF SCREEN 9830.
+
+SELECTION-SCREEN BEGIN OF SCREEN 9840 AS SUBSCREEN.
+ PARAMETERS: plus AS CHECKBOX DEFAULT 'X',
+ minus AS CHECKBOX DEFAULT 'X',
+ multiply AS CHECKBOX DEFAULT 'X',
+ divide AS CHECKBOX DEFAULT 'X'.
+SELECTION-SCREEN END OF SCREEN 9840.
+
+"The following selection screen (as regular dynpro) is created
+"as dummy, i.e. it is not included as the ones above. It is
+"used to demonstrate the INCLUDE addition.
+SELECTION-SCREEN BEGIN OF SCREEN 9850.
+ SELECTION-SCREEN COMMENT /1(50) t3.
+SELECTION-SCREEN END OF SCREEN 9850.
+
+"The following declaration is required in the context of the
+"TABBED BLOCK addition.
+TABLES sscrfields.
+
+"The following selection screen (as regular dynpro) is created to
+"demonstrate ...
+"- the use of subscreen dynpros. In this case, the subscreen dynpros
+" are used in the context of tab pages (TABBED BLOCK, TAB additions).
+"- the reuse of available screen elements in the program using the
+" INCLUDE addition.
+SELECTION-SCREEN BEGIN OF SCREEN 9860 TITLE title2.
+ SELECTION-SCREEN INCLUDE COMMENT /1(70) t3. "Reusing a screen element
+ SELECTION-SCREEN: BEGIN OF TABBED BLOCK tabs FOR 10 LINES,
+ "In such a TABBED BLOCK statement, only TAB statements are allowed
+ "to include subscreen dynpros.
+ "The USER-COMMAND addition specifies a function code. If a tab is
+ "selected by users, the function code can be evaluated using the the
+ "component ucomm of the structure sscrfields after the
+ "AT SELECTION-SCREEN event.
+ TAB (20) btn_nums USER-COMMAND uc_num,
+ TAB (20) btn_op USER-COMMAND uc_op,
+ END OF BLOCK tabs.
+SELECTION-SCREEN END OF SCREEN 9860.
+
+**********************************************************************
+
+INITIALIZATION.
+ title1 = 'First calculation'.
+ title2 = 'Second calculation'.
+ t1 = 'Insert an integer value for the first calculation.'.
+ t2 = 'Provide the second number for the first calculation.'.
+ t3 = 'Make entries in the tabs for the second calculation.'.
+ btn_nums = 'Numbers'.
+ btn_op = 'Operators'.
+
+ "Instead of the following assignements, you can also use the DEFAULT,
+ "SCREEN, PROGRAM additions of the ... TAB ... statement
+ tabs-prog = sy-repid.
+ tabs-dynnr = 9830.
+ tabs-activetab = 'UC_NUM'.
+
+**********************************************************************
+
+AT SELECTION-SCREEN.
+ CASE sy-dynnr.
+ WHEN 9860.
+ CASE sscrfields-ucomm.
+ WHEN 'UC_NUM'.
+ tabs-dynnr = 9830.
+ WHEN 'UC_OP'.
+ tabs-dynnr = 9840.
+ ENDCASE.
+ ENDCASE.
+
+**********************************************************************
+
+START-OF-SELECTION.
+
+ "The following statements call the selection screens.
+ CALL SELECTION-SCREEN 9810.
+
+ IF sy-subrc = 0.
+ "STARTING AT: Specifies that the selection screen is displayed as a
+ "modal dialog box.
+ CALL SELECTION-SCREEN 9820 STARTING AT 10 10.
+ ENDIF.
+
+ IF sy-subrc = 0.
+ CALL SELECTION-SCREEN 9860.
+ ENDIF.
+
+ IF sy-subrc = 0.
+ "Creating a classic list
+ WRITE / |Results of the first calculation using the provided numbers { number1 } and { number2 } (all basic arithmetic operations):| COLOR COL_POSITIVE.
+ WRITE / |{ number1 } + { number2 } = { number1 + number2 }|.
+ WRITE / |{ number1 } - { number2 } = { number1 - number2 }|.
+
+ TRY.
+ WRITE / |{ number1 } * { number2 } = { number1 * number2 }|.
+ CATCH cx_sy_arithmetic_error INTO DATA(error).
+ WRITE / |{ number1 } * { number2 } = ??? Error in multiplication: { error->get_text( ) }| COLOR COL_NEGATIVE.
+ ENDTRY.
+
+ TRY.
+ WRITE / |{ number1 } / { number2 } = { CONV decfloat34( number1 / number2 ) DECIMALS = 3 }|.
+ IF number1 = 0 AND number2 = 0.
+ WRITE / `No zero division error? Note that ABAP "allows" zero division if the first number is also 0 :)` COLOR COL_NEGATIVE.
+ ENDIF.
+ CATCH cx_sy_zerodivide INTO error.
+ WRITE / |{ number1 } / { number2 } = ??? Error in division: { error->get_text( ) }| COLOR COL_NEGATIVE.
+ ENDTRY.
+
+ SKIP 2.
+ WRITE / |Results of the second calculation using the provided numbers { number3 } and { number4 } (selected basic arithmetic operations):| COLOR COL_POSITIVE.
+
+ IF plus IS INITIAL
+ AND minus IS INITIAL
+ AND multiply IS INITIAL
+ AND divide IS INITIAL.
+ WRITE / 'You did not select any operators from the tab. No calculation was performed.' COLOR COL_NEGATIVE.
+ ELSE.
+ IF plus = 'X'.
+ WRITE / |{ number3 } + { number4 } = { number3 + number4 }|.
+ ENDIF.
+
+ IF minus = 'X'.
+ WRITE / |{ number3 } - { number4 } = { number3 - number4 }|.
+ ENDIF.
+
+ IF multiply = 'X'.
+ TRY.
+ WRITE / |{ number3 } * { number4 } = { number3 * number4 }|.
+ CATCH cx_sy_arithmetic_error INTO error.
+ WRITE / |{ number3 } * { number4 } = ??? Error in multiplication: { error->get_text( ) }| COLOR COL_NEGATIVE.
+ ENDTRY.
+ ENDIF.
+
+ IF divide = 'X'.
+ TRY.
+ WRITE / |{ number3 } / { number4 } = { CONV decfloat34( number3 / number4 ) DECIMALS = 3 }|.
+ IF number3 = 0 AND number4 = 0.
+ WRITE / `No zero division error? Note that ABAP "allows" zero division if the first number is also 0 :)` COLOR COL_NEGATIVE.
+ ENDIF.
+ CATCH cx_sy_zerodivide INTO error.
+ WRITE / |{ number3 } / { number4 } = ??? Error in division: { error->get_text( ) }| COLOR COL_NEGATIVE.
+ ENDTRY.
+ ENDIF.
+ ENDIF.
+ ENDIF.
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.xml b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.xml
new file mode 100644
index 0000000..2f035d0
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_standalone.prog.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ ZDEMO_ABAP_SELSCR_STANDALONE
+ S
+ D$
+ 1
+ X
+ D$S
+ X
+
+
+ -
+ R
+ Standalone selection screens (ABAP cheat sheet)
+ 47
+
+
+
+
+
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.abap b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.abap
new file mode 100644
index 0000000..88d2271
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.abap
@@ -0,0 +1,263 @@
+***********************************************************************
+*
+* ABAP cheat sheet: Selection screens and classic lists
+* Example: Variants of SELECTION-SCREEN statements
+*
+* -------------------------- PURPOSE ----------------------------------
+* Example that demonstrates variants of the SELECTION-SCREEN statements
+* to modify the layout, create additional screen elements etc.
+* Includes:
+* - Adding blank lines (SKIP)
+* - Creating a horizontal line (ULINE)
+* - Providing text (COMMENT)
+* - Creating a pushbutton (PUSHBUTTON)
+* - Specifying the output position of a screen element (POSITION)
+* - Defining a new line with multiple elements (BEGIN OF LINE)
+* - Creating blocks (BLOCK)
+* - Creating tabbed blocks (TABBED BLOCK/TAB)
+* - Assigning a screen element to a modification group (MODIF ID)
+* - Adding pushbuttons in the application toolbar (FUNCTION KEY)
+*
+* Notes:
+* - A selection of additions is used. For more additions and details,
+* see the ABAP Keyword Documentation.
+* - See the ABAP cheat sheet for other statements used here, for example,
+* the ones related to event blocks such as START-OF-SELECTION.
+*
+* ----------------------- GETTING STARTED -----------------------------
+* - Open the program with the ABAP development tools for Eclipse (ADT).
+* - Choose F8 to run the program.
+*
+* ----------------------------- NOTE -----------------------------------
+* The code presented in this class is intended only to support the ABAP
+* cheat sheets. It is not intended for direct use in a production system
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
+* errors or their consequences that may occur when using the the example
+* code.
+*
+***********************************************************************
+
+PROGRAM.
+
+"The following declaration is required in the context of the
+"TABBED BLOCK, FUNCTION KEY, and USER-COMMAND additions.
+TABLES sscrfields.
+
+"Creating blocks (BLOCK)
+"The WITH FRAME additions draws a frame around a block.
+"Note that the block must be ended with a ... END OF BLOCK ... statement.
+SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.
+ "Providing text (COMMENT)
+ SELECTION-SCREEN COMMENT /30(70) t1.
+ "Assigning a screen element to a modification group (MODIF ID)
+ "An identifier can be specified to assign a screen element to a
+ "modification group. This identifier is assigned to the component
+ "'group1' of the SCREEN structure. Using MODIFY SCREEN statements,
+ "the elements can be modified before displaying
+ "in the AT SELECTION-SCREEN OUTPUT event block.
+ "Note: The additions is possible for PARAMETERS, SELECT-OPTIONS
+ "and SELECTION-SCREEN.
+ PARAMETERS my_name LIKE sy-uname MODIF ID nd.
+
+ "Adding blank lines (SKIP)
+ "Just SKIP, no further addition means it skips one line.
+ SELECTION-SCREEN SKIP.
+ PARAMETERS sap_rel LIKE sy-saprl MODIF ID nd.
+
+ "Specifying the number of blank lines
+ SELECTION-SCREEN SKIP 2.
+ "Creating a horizontal line (ULINE)
+ SELECTION-SCREEN ULINE /10(40).
+ PARAMETERS random_i TYPE i MODIF ID nd.
+SELECTION-SCREEN END OF BLOCK block1.
+
+SELECTION-SCREEN ULINE.
+SELECTION-SCREEN SKIP.
+
+"Defining a new line with multiple elements (BEGIN OF LINE)
+"Chained statements are handy.
+SELECTION-SCREEN: BEGIN OF LINE,
+"Specifying the output position of a screen element (POSITION)
+"Only possible within BEGIN/END OF LINE
+POSITION 2,
+PUSHBUTTON (5) btn1 USER-COMMAND btn_1,
+POSITION 9,
+COMMENT (25) t2,
+POSITION 35,
+PUSHBUTTON (5) btn2 USER-COMMAND btn_2,
+POSITION 42,
+COMMENT (25) t3,
+END OF LINE.
+SELECTION-SCREEN SKIP.
+
+"Radio buttons in a block with a frame and title
+SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE title1.
+ SELECTION-SCREEN BEGIN OF LINE.
+ PARAMETERS: rb1 RADIOBUTTON GROUP grp.
+ SELECTION-SCREEN COMMENT (20) text1.
+ SELECTION-SCREEN END OF LINE.
+ SELECTION-SCREEN BEGIN OF LINE.
+ PARAMETERS: rb2 RADIOBUTTON GROUP grp.
+ SELECTION-SCREEN COMMENT (20) text2.
+ SELECTION-SCREEN END OF LINE.
+SELECTION-SCREEN END OF BLOCK block2.
+
+SELECTION-SCREEN SKIP.
+
+"Further statements with the MODIF ID addition
+
+"The layout of the following screen element should be modified
+"using the specified ID.
+"Note: Outside of BEGIN/END OF LINE statements, the specified
+"format must contain one position (/...)
+SELECTION-SCREEN COMMENT /10(70) t4 MODIF ID mod.
+
+SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME.
+ "The layout of the following screen elements should be modified
+ "using the specified ID.
+ PARAMETERS: pa1 RADIOBUTTON GROUP gr MODIF ID mbl,
+ pa2 RADIOBUTTON GROUP gr MODIF ID mbl,
+ pa3 RADIOBUTTON GROUP gr,
+ pa4 RADIOBUTTON GROUP gr.
+SELECTION-SCREEN END OF BLOCK bl.
+
+"Creating tabbed blocks (TABBED BLOCK/TAB)
+
+"Creating standalone selection screens as subscreen dynpros
+"They can be included in other dynpros or selection screens, or in
+"subscreen areas or tab pages. This example covers the latter.
+SELECTION-SCREEN BEGIN OF SCREEN 9990 AS SUBSCREEN.
+ PARAMETERS: par_sub1 TYPE c LENGTH 10 LOWER CASE.
+SELECTION-SCREEN END OF SCREEN 9990.
+
+SELECTION-SCREEN BEGIN OF SCREEN 9991 AS SUBSCREEN.
+ PARAMETERS: par_sub2 TYPE c LENGTH 10 LOWER CASE.
+SELECTION-SCREEN END OF SCREEN 9991.
+
+SELECTION-SCREEN: BEGIN OF TABBED BLOCK tabs FOR 2 LINES,
+"The USER-COMMAND addition specifies a function code.
+"If a tab is selected by users, the function code can
+"be evaluated using the the component ucomm of the structure
+"sscrfields after the AT SELECTION-SCREEN event.
+TAB (20) tabtitl1 USER-COMMAND tab1,
+TAB (20) tabtitl2 USER-COMMAND tab2,
+END OF BLOCK tabs.
+
+"Adding pushbuttons in the application toolbar (FUNCTION KEY)
+"There are five inactive pushbuttons to which the function codes FC01, FC02
+"up to FC05 are assigned. The ... FUNCTION KEY ... statement activates the
+"pushbuttons for the specified codes.
+"Note: To enable it, include the statement 'TABLES sscrfields.' in the code.
+"When the button is clicked, the event AT SELECTION-SCREEN is raised and the
+"function code is passed to the 'ucomm' component in the interface
+"work area 'sscrfields' which can be evaluated and reacted upon accordingly,
+"e.g. in a CASE control structure.
+SELECTION-SCREEN: FUNCTION KEY 1, "Stands for FC01
+FUNCTION KEY 2, "FC02
+FUNCTION KEY 3, "FC03
+FUNCTION KEY 4. "FC04
+
+**********************************************************************
+
+INITIALIZATION.
+ title1 = 'Block including radio buttons + comments put in one line using BEGIN/END OF LINE'.
+ t1 = 'This is a selection screen comment included in a block with frame.'.
+ t2 = '<- Click to get the time'.
+ t3 = '<- Click to get the date'.
+ t4 = 'This text and the following radio button group was modified.'.
+ text1 = 'Radio button A'.
+ text2 = 'Radio button B'.
+ btn1 = 'A'.
+ btn2 = 'B'.
+ "Relevant to the tabbed blocks
+ tabtitl1 = 'Selection Screen A'.
+ tabtitl2 = 'Selection Screen B'.
+ tabs-prog = sy-repid.
+ tabs-dynnr = 9990.
+ tabs-activetab = 'TAB1'.
+ "Relevant to the function keys
+ "To provide text for the buttons, assign values to the component functxt_0n
+ "(while n stands for the numbers 1 - 5). Otherwise, there won't be any button
+ "text.
+ sscrfields-functxt_01 = 'Get my name'.
+ sscrfields-functxt_02 = 'Get ABAP release'.
+ sscrfields-functxt_03 = 'Get random integer'.
+ sscrfields-functxt_04 = 'Clear input fields'.
+
+**********************************************************************
+
+AT SELECTION-SCREEN OUTPUT.
+
+ "Modifying the layout of screen elements
+ LOOP AT SCREEN INTO DATA(wa).
+ IF wa-group1 = 'MOD'.
+ "Intensify the text output
+ wa-intensified = '1'.
+ MODIFY SCREEN FROM wa.
+ ENDIF.
+
+ IF wa-group1 = 'MBL'.
+ "Make the screen element invisible
+ wa-invisible = '1'.
+ MODIFY SCREEN FROM wa.
+ ENDIF.
+
+ IF wa-group1 = 'ND'.
+ "Disable the input for a field
+ wa-input = '0'.
+ MODIFY SCREEN FROM wa.
+ ENDIF.
+ ENDLOOP.
+
+**********************************************************************
+
+AT SELECTION-SCREEN.
+
+ "Evaluating the function codes relevant to the
+ "TABBED BLOCK, FUNCTION KEY, and USER-COMMAND additions.
+
+ "Evaluating only if sy-dynnr has the value of the standard selection
+ "screen
+ CHECK sy-dynnr = 1000.
+
+ CASE sscrfields-ucomm.
+ WHEN 'FC01'.
+ my_name = sy-uname.
+ WHEN 'FC02'.
+ sap_rel = sy-saprl.
+ WHEN 'FC03'.
+ random_i = cl_abap_random_int=>create(
+ seed = cl_abap_random=>seed( ) min = 1
+ max = 100 )->get_next( ).
+ WHEN 'FC04'.
+ CLEAR: my_name, sap_rel, random_i, par_sub1, par_sub2.
+ WHEN 'BTN_1'.
+ MESSAGE |You clicked button A. The time is { sy-uzeit TIME = ISO }.| TYPE 'I'.
+ WHEN 'BTN_2'.
+ MESSAGE |You clicked button B. The date is { sy-datum DATE = ISO }.| TYPE 'I'.
+ WHEN 'TAB1'.
+ tabs-dynnr = 9990.
+ WHEN 'TAB2'.
+ tabs-dynnr = 9991.
+ ENDCASE.
+
+**********************************************************************
+
+START-OF-SELECTION.
+
+ "Creating a classic list
+ WRITE / `This list displays the values provided on the selection screen.`.
+ SKIP.
+ WRITE / |my_name: "{ my_name }"|.
+ WRITE / |sap_rel: "{ sap_rel }"|.
+ WRITE / |random_i: "{ random_i }"|.
+ WRITE / |Radio button selected (1): "{ COND #( WHEN rb1 = 'X' THEN 'rb1' ELSE 'rb2' ) }"| .
+ WRITE / |Radio button selected (2): "{ COND #( WHEN pa1 = 'X' THEN 'pa1' WHEN pa2 = 'X' THEN 'pa2' WHEN pa3 = 'X' THEN 'pa3' ELSE 'pa4' ) }"| .
+ WRITE / |par_sub1: "{ par_sub1 }"|.
+ WRITE / |par_sub2: "{ par_sub2 }"|.
diff --git a/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.xml b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.xml
new file mode 100644
index 0000000..52c6b97
--- /dev/null
+++ b/src/test_abap_cheat_sheets_classic/zdemo_abap_selscr_stmts_var.prog.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ ZDEMO_ABAP_SELSCR_STMTS_VAR
+ S
+ D$
+ 1
+ X
+ D$S
+ X
+
+
+ -
+ R
+ Variants of SELECTION-SCREEN statements (ABAP cheat sheet)
+ 58
+
+
+
+
+