有时候在调用FM的时候,需要弹出一个输入框
比如输入邮箱
所以写了个小例子
创建了个Function group,他会自带两个include
其中LZLM_TEST_SCREEN_GROUPTOP
定义全局变量
DATA
: ok_code
TYPE sy
-ucomm
,
save_ok TYPE sy -ucomm .
DATA : g_email TYPE so_recname .
save_ok TYPE sy -ucomm .
DATA : g_email TYPE so_recname .
在函数组里新建屏幕9001.
然后定义 user_command_9001.
module USER_COMMAND_9001
input
.
save_ok = ok_code .
CASE save_ok .
WHEN 'OK' OR '' .
IF g_email IS INITIAL .
MESSAGE '请输入邮箱' TYPE 'S' .
ELSEIF g_email NA '@' .
MESSAGE '邮箱格式不正确,请重新输入' TYPE 'S' .
CLEAR g_email .
ELSE .
SET SCREEN 0 .
LEAVE SCREEN .
ENDIF .
"结束屏幕调用
WHEN OTHERS .
g_email = '' .
SET SCREEN 0 . "这两句很有必要
LEAVE SCREEN .
ENDCASE .
endmodule . " USER_COMMAND_9001 INPUT
save_ok = ok_code .
CASE save_ok .
WHEN 'OK' OR '' .
IF g_email IS INITIAL .
MESSAGE '请输入邮箱' TYPE 'S' .
ELSEIF g_email NA '@' .
MESSAGE '邮箱格式不正确,请重新输入' TYPE 'S' .
CLEAR g_email .
ELSE .
SET SCREEN 0 .
LEAVE SCREEN .
ENDIF .
"结束屏幕调用
WHEN OTHERS .
g_email = '' .
SET SCREEN 0 . "这两句很有必要
LEAVE SCREEN .
ENDCASE .
endmodule . " USER_COMMAND_9001 INPUT
下面创建函数:ZLM_TEST_FM_GET_EMAIL
FUNCTION ZLM_TEST_FM_GET_EMAIL
.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" REFERENCE(E_EMAIL) TYPE SO_RECNAME
*"----------------------------------------------------------------------
CALL SCREEN 9001 STARTING AT '30' '10' ENDING AT '97' '14' .
e_email = g_email .
ENDFUNCTION .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" REFERENCE(E_EMAIL) TYPE SO_RECNAME
*"----------------------------------------------------------------------
CALL SCREEN 9001 STARTING AT '30' '10' ENDING AT '97' '14' .
e_email = g_email .
ENDFUNCTION .
然后在程序中调用
REPORT zlm_test_call_fm_screen
.
DATA :email TYPE so_recname .
CALL FUNCTION 'ZLM_TEST_FM_GET_EMAIL'
IMPORTING
e_email = email .
WRITE email .
DATA :email TYPE so_recname .
CALL FUNCTION 'ZLM_TEST_FM_GET_EMAIL'
IMPORTING
e_email = email .
WRITE email .
因为
LZLM_TEST_SCREEN_GROUPTOP 定义的是全局的
这个函数组里的其他函数有可能会受影响
所以,如果可以,带屏幕的函数,跟其他函数还是分开在不同的函数组的好