Working with BAPI to load Long Text in S4HANA using BODS
By Imran, Mohammad May 15, 2024 under BODS
Like IDoc, BODS supports BAPI too, BAPI is useful to load the data to S4HANA when you dont have IDoc available. The first thing you need to make sure before you start working on BAPI is to check whether the BAPI you would be calling to BODS is RFC enabled functional module. I will show below how can you check this. From this Blog, you will learn two things. First, how to load long text using BAPI. Second, calling an RFC Enabled functional module(BAPI) using BODS.
Functional Module (BAPI)
The Functional Module we are chooing here to load long text is RFC_SAVE_TEXT. Now, ensure the FM is Remote-Enabled by running a t-code called SE37.
- Run the t-code (SE37).
- Enter the Functional Mudule under the textfield and click Display.
- Under the tab Attributes, check if Remote-Enabled Module redio button is chosen. If any other radio buttong is chosen then that means the FM is not RFC Enabled. You will then need to connect with ABAP team to create a WRAPPER of this FM so that it can be remote-enabled and ready to be called using BODS.
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.
Design Source Structure
If required fields are aviable on header without any segment then you will need to map the fields directly. Or if the fields are avilable under a segment then you will need to create a input segment and map directly to FM. Lets design the source structure the way we have in the functional module. Ignore the design below if you are wroking on any other functional module because structure of the functional module varies. The design below is specifically for long text load for Purchase Order.
- In order to design your source structure for long text, you will need the help of STXH Table.
- The STXH table will tell what the value you will need to populate on those long text fields available in Functional Module.
- If you are not sure of the values, you can go to your object and enter a long text and save. Then come back to STXH table and enter your object number in TDNAME field. For Example - Purchase Order Number.
Below are fields available in the functional module and you need to pupulate the values for:
- MANDT - Client Number, where the update needs to run.
- TDOBJECT - The object name, the Text lines need to be updated for(For example: EKKO for Purchase Order Header, EKPO for Purchase Order Item). It is not always the table name. For exmple MATERIAL for Material Master. The best way to know the object name is to enter a long text manually at the object level and check in the STXH table that an entry with a value has been generated.
- TDNAME - SAP PO Number. if you are loading text for item then PO number with concatnation of item number.
- TDID - Identifier for Header or Item Level Text (For example: F01 is PO Header. F00 is PO Item) - Check the STXH table what value has been generated if you are not sure of the value.
- TDSPRAS - Language Code, which is generally E or EN
- TDFORMAT - Basicly it is always * because it enters a new line.
- TDLINE - The Original text which needs to be loaded to SAP.
Map entire query to the next Query transform so that it become segment. Like I created Filter query transform.
Call the Functional Module
In order to call the functional module, you will need to create a query transform. Like I created Func_Call query transform.
- Right click on the Schema out and choose New Function Call...
- Select the datastore from left panel and choose the functional module which you had imported.
- Map the fields and segments. In this case we have only a segment. So choose your segment to the corresponding mapping field. If the field is not availabel in source structure then map to NULL.
- Bring the output field to right so that you can view the return values from the FM. Click Finish.
- Attache a target table so that you can recieve the output.
Long Text for Purchase Order using a Functional Module loaded to S4HANA
Enter the t-code for purchase order which is ME23N and see at the Header under the Text tab that text is uploaded successfuly.
Conclusion
The Functional Module you saw above is particularly for Long text load. This Functional Module can be used to load any long text for any object the only thing needs to be changed is the TDOBJECT and TDID for example if you are loading long text for Material Master then object name will be MATERIAL and id will be BEST instead of EKKO and F01 respectively. You also leanrt how to call a Functional Module using BODS.