<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # ABAP 中的模塊化:宏,子例程&功能模塊 > 原文: [https://www.guru99.com/sap-macro-include-function-module-group-subroutine.html](https://www.guru99.com/sap-macro-include-function-module-group-subroutine.html) 在對源代碼進行模塊化時,需要在模塊中放置一系列 ABAP 語句。 然后,您無需調用所有語句即可將其放置在主程序中,而只需調用模塊即可。在生成程序時,將模塊化單元中的源代碼視為實際上實際存在于主程序中。 在本教程中,您將學習: * [SAP- ABAP 宏](#1) * [包含程序](#2) * [子例程](#3) * [功能模塊](#4) * [功能組](#5) **Need of Modularization** * 改進程序的結構。 * 易于閱讀的代碼 * 易于維護的代碼 * 避免冗余并促進代碼重用 **Various Modularization Techniques** * 宏的使用 * 包含文件的使用 * 子程序 * 功能模塊 Lets look into each of them in detail : ## SAP- ABAP 宏 If you want to reuse the same set of statements more than once in a program, you can include them in a macro.You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition. 宏對于長時間計算或復雜的 WRITE 語句很有用。 句法 ``` DEFINE <macro_name> 'Macro Statements END-OF-DEFINITION ``` Macros can use Parameters ***&N*** where N = 1,2,3... 例:- ``` DATA: number1 TYPE I VALUE 1. DEFINE increment. ADD 1 to &1. WRITE &1. END-OF-DEFINITION. Increment number1. WRITE number1. ``` Output: 2 ## 包含程序 Include Programs are solely for modularizing source code, and have no parameter interface. Include programs allow you to use the same source code in different programs. They? can be useful if you have lengthy data declarations that you want to use in different programs. Syntax ``` Include <include program Name> ``` **Points to Note** * 包含程序無法自行調用。 * 包含程序必須包含完整的語句。 Example: ``` INCLUDE ZILX0004. WRITE: / 'User', SY-UNAME,/ 'Date', SY-DATUM. ================================ PROGRAM ZRPM0001. INCLUDE ZILX0004. ``` ## 子例程 Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module. 句法- ``` FORM <Subroutine> [<pass>]. <Statement block>. ENDFORM. ``` <Subroutine> = Name of the subroutine <通過> =正在傳遞參數 **子例程的類型** 1. 內部 * 在同一程序中定義的子例程被調用。 * 可以訪問在 ABAP / 4 主程序中聲明的所有數據對象。 2. 外部 * 在正在調用的程序之外定義的子例程。 * 需要使用<傳遞>選項或在內存的公共部分聲明數據對象。 **Calling a Subroutine** ***Internal Subroutines*** ``` PERFORM <subroutine> [<pass>] ``` <subroutine> = Name of the subroutine <pass> = Parameters being passed 主程序中聲明的數據將自動可用。 ***外部子程序*** ``` PERFORM <subroutine>(<Program>) [<pass>]. PERFORM <subroutine> (<Program>) [<pass>] [IF FOUND]. PERFORM (<subroutine>) IN PROGRAM (<Program>) [<pass>] [IF FOUND]. PERFORM <index> OF <subroutine1> <subroutine2> <subroutine3> [<pass>]. ``` ***Points to Note*** * 子程序中允許嵌套調用(即 FORM ... ENDFORM 中的 PERFORM)。 * 遞歸調用也是可能的。 * 要定義本地數據,請在 FORM 之后使用 DATA 語句。 每次您進入子例程時,都會重新創建數據(使用初始值)并在最后(從堆棧中)釋放數據。 * 要定義子例程中使用的全局數據,請在 FORM 之后使用 LOCAL 語句。 當您輸入子例程時,將保存這些值,然后最后(從堆棧中)釋放這些值 ## 功能模塊 Function Modules are general purpose ABAP/4 routines that anyone can use. Infact , there are a large number of standard function Modules available.Function Modules are organized into Function Groups: Collections of logically related functions. A Function module always belongs to a Function Group. 句法- ``` FUNCTION <function module> <Statements> ENDFUNCTION. ``` **Important information Associated with Function Module** * 行政 * 導入/更改/導出參數。 * 表參數/異常。 * 文獻資料 * 源代碼- *L < fgrp > U01。* < fgrp >是功能組 * 全局數據- *L < fgrp > TOP* 。功能組的全局數據-可在功能組中的各個功能模塊之間訪問。 * 主程序- *SAPL < fgrp >* 。 包含該功能組的所有包含文件的列表 **Call a Function Module** 要調用功能模塊,請使用 CALL FUNCTION 語句: ``` CALL FUNCTION <module> [EXPORTING??f1 = a 1.... f n = a n] [IMPORTING??f1 = a 1.... f n = a n] [CHANGING?? f1 = a 1.... f n = a n] [TABLES???? f1 = a 1.... f n = a n] [EXCEPTIONS e1 = r 1.... e n = r n [ERROR_MESSAGE = r E] ??? [OTHERS = ro]]. ``` ## 功能組 Function groups are containers for function modules. Infact, there are a large number of standard Function Groups. All of the function modules in a function group can access the global data of the group. 像可執行程序(類型 1)和模塊池(類型 M)一樣,功能組可以包含屏幕,選擇屏幕和列表。 **注意點** * 功能組無法執行。 * 功能組的名稱最多可以包含 26 個字符。 * 創建功能組或功能模塊時,將自動生成主程序和包含程序。 * 功能組封裝數據。 **How to create a Function Group** 1. 轉到事務 SE80。 2. 在下拉列表中選擇程序。 3. 輸入要創建的功能組的名稱。 通常,用戶創建的功能組以“ Z”開頭。 例如 -< Z_FUNCTION_GROUP_NAME >。 按下 Enter 鍵。 4. 請注意,如果用戶選中創建 TOP 包含的選項,則默認情況下將創建 TOP 包含。 **How to create a Function Module** 1. 創建一個功能組(例如“ *ZCAL* ”)。 2. 創建功能模塊,設置屬性(功能組,應用程序,短文本和過程類型)和保存。 3. 包含文件“ *LZCALU01* ”將具有第一個功能模塊的源代碼。 4. 包含文件“ *LZCALTOP* ”將具有全局數據。 5. 主程序“ *SAPLZCAL* ”包含 * 全局數據包含文件“ *LZCALTOP* ” * 功能模塊包括文件“ *LZCALUXX* ” * 用戶定義的包含文件“ *LZCALF* ..”,“ *LZCALO* ..”和“ *LZCALI* ..” 6. 定義接口參數和異常 7. 編寫源代碼 8. 激活功能模塊 9. 測試功能模塊-單一測試&調試 10. 記錄和發布功能模塊 That's all to Modularity in ABAP.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看