我需要将给定程序(ZPRG1
)的选择屏幕包括到另一个程序的(ZPRG2
)子屏幕(100
)中。
当我运行下面的程序ZPRG2
时,在显示任何屏幕之前,都会出现运行时错误DYNP_WRONG_SCREEN_TYPE
(错误的屏幕类型:该屏幕定义不正确或使用不正确)。
ZPRG1 (带有一个字段TEST
的选择屏幕1000):
REPORT zprg1.
PARAMETERS test AS CHECKBOX.
ZPRG2 :
REPORT zprg2.
CALL SCREEN 100.
MODULE pai INPUT.
SET SCREEN 0. " close screen (all the time)
ENDMODULE.
屏幕100 :( ZPRG2)
屏幕布局定义了子屏幕区域SUBAREA
和任意数量的元素,流程逻辑如下:
PROCESS BEFORE OUTPUT.
CALL SUBSCREEN subarea INCLUDING 'ZPRG1' '1000'.
PROCESS AFTER INPUT.
CALL SUBSCREEN subarea.
MODULE pai.
如何防止运行时错误?
答案 0 :(得分:3)
在dynpro技术中,要将屏幕“ A”包含在屏幕“ B”中,必须将屏幕“ A”定义为子屏幕,而屏幕“ B”必须定义“子屏幕区域”中包含屏幕“ A”。屏幕“ B”的flow logic必须包含语句CALL SUBSCREEN <subscreen_area> INCLUDING ...
,该语句引用要静态或通过全局变量包含的子屏幕编号。
与普通屏幕一样,也可以通过将选择屏幕定义为子屏幕,方法是将其定义为“独立选择屏幕”(将其元素包装在ABAP语句SELECTION-SCREEN BEGIN OF SCREEN <any-screen-number>
和SELECTION-SCREEN END OF SCREEN <any-screen-number>
),并在BEGIN OF SCREEN <any-screen-number>
之后添加“按订阅” 。例如:
SELECTION-SCREEN BEGIN OF SCREEN 1001 AS SUBSCREEN.
PARAMETERS test AS CHECKBOX.
SELECTION-SCREEN END OF SCREEN 1001.
如果必须包括一个尚未选择为子屏幕的现有选择屏幕,则有两种主要可能性:
SELECTION-SCREEN BEGIN OF SCREEN ...
),并且只能用作子屏幕,则可以如上所述简单地添加AS SUBSCREEN
。SELECTION-SCREEN BEGIN OF BLOCK <block ID>
和SELECTION-SCREEN END OF BLOCK <block ID>
),然后定义另一个包含此块的选择屏幕(ABAP语句SELECTION-SCREEN INCLUDE BLOCKS <block ID>
)。下面是案例2的两个示例。
示例1,具有默认选择屏幕(1000 cf脚注)
REPORT zprg1.
PARAMETERS test AS CHECKBOX. " screen 1000 cf footnote
REPORT zprg1.
SELECTION-SCREEN BEGIN OF BLOCK b1000.
PARAMETERS test AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b1000.
SELECTION-SCREEN BEGIN OF SCREEN 1001 AS SUBSCREEN.
SELECTION-SCREEN INCLUDE BLOCKS b1000.
SELECTION-SCREEN END OF SCREEN 1002.
带有独立选择屏幕的示例2 (1002,包含在CALL SUBSCREEN subarea INCLUDING 'ZPRG1' '1002'.
中)
REPORT zprg1.
SELECTION-SCREEN BEGIN OF SCREEN 1002.
PARAMETERS test AS CHECKBOX.
SELECTION-SCREEN END OF SCREEN 1002.
REPORT zprg1.
SELECTION-SCREEN BEGIN OF SCREEN 1002.
SELECTION-SCREEN BEGIN OF BLOCK b1002.
PARAMETERS test AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b1002.
SELECTION-SCREEN END OF SCREEN 1002.
SELECTION-SCREEN BEGIN OF SCREEN 1003 AS SUBSCREEN.
SELECTION-SCREEN INCLUDE BLOCKS b1002.
SELECTION-SCREEN END OF SCREEN 1003.
脚注:
(1)未放置在SELECTION-SCREEN BEGIN OF SCREEN ... END OF SCREEN ...
内的选择屏幕参数隐式属于“默认选择屏幕”(1000
)的一部分。请注意,使用SELECTION-SCREEN BEGIN OF SCREEN 1000...
会导致语法错误。