REPORT ZMAIN .
************************************************************************
* This program implements a self-programmed value help for F4.
* When F4 or the down arrow is pressed, a custom list pops up
* with the selectable values.
* This method does not require help-view, check table or
* or matchcode. We can also avoid the programming of a more
* complex transaction with PROCESS ON VALUE-REQUEST in the flow
* logic. Furthermore, the help values can be anything (not only
* values from tables linked with foreign keys)
************************************************************************
DATA: BEGIN OF FIELDS OCCURS 10.
        INCLUDE STRUCTURE HELP_VALUE.
DATA: END OF FIELDS.
DATA: BEGIN OF VALUETAB OCCURS 10,
        LINE(80),
END OF VALUETAB.
* ZTSTSTRC: a custom structure defined in the data dictionary:
* field    data_element   type   length
* NAME      CHAR0008      CHAR      8
* FLAG      CHAR0001      CHAR      1
* TEXT      CHAR012       CHAR     12
TABLES: ZTSTSTRC.
* Display the selection screen
SELECTION-SCREEN BEGIN OF BLOCK BL1.
PARAMETERS: A LIKE ZTSTSTRC-NAME.
SELECTION-SCREEN END OF BLOCK BL1.
* Value list requested (F4 or click on the arrow)
AT SELECTION-SCREEN ON VALUE-REQUEST FOR A.
  CLEAR FIELDS. REFRESH FIELDS.
  CLEAR VALUETAB. REFRESH VALUETAB.
* Fill the structure table
  FIELDS-TABNAME = 'ZTSTSTRC'.
  FIELDS-FIELDNAME = 'NAME'.
  FIELDS-SELECTFLAG = 'X'.
  APPEND FIELDS. CLEAR FIELDS.
  FIELDS-TABNAME = 'ZTSTSTRC'.
  FIELDS-FIELDNAME = 'FLAG'.
  APPEND FIELDS. CLEAR FIELDS.
  FIELDS-TABNAME = 'ZTSTSTRC'.
  FIELDS-FIELDNAME = 'TEXT'.
  APPEND FIELDS. CLEAR FIELDS.
* Fill the value table
  VALUETAB-LINE = 'aaa'. APPEND VALUETAB.
  VALUETAB-LINE = 'b'. APPEND VALUETAB.
  VALUETAB-LINE = 'ccc'. APPEND VALUETAB.
  VALUETAB-LINE = 'ddd'. APPEND VALUETAB.
  VALUETAB-LINE = 'e'. APPEND VALUETAB.
  VALUETAB-LINE = 'fff'. APPEND VALUETAB.
  VALUETAB-LINE = 'ggg'. APPEND VALUETAB.
  VALUETAB-LINE = 'h'. APPEND VALUETAB.
  VALUETAB-LINE = 'iii'. APPEND VALUETAB.
* Call the help value screen
  CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
  EXPORTING
*              cucol = 10
*              curow = 10
               TITLE_IN_VALUES_LIST = 'List header line'
               TITEL = 'Window title'
  IMPORTING
                SELECT_VALUE  = A
  TABLES
                FIELDS   = FIELDS
                VALUETAB = VALUETAB.