Skip to main content

A Function Module in SAP is a reusable, modular piece of code that performs a specific task. It is part of the ABAP (Advanced Business Application Programming) language and is stored in the Function Builder (SE37). Function Modules are used to encapsulate business logic, making it reusable across different programs, reports, or applications. 

RFC_READ_TABLE is a standard SAP function module that allows you to read data from any database table in SAP systems. It's designed to be flexible and can handle various data types and table structures. The function module is particularly useful when you need to read data from SAP tables temporarily, work with small to medium-sized datasets, or need quick access to table data. It's also beneficial when you want to avoid complex database programming and need a straightforward solution for data retrieval. 

However, RFC_READ_TABLE has some limitations. It can experience performance issues with large datasets and provides limited control over data retrieval. It may not handle complex data relationships well and can be slower than custom solutions for frequent access. A custom solution might be more appropriate when you need to access large amounts of data frequently, require optimized performance, or need complex data relationships. 

To address these needs, we provide custom function modules Z_CUSTOM_READ_TABLE.txt, Z_CUSTOM_READ_TABLE_752.txt, though Z_CUSTOM_READ_TABLE_752.txt is preferred if your SAP ERP instance is running ABAP version 7.52 or later. 

These files are available in the DB folder of the SAP providers, located at C:\Program Files\CData\CData ODBC Driver for SAP ERP\db

Below are the steps to implement and use these Z_CUSTOM_READ_TABLE function. 

Step 1: Access the Function Builder 

  1. Open the SAP GUI and log in to your system. 

  1. Enter transaction code SE37 in the command field and press Enter. This opens the Function Builder. 

 

 

Step 2: Create a New Function Module 

  1. In the Function Builder, enter a name for your custom function module, e.g., Z_CUSTOM_READ_TABLE. 

  1. Click the Create button. 

  1. Assign the function module to a Function Group. A function group is a container for related function modules. 

 

 

Step 3: Define the Function Module Attributes 

  1. Short Text: Provide a description of the function module. 

  1. Processing Type: Choose between: 

  • Regular Function Module: For regular ABAP processing. 

  • Remote-Enabled Function Module: If the function module needs to be called from an external system which is our case 

 

 

  1. Save your changes. 

Step 4: Define Import/Export Parameters 

  1. Go to the Import tab to define input parameters.

     

     

  1. Go to the Export tab to define output parameters.

     

     

  1. Go to the Tables tab and define Options/Fields and DATA

     

     

  1. Go to the Exceptions and enter the exceptions from the file.

     

     

Step 5: Enter the ABAP Sample Code 

  1. Go to the Source Code tab. 

  1. Paste the code sample from the Z_CUSTOM_READ_TABLE.txt file into the source code editor.

     

     

Step 6: Activate the Function Module 

  1. Save your changes. 

  1. Click the Activate button (Ctrl + F3) to activate the function module. 

Step 7: Test the Function Module in SAP Gui 

  1. In the Function Module tab on the top left, click Execute → In a test environment.

     

     

  1. You can either provide input details or click the Preview button (represented by a clock icon), which will prompt you to enter the table name.

     

     

  1. Once you enter the desired table name, press Enter, and you should be able to successfully test the custom function. If data is retrieved, this confirms that the function is working correctly. You can then test it on the driver side to ensure its functionality. 

 

 Step 8: Use the Z_CUSTOM_READ_TABLE on the Driver 

  1. Open DSN Configuration in the Advanced section. 

  1. Under Miscellaneous, set the Read Table Function to Z_CUSTOM_READ_TABLE to use the newly created custom function.

     

     

  1. Navigate to the Data Model, view the table listing, and attempt to retrieve the data.

     

     

As you can see, we are able to successfully retrieve results using the custom function. If you encounter any issues, please don't hesitate to reach out to CData support for assistance. 

Be the first to reply!