ABAP Function ModuleCreated by Zero Li文档格式.docx
《ABAP Function ModuleCreated by Zero Li文档格式.docx》由会员分享,可在线阅读,更多相关《ABAP Function ModuleCreated by Zero Li文档格式.docx(7页珍藏版)》请在冰豆网上搜索。
![ABAP Function ModuleCreated by Zero Li文档格式.docx](https://file1.bdocx.com/fileroot1/2022-12/13/85694000-66ab-4880-bf82-0ad50feec639/85694000-66ab-4880-bf82-0ad50feec6391.gif)
InTcodeSE37,youcanseeaimporttab(theparametersneededtopassintothefunctionmodule)here,iftheOptionisselected,theparameterisnotrequired,ifthePassValueisselected,theparameterispassedbyvaluebutnotpassedbyreference.
在TcodeSE37,这里import是传入参数,Option如果打扣,就是可选的(不是必须),PassValue如果打扣,就是值传递(不是引用传递,这个概念基本编程语言都有,如果不懂上网查下)
TheparametersintheExporttabisparametersthefunctionreturnvalueafterprocess.
Exporttab里的参数是Function运行后的传出参数
YoucanputtheexportorimportparametersinChangingtab,usuallyyoucanputaparameterwhichwillbemodifiedinthefunction
你可以把那传入或传出的参数放在Changing这里,通常我会把那些在Function里改变的变量放这里
Inthetabletab,thetableneededtobeimportorexportcanbeputhere.WiththeLIKEkeyword,thetableisdifinedwithheadline
在Table这里,当然就是Table了,可以是传出的或传入的,用LIKE一个结构体来定义一个有Headline的Function
Youcanmaintaintheexceptionafterthefunction.Afterthecalling,theSY-SUBRCwillbesettotheexceptionnumber,isTextIDinvalid,SY-SUBRCwillbesetto1,ifInvalidlanguage,SY-SUBRCwillbesetto2,etc.Ifthereisnoexception,SY-SUBRCwillbe0.
你可以把Exception维护在这里,当完成Callfunction后,系统变量SY-SUBRC会设成Exception的值,如果ID无效,SY-SUBRC会设成1,如果语言无效,SY-SUBRC会设成2,如此类推。
如果没异常,则SY-SUBRC会是0.
Thecodebelowcallthefunctionmodule'
READ_TEXT'
togetthelongtextofthematerial
以下的代码可以拿到这个物料的长文本
Buttotheprogramtheparametersisexportedintothefunction(importinSE37),whenfinishingcallingtheprogramwillimporttheparametersfromthefunctionmodule.
在程中,程序把参数传出给FM,当调用FM后,程序引进FM的结果,这里是和SE37那里相对的。
DATA:
lt_tline
TYPE
STANDARD
TABLE
OF
tline,
lw_tline
tline.
CALL
FUNCTION
'
EXPORTING
*
CLIENT
=
SY-MANDT
id
GRUN'
language
E'
name
1500-600'
object
MATERIAL'
ARCHIVE_HANDLE
LOCAL_CAT
IMPORTING
HEADER
=
TABLES
lines
lt_tline
EXCEPTIONS
1
2
3
not_found
4
5
reference_check
6
wrong_access_to_archive
7
OTHERS
8
.
IF
sy-subrc
<
>
0.
MESSAGE
ID
SY-MSGID
SY-MSGTY
NUMBER
SY-MSGNO
WITH
SY-MSGV1
SY-MSGV2
SY-MSGV3
SY-MSGV4.
ELSE.
LOOP
AT
INTO
lw_tline.
WRITE:
/
lw_tline-tdline.
ENDLOOP.
ENDIF.