[ABAP] Oberflächenelemente per Button ausblenden

TABLES: sscrfields.

CONSTANTS: BEGIN OF e_status,
             open  TYPE i VALUE 0,
             close TYPE i VALUE 1,
           END OF e_status.

DATA: status_blk2 TYPE i.

SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE title1.
PARAMETERS: p1 TYPE string.
SELECTION-SCREEN: END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (4) btn_oc USER-COMMAND btn_cmd_oc.
SELECTION-SCREEN COMMENT 6(25) lbl_oc.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN: BEGIN OF BLOCK blk2 WITH FRAME TITLE title2.
PARAMETERS: s1 TYPE string MODIF ID b2.
PARAMETERS: s2 TYPE string MODIF ID b2.
SELECTION-SCREEN: END OF BLOCK blk2.

INITIALIZATION.
  title1 = 'Kundennummer'.
  title2 = 'Eingabe'.

  lbl_oc  = 'Eingabe'.

  status_blk2 = e_status-close.

  PERFORM set_btn_icon USING status_blk2 CHANGING btn_oc.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN INTO DATA(wa).
    CASE wa-group1.       " Name der Modifikationsgruppe
      WHEN 'B2'.          " wenn in Modifikationsgruppe 'B2'
        IF status_blk2 = e_status-open.
          wa-active = '1'.
        ELSE.
          wa-active = '0'.
        ENDIF.
    ENDCASE.

    MODIFY SCREEN FROM wa.
  ENDLOOP.

  PERFORM set_btn_icon USING status_blk2 CHANGING btn_oc.

AT SELECTION-SCREEN.
  CASE sscrfields-ucomm.
    WHEN 'BTN_CMD_OC'.
      IF status_blk2 = e_status-open.
        status_blk2 = e_status-close.
      ELSE.
        status_blk2 = e_status-open.
      ENDIF.
  ENDCASE.

FORM set_btn_icon USING iv_status TYPE i CHANGING btn_icon TYPE any.
  CASE iv_status.
    WHEN e_status-close.
      btn_icon = icon_data_area_expand.
    WHEN e_status-open.
      btn_icon = icon_data_area_collapse.
  ENDCASE.
ENDFORM.