如果引用或轉貼,麻煩註明出處與本網誌連結,否則視為侵權。

2018年3月20日

SAP ABAP/4程式共用的六種方法

作者: Fred F.M. Wang (FW知識瑣記) 日期:2018.3.20
原著作日期 : 2001/03/29



Outline
   共用程式片段(Include file)
   共用副程式庫(Subroutine pool)
   共用功能模組(Function pool)
   共用Transaction (Call transaction)
   共用報表(Submit report)
   共用對話窗模組(Dialog module pool)

共用程式片段(Include file)
•    共用程式片段Program type : ‘I’ (Include program)
•    叫用方式 : Include Zxxxxx.
•    Include programs are used to
–    1. divide very large programs into smaller more manageable units
–    2. create common program components
•    就上面第二點而言, 兩個缺點:
–    data dependence, not information hiding
–    not modularization

共用副程式庫(Subroutine pool)
•    副程式庫Program type : ‘S’ (subroutine pool)
•    用來存放可共用的副程式(Form)
•    副程式庫宣告方式 : Report Zxxxxx.
•    程式庫宣告方式 :  FORM abc.  … ENDFORM.
•    叫用共用副程式庫中的副程式 : PERFORM abc(Zxxxxx).
•    優點:
–    Easy developing, easy calling
–    Grouping different purpose subroutines into pools
–    Data independent, data transmitting via parameters

共用功能模組庫(Function pool)
•    功能模組庫Program type : ‘F’ (Function group)
•    Function pool 用來存放Function module
•    功能模組庫宣告方式 : FUNCTION-POOL Zxxx.
•    功能模組宣告方式 : FUNCTION abc. …. ENDFUNCTION.
•    叫用功能模組庫中的功能模組 : CALL FUNCTION abc.
•    優點:
–    same as subroutine pool
–    Remote function call supported
–    不必記得function module放在哪個function group只要記得function module name即可
共用Transaction (Call transaction)
叫用方式 : CALL TRANSACRION “Zxx”.
2種應用方式:
1. SET PARAMETER 方式: Call transaction … and skip first screen,  put value into parameters of input fields
2. BATCH INPUT 方式: Call transaction …  using BDCDATA mode 'E'  update 'S’ messages into MESSTAB : put value into fields via BDC structure

共用報表(Submit report)
•    共用報表Program type : ‘1’ (report)
•    報表程式宣告方式 : REPORT Zxxxxx.
•    叫用報表程式 : SUBMIT Zxxxxx.
•    缺點:
–    Parameters transmitting via EXPORT/IMPORT commands
–    變數必須宣告以相同的名稱, 模組化程度不足

共用對話窗模組庫(Dialog module pool)
•    Program type : ‘M’ (module pool)
•    共用對話窗模組庫宣告方式 : PROGRAM Zxxxxx.
•    叫用方式 : CALL DIALOG “Zabc”.
•    可將許多共用對話窗模組,放在一個Module pool內供許多程式叫用
•    優點:Function module不必記得Dialog module放在哪個module pool要記得dialog module name即可

沒有留言:

張貼留言

歡迎提供意見, 謝謝 (註 : 留言經過版主審核通過才會發布)