调用功能模块
模塊化技術包括:子程序(Subroutine),功能模塊(Function Modules),類方法(Class Methods).
?
調用功能模塊
要從abap/4程序調用功能模塊,需使用CALL語句。
?
語法
call function <module>
????? [exporting f1 = a1 ... fn = an]
????? [importing f1 = a1 ... fn = an]
????? [changing f1 = a1 ... fn = an]
????? [tables f1 = a1 ... fn = an]
????? [exceptions e1 = r1 ... en = rn [others = ro]].
注釋:
? ----tables選項的參數必須為內表。
?
例子
?? data: text(20),
?? ? ??? ? ? front(20),
???? ? ? ? ? end(20).
??? text = 'Testing:String_Split'.
??? call function 'STRING_SPLIT'
?? ? ?? exporting delimiter = ':'? string = text
??? ? ? importing head = front? tail = end
??? ? ? exceptions not_found = 1? others = 2.
???? ? ? ? case sy-subrc.
????? ? ? ? ? when 1.
?????? ? ? ? ? ? write / 'not found'.
????? ? ? ? ? when 2.
???????? ? ? ? ? write / 'other errors'.
? ? ? ? ????? when others.
??????? ? ? ?? ? write:/ front, / end.
?????????? endcase.
?? 該函數的功能:將":"和text分別傳遞給delimiter和string,調用功能函數STRING_SPLIT[將字符串根據分隔符來分隔],然后將結果傳遞給head[head='Testing']和tail[tail='String_Split'],而exceptions就是處理例外.
總結