示例数据
程序: Z437_TEST_20241006 代码如下所示
REPORT Z437_TEST_20241006.* 创建跟表或结构同名的工作区
TABLES: zdbt_stu_437.SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.PARAMETERS: p_1 TYPE c LENGTH 4.SELECT-OPTIONS: s_sex FOR zdbt_stu_437-sex NO INTERVALS NO-EXTENSION,s_id FOR zdbt_stu_437-id.
SELECTION-SCREEN END OF BLOCK b1.
输出结果:
1.SUBMIT
示例1
通过SUBMIT调用Z437_TEST_20241006的程序
REPORT z437_test_2024.DATA: lt_seltab TYPE STANDARD TABLE OF rsparams,ls_seltab TYPE rsparams.ls_seltab-selname = 'P_1'.
ls_seltab-kind = 'P'. " 选择PARAMETERS类型
ls_seltab-low = '12'.
APPEND ls_seltab TO lt_seltab.ls_seltab-selname = 'S_SEX'.
ls_seltab-kind = 'S'. " 选择SELECT-OPTIONS类型
ls_seltab-sign = 'I'.
ls_seltab-option = 'EQ'.
ls_seltab-low = 'M'.
APPEND ls_seltab TO lt_seltab.ls_seltab-selname = 'S_ID'.
ls_seltab-kind = 'S'.
ls_seltab-sign = 'I'.
ls_seltab-option = 'BT'.
ls_seltab-low = '1'.
ls_seltab-high = '10'.
APPEND ls_seltab TO lt_seltab.SUBMIT Z437_TEST_20241006VIA SELECTION-SCREEN " 显示调用程序的选择屏幕AND RETURN " 调用程序之后,继续执行当前程序WITH SELECTION-TABLE lt_seltab.WRITE: 'Test437'.
输出结果:
调用SUMBIT AND RETURN后,会继续执行源程序中该语句之后的代码
2.CALL TRANSACTION
示例1
将上述程序Z437_TEST_20241006创建对应的事务码Z437_TEST,具体操作可参考如下资料
创建事务码T-CODEhttps://blog.csdn.net/Hudas/article/details/136761899?spm=1001.2014.3001.5502我们可以使用事务码Z437_TEST跳转到Z437_TEST_20241006程序输出界面
通过CALL TRANSACTION调用Z437_TEST
REPORT z437_test_2024.DATA: lt_bdcdata_tab TYPE TABLE OF bdcdata,ls_bdcdata_tab TYPE bdcdata,ls_opt TYPE ctu_params.ls_bdcdata_tab-program = 'Z437_TEST_20241006'. " 调用的程序名
ls_bdcdata_tab-dynpro = '1000'. " 屏幕号
ls_bdcdata_tab-dynbegin = 'X'. " 设置为开始屏幕
APPEND ls_bdcdata_tab TO lt_bdcdata_tab.CLEAR:ls_bdcdata_tab.
ls_bdcdata_tab-fnam = 'S_SEX-LOW'. " Dynpro字段
ls_bdcdata_tab-fval = 'F'.
APPEND ls_bdcdata_tab TO lt_bdcdata_tab.CLEAR:ls_bdcdata_tab.
ls_bdcdata_tab-fnam = 'S_ID-LOW'. " Dynpro字段
ls_bdcdata_tab-fval = '1'.
APPEND ls_bdcdata_tab TO lt_bdcdata_tab.CLEAR:ls_bdcdata_tab.
ls_bdcdata_tab-fnam = 'S_ID-HIGH'. " Dynpro字段
ls_bdcdata_tab-fval = '10'.
APPEND ls_bdcdata_tab TO lt_bdcdata_tab.ls_opt-dismode = 'E'. " 显示错误
ls_opt-defsize = 'X'.* ls_opt = VALUE #( dismode = 'E' defsize = 'X' ).CALL TRANSACTION 'Z437_TEST' " 事务码TCodeUSING lt_bdcdata_tabOPTIONS FROM ls_opt.
输出结果:
提示Tips
① 如何获取相关的PROGRAM、DYNPRO参数值?
点击【系统】|【状态】
② 如何获取Dynpro字段?
示例2
程序调用事务码MM02,物料号填写'EWMS4-03'
输出结果:
提示Tips:如何查看物料号的PARAMETER ID(参数ID)?