只有在以下情况下,屏幕字段才能采用 `SET PARAMETER ID 'ZZZ' FIELD 'VALUE' 设置的值:
- 字段的类型为“输入/输出”(在设计时和运行时)
- 字段属性“参数 ID”是相同的 SAP 内存 ID (ZZZ)
- 字段属性“GET 参数”被选中
- 在程序中,屏幕字段名对应的全局变量为initial(至少在Process Before Output阶段结束时)
摘自ABAP 文档:“定义输入字段时,可以通过从数据库表 TPARA 输入 SPA/GPA 参数的名称作为属性 PARAMETER ID 将 dynpro 字段与 SPA/GPA 参数相关联。如果相应的参数 GET PARAMETER 是设置并且没有为输入字段分配其他值,输入字段在发送屏幕时填充SPA/GPA参数的值。"
演示,在第一个屏幕输入的值出现在第二个屏幕,反之亦然:
REPORT z.
TABLES sscrfields.
" Selection screen 1000 (implicit first one)
SELECTION-SCREEN COMMENT /1(40) text1000.
PARAMETERS p_start TYPE c LENGTH 10 LOWER CASE MEMORY ID zzzz.
" Selection screen 1001
SELECTION-SCREEN BEGIN OF SCREEN 1001.
SELECTION-SCREEN COMMENT /1(40) text1001.
PARAMETERS p_b1ab1a TYPE c LENGTH 10.
PARAMETERS p_end TYPE c LENGTH 10 LOWER CASE MEMORY ID zzzz.
PARAMETERS p_b2ab2a TYPE c LENGTH 10.
SELECTION-SCREEN END OF SCREEN 1001.
INITIALIZATION.
text1000 = 'Press Enter to go to next screen'(000).
text1001 = 'Press Enter to go to previous screen'(001).
AT SELECTION-SCREEN.
IF sscrfields-ucomm IS INITIAL.
CASE sy-dynnr.
WHEN 1000.
CLEAR p_end. " <== very important !
CALL SELECTION-SCREEN 1001.
WHEN 1001.
CLEAR p_start. " <== very important !
LEAVE TO SCREEN 0. " go to previous screen (don't use CALL
" SELECTION-SCREEN to avoid a stack of more than 50 dynpros)
ENDCASE.
ENDIF.