You are on page 1of 3

Function Modules

Function modules are procedures that are defined in special ABAP programs only, so-called function groups, but can be called from all ABAP programs. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder. Function modules allow you to encapsulate and reuse global functions in the SAP System. They are managed in a central function library. The SAP System contains several predefined functions modules that can be called from any ABAP program. Function modules also play an important role during updating and in interaction between different SAP systems, or between SAP systems and remote systems through remote communications. Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. You can test function modules without having to include them in a program using the Function Builder. The Function Builder also has a release process for function modules. This ensures that incompatible changes cannot be made to any function modules that have already been released. This applies particularly to the interface. Programs that use a released function module will not cease to work if the function module is changed.

All ABAP programs are modular in structure and made up of processing blocks you can modularize source code by placing ABAP statements either global include programs or function modules. The processing blocks that you call from ABAP programs are called procedures. Modularization makes ABAP programs easier to read and maintain, as well as avoiding redundancy, increasing the reusability of source code, and encapsulating data. Function modules are procedures that are defined in function groups (type F) and can be called from any ABAP program. Every function module needs a function group which acts as containers. Function modules allow you to encapsulate and reuse global functions in the R/3 System. Function modules are stored in a central library. The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program. Function modules play an important role in updating the databases. Function modules play an important role in remote communications between R/3 Systems or between an R/3 System and a non-SAP system. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. The actual ABAP interface definition remains hidden from the programmer. You can define the following Function modules can be tested without having to include them in a program. Please follow the steps to create the function groups and function modules in the ABAP by using function builder. GOTO> Tcode: SE37 or Tools -> ABAP workbench -> Development -> Function builder.

Step 1: Create function group first if your not using existing one Function builder -> Goto -> function groups -> Create function groups. Step 2: Create function module using the function builder. Calling function module: To call the function module, try creating a report and calling the function modules. Follow the steps as below: 1) Create ABAP Program using ABAP editor ( TCODE: SE38). 2) Define the required Variables. 3) Call function module, by passing the values.

Function Modules for SD Reports and Smartforms


by Sundar These function modules are great to get the information used to populate Smartforms and reports in SD. Remember you can access the data with transaction SE37 and use the test/execute icon [F8]. 1. To get all Pricing details for the Sale order item: SD_SALES_PRICING_INFORMATION. This will fetch all KOMK / KOMP data into the internal Tables. 2. To get all pricing details for the Billing item: RV_INVOICE_PRICING_PREPARE. This will fetch all KOMK / KOMP data into the internal Tables. 3. To get the Pricing Condition data: PRICING_GET_CONDITIONS This will fetch corresponding KONV data to the internal tables 4. To fetch the Terms of Payment Details: SD_PRINT_TERMS_OF_PAYMENT This Function Module will be used to retrieve the Billing Due Date and Cash discount Percentage for each with respect to the Document Payment Terms 5. To fetch the Texts: READ_TEXT This is the commonly used Function Module to read the header and item texts from the document for the given Text ID /Text Name / Text Object 6. To fetch Address Details of the Customer: SD_ADDRESS_GET This FM is used to fetch the complete Address Details of the Customer using the corresponding ADRNR. (With Key as Document # in VBPA)

You might also like