1

I have the following program.

REPORT zz_tab_strip_obligatory.

SELECTION-SCREEN BEGIN OF TABBED BLOCK tab FOR 20 LINES.
SELECTION-SCREEN TAB (54) tab1 USER-COMMAND tab1 DEFAULT SCREEN 100.
SELECTION-SCREEN TAB (54) tab2 USER-COMMAND tab2 DEFAULT SCREEN 200.
SELECTION-SCREEN END OF BLOCK tab.

SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
PARAMETERS:
  p1 TYPE i.
SELECTION-SCREEN END OF SCREEN 100.

SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
PARAMETERS:
  p2 TYPE i OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 200.

INITIALIZATION.
  tab1 = 'Tab1'.
  tab2 = 'Tab2'.

The first tab has no obligatory fields. The second one on the other hand does.

The problem I am having is that if the user does not go to the second tab and instead of it starts the program immediately with F8 then the obligatory check for the parameters p2 is not performed at all. It looks like all of the events like AT SELECTION-SCREEN are executed only for the current tab ergo for the displayed subscreen.

Is there any way to work around it? My current solution right now is sadly getting rid of OBLIGATORY keywords and making the checks after START-OF-SELECTION (my real program has many tabs).

Jagger
  • 10,350
  • 9
  • 51
  • 93

1 Answers1

1

I do not think there is a direct solution to the selection screen obligatory issue. Here is a similar topic. However, you can store all the obligatory parameters in an internal table. At the Start-of-selection, loop through them and check them.

DATA: BEGIN OF gt_obl_fields OCCURS 0,
    fname TYPE char10,
    ftext type char50,
END OF gt_obl_fields.

INITIALIZATION.
 tab1 = 'Tab1'.
 tab2 = 'Tab2'.

 gt_obl_fields-fname = 'P2'.
 gt_obl_fields-ftext = text-001.
 APPEND gt_obl_fields.
 "...
START-OF-SELECTION.
  LOOP AT gt_obl_fields .
    ASSIGN (gt_obl_fields-fname) TO FIELD-SYMBOL(<fs_field>).
    IF <fs_field> IS ASSIGNED AND <fs_field> IS INITIAL..
      CONCATENATE gt_obl_fields-ftext 'field must be filled!' INTO data(lv_message).
      MESSAGE lv_message TYPE 'E'.
    ENDIF.
  ENDLOOP.
Oguz
  • 1,867
  • 1
  • 17
  • 24
  • 2
    Thanks for the answer but this is what I am actually doing as a workaround. It is hard to believe, that this cannot be handled in some other neater way without getting rid of `OBLIGATORY` markups. – Jagger Aug 07 '17 at 12:24