ABAP语言中的IS SUPPLIED是用来判断function的输入参数是否被实参赋值,简单说来就是判断参数是否传入。
下面用一个例子来说明:
SE37创建一个Function,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
FUNCTION ztest_supplied .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_NAME) TYPE UNAME OPTIONAL
*"----------------------------------------------------------------------
IF i_name IS NOT SUPPLIED.
WRITE:/ 'Import parameter I_NAME is not SUPPLIED'.
ELSE.
WRITE:/ 'Import parameter I_NAME is SUPPLIED'.
ENDIF.
IF i_name IS INITIAL.
WRITE:/ 'I_NAME is initial'.
ELSE.
WRITE:/ 'I_NAME = ', i_name.
ENDIF.
ENDFUNCTION.
|
其中参数I_NAME是optional的
SE38,创建一个report来调用上面的function,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
REPORT ztest_supplied.
WRITE:/ '1st call:'.
CALL FUNCTION 'ZTEST_SUPPLIED'
* EXPORTING
* I_NAME =
.
SKIP.
WRITE:/ '2nd call:'.
CALL FUNCTION 'ZTEST_SUPPLIED'
EXPORTING
i_name = 'BaiduSAP.com'.
SKIP.
WRITE:/ '3rd call:'.
CALL FUNCTION 'ZTEST_SUPPLIED'
EXPORTING
i_name = ''.
|
运行结果:
以上。