bodsexpert
bodsexpert

Working with BAPI to load Long Text in S4HANA using BODS

By Imran, Mohammad May 15, 2024 under BODS

 

Like IDoc, BODS also supports BAPI. BAPI is useful for loading data into S4HANA when IDoc is not available. Before you begin working with BAPI in BODS, the first step is to ensure that the BAPI you intend to call is an RFC-enabled function module. Below, I will demonstrate how to verify this. In this blog, you will learn two key things: first, how to load long text using BAPI, and second, how to call an RFC-enabled function module (BAPI) using BODS.

 

Functional Module (BAPI)

The functional module we are choosing here to load long text is RFC_SAVE_TEXT. To ensure that the functional module is remote-enabled, run the transaction code SE37.

  • Run the transaction code SE37.
  • Enter the functional module name in the text field and click Display.
  • Under the Attributes tab, check if the Remote-Enabled Module radio button is selected. If any other radio button is selected, it means the functional module is not RFC-enabled. In this case, you will need to collaborate with the ABAP team to create a wrapper for this functional module, enabling it for remote calls and making it ready to be used in BODS.
RFC_Enabled

Import FM to BODS

Import the Functional Module the way you imported the IDoc.

  • Open the BODS and goto your target S4HANA Datastore.
  • Right click on Functions and click Import By Name.
  • Enter the name and click Import.
IDoc design

Design Source Structure

If the required fields are available on the header without being part of a segment, you will need to map the fields directly. If the fields are available under a segment, you will need to create an input segment and map it directly to the functional module. Let's design the source structure based on the structure of the functional module. Please disregard the design below if you are working with a different functional module, as the structure may vary. The design provided below is specifically for loading long text into a Purchase Order.

  • To design your source structure for long text, you will need to reference the STXH table.
  • The STXH table provides the necessary information on the values you need to populate for the long text fields available in the functional module.
  • If you're unsure of the values, you can enter a long text in your object and save it. Afterward, return to the STXH table and enter your object number in the TDNAME field. For example, this could be the Purchase Order number.

Below are the fields available in the functional module, and you will need to populate these values:

  • MANDT - Client number, where the update needs to be executed.
  • TDOBJECT - The object name for which the text lines need to be updated (e.g., EKKO for Purchase Order Header, EKPO for Purchase Order Item). It is not always the table name. For example, MATERIAL for the Material Master. The best way to determine the object name is to manually enter long text at the object level and check the STXH table for a corresponding entry with a value.
  • TDNAME - SAP PO number. If you are loading text for an item, it will be the PO number concatenated with the item number.
  • TDID - Identifier for header or item-level text (e.g., F01 for PO Header, F00 for PO Item). Check the STXH table to verify the generated value if you're uncertain.
  • TDSPRAS - Language code, typically E or EN.
  • TDFORMAT - Generally set to *, as it indicates the start of a new line.
  • TDLINE - The original text that needs to be loaded into SAP.
Parallel Processing

Map the entire query to the next query transform so that it becomes a segment. For example, I created a filter query transform.

Call the Functional Module

To call the functional module, you need to create a query transform. For example, I created the Func_Call query transform.

  • Right-click on Schema Out and select New Function Call...
IDoc Design
  • Select the datastore from the left panel and choose the functional module that you imported.
    IDoc Design
    
  • Map the fields and segments. In this case, we have only one segment, so map the segment to the corresponding field. If the field is not available in the source structure, map it to NULL.
    IDoc Design
    
  • Move the output field to the right to view the return values from the functional module. Click Finish.
    Output Field
    
  • Attach a target table so that you can receive the output.
  • Long Text for Purchase Order Using a Functional Module Loaded to S4HANA

    Enter the t-code for the purchase order, ME23N, and navigate to the Header under the Text tab to verify that the text has been uploaded successfully.

    Output Field
    

    Conclusion

    The functional module you reviewed above is specifically for loading long text. This functional module can be used to load long text for any object; the only adjustments required are to the TDOBJECT and TDID. For example, if you're loading long text for the Material Master, the object name will be MATERIAL and the ID will be BEST, instead of EKKO and F01 respectively. You also learned how to call a functional module using BODS.