最近一个同事有一个比较变态的用户需求,他希望每次回到选择屏幕时,选择参数是有程序控制输入的,用户客户端的输入清除。对此需求有两种处理方法:
一、在AT SELECTION-SCREEN中写赋值语句,这种方法你可能需要中间变量缓存选择条件用于查询,代码样例:
REPORT ZDEMO_WRITE_STATEMENT.
TABLES VBAK.
DATA: NAME(20) VALUE 'SOURCE',
SOURCE(10) VALUE 'abcd',
TARGET(10).
SELECT-OPTIONS K_KUNNR FOR VBAK-KUNNR.
DATA: IS_PARENT TYPE I VALUE 0.
INITIALIZATION.
REFRESH K_KUNNR.
AT SELECTION-SCREEN.
REFRESH K_KUNNR.
MOVE: 'I' TO K_KUNNR-SIGN,
'EQ' TO K_KUNNR-OPTION,
'9999' TO K_KUNNR-LOW.
APPEND K_KUNNR.
*SYSTEM-CALL INITIALIZATION.
二、在Initialization事件中写赋值代码
在Initialization事件中写赋值代码,默认情况只有第一次会影响输入屏幕,以后将失去作用。为了使该代码起作用你必须在选择屏幕的其他事件中执行SYSTEM-CALL INITIALIZATION.这个语句。代码样例:
REPORT ZDEMO_WRITE_STATEMENT.
TABLES: SPFLI.
DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT
WITH UNIQUE KEY TABLE_LINE,
WA LIKE LINE OF TAB_SFLIGHT.
SELECT-OPTIONS S_CARRID FOR SPFLI-CARRID.
INITIALIZATION.
REFRESH S_CARRID.
MOVE: 'I' TO S_CARRID-SIGN,
'EQ' TO S_CARRID-OPTION,
'AZ' TO S_CARRID-LOW.
APPEND S_CARRID.
AT SELECTION-SCREEN.
START-OF-SELECTION.
SELECT CARRID CONNID
INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI
FROM SPFLI
WHERE CARRID IN S_CARRID .
SYSTEM-CALL INITIALIZATION.
SELECT CARRID CONNID FLDATE
INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT
FROM SFLIGHT
FOR ALL ENTRIES IN TAB_SPFLI
WHERE CARRID = TAB_SPFLI-CARRID AND
CONNID = TAB_SPFLI-CONNID.
LOOP AT TAB_SFLIGHT INTO WA.
AT NEW CONNID.
WRITE: / WA-CARRID, WA-CONNID.
ENDAT.
WRITE: / WA-FLDATE.
ENDLOOP.
还有怎么点击返回🔙,执行INITIALIZATION不清空历史数据。
我是老周,如果你喜欢我的文字,请记得点击⬇️关注我。
码字不易,文章下拉,右边点个【赞】和【在看】吧!!
猜您还喜欢合集:
猜您还喜欢文章: