学习编程的最佳方法是研究他人的代码,一些我写了一段简单的代码演示动态选择屏幕
TABLES: sflight, spfli, sbook.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
PARAMETERS p_scd RADIOBUTTON GROUP grp1 USER-COMMAND com MODIF ID scd DEFAULT 'X'.
PARAMETERS p_flt RADIOBUTTON GROUP grp1 MODIF ID flt.
PARAMETERS p_fbk RADIOBUTTON GROUP grp1 MODIF ID fbk.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME.
PARAMETERS p_carrid TYPE spfli-carrid MODIF ID scd.
PARAMETERS p_connid TYPE spfli-connid MODIF ID scd.
PARAMETERS p_fldate TYPE sflight-fldate MODIF ID flt.
PARAMETERS p_price TYPE sflight-price MODIF ID flt.
PARAMETERS p_bookid TYPE sbook-bookid MODIF ID fbk.
PARAMETERS p_ctmid TYPE sbook-customid MODIF ID fbk.
SELECTION-SCREEN END OF BLOCK blk2.
AT SELECTION-SCREEN OUTPUT.
IF p_scd = 'X'.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'SCD'.
screen-active = '1'.
MODIFY SCREEN.
WHEN 'FLT'.
IF screen-name = 'P_FLDATE' OR
screen-name = 'P_PRICE' OR
screen-name = '%_P_FLDATE_%_APP_%-TEXT' OR
screen-name = '%_P_PRICE_%_APP_%-TEXT'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
WHEN 'FBK'.
IF screen-name = 'P_BOOKID' OR
screen-name = 'P_CTMID' OR
screen-name = '%_P_BOOKID_%_APP_%-TEXT' OR
screen-name = '%_P_CTMID_%_APP_%-TEXT'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDIF.
IF p_flt = 'X'.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'SCD'.
IF screen-name = 'P_CARRID' OR
screen-name = 'P_CONNID' OR
screen-name = '%_P_CARRID_%_APP_%-TEXT' OR
screen-name = '%_P_CONNID_%_APP_%-TEXT'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
WHEN 'FLT'.
screen-active = '1'.
MODIFY SCREEN.
WHEN 'FBK'.
IF screen-name = 'P_BOOKID' OR
screen-name = 'P_CTMID' OR
screen-name = '%_P_BOOKID_%_APP_%-TEXT' OR
screen-name = '%_P_CTMID_%_APP_%-TEXT'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDIF.
IF p_fbk = 'X'.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'SCD'.
IF screen-name = 'P_CARRID' OR
screen-name = 'P_CONNID' OR
screen-name = '%_P_CARRID_%_APP_%-TEXT' OR
screen-name = '%_P_CONNID_%_APP_%-TEXT'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
WHEN 'FLT'.
IF screen-name = 'P_FLDATE' OR
screen-name = 'P_PRICE' OR
screen-name = '%_P_FLDATE_%_APP_%-TEXT' OR
screen-name = '%_P_PRICE_%_APP_%-TEXT'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
WHEN 'FBK'.
screen-active = '1'.
MODIFY SCREEN.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDIF.