Long texts are a powerful asset in data management, providing detailed information beyond standard text descriptions. They allow businesses to capture essential details like ingredient descriptions, vendor remarks, and item details. However, long texts cannot be uploaded using data objects in the SAP Data Migration Cockpit (Migrate your Data Fiori App in S/4 HANA 2020).
Load Long text into SAP S4 HANA using BODS
Loading long texts into SAP S/4HANA can be a complex task, but SAP has provided an FM RFC_SAVE_TEXT that can serve this purpose. To load data using RFC_SAVE_TEXT, you may need to split long strings into equal parts, especially when dealing with tables like STXL and STXH in SAP.
Here’s a step-by-step guide to load long texts into SAP S/4HANA using SAP Data Services:
- Source data Extraction: We have a string with a length of 1032 symbols, and our goal is to split it into equal pieces of 132 symbols each. This is necessary as we need to provide these equal parts as input to the FM RFC_SAVE_TEXT during the data extraction process.
- Data Transformation: By utilizing the Row generation transform in a script and dataflow, we achieve the split of the long string into equal parts.
- Script: Initialize a variable with a maximum length of the long text using the script in BODS.
- Data Flow: Create a data flow that contains all the transformations to be done.
- Row Generation transform: Use the Row Generation transform to build the desired structure with equal parts of the long text. Set the Row number to start at 1, the Row count to equal the length of the longest string divided by the chunk size (round up the result), and the Join rank to 0.
- Query transform “Split”: create a new Substring column of desirable size(split_size) and Map DI_ROW_ID from Row_Generation as shown below:
substr(<source_string>, (Row_Generation.DI_ROW_ID*<split_size>)+1,<split_size> )
where split_size is the length of the split data
- Query transform “Not_Null”: For each long string, $GV_MAX_LEN indicates how many substrings are to be generated. In a source dataset containing multiple strings, shorter ones will generate NULL values. The WHERE tab should be set to exclude such records.
- Execute the job to get the multiple strings, as shown below
- Data Load: Use FM RFC_SAVE_TEXT to load data into SAP. Build Data flow as shown below:
Use the SELECT DISTINCT statement to find the driver records (e.g., TDNAME) from the STXL table.
Qry_TEXT_LINES contains the data for the long text.
Qry_Nest: Combine the data using driver records and create the structure as in Qry_TEXT_LINES which can be used in the FM RFC_SAVE_TEXT.
(e.g., Qry_TEXT_LINES.TDNAME =Qry_DRIVER_REC.TDNAME).
Import the FM RFC_SAVE_TEXT and call the FM RFC_SAVE_TEXT in the query.
Map the table TEXT_LINES to pass the data to SAP.
Read Long Text from SAP S4HANA
To read long text from SAP S/4HANA, you can use the function /BODS/READ_TEXT in SAP Data Services.
We need to extract TDNAME into the staging table in BODS. Then determine the parameters value TDID from CV03n t-code for the corresponding long text.
The function module /BODS/READ_TEXT in Data Services can be used to read data from SAP.
Extract the TDNAME(Hearder data ) from STXL for the particular TDID and pass it through the FM READ_TEXT
Map the corresponding fields from the query and click the next button.
After clicking the Next button, you should select the Columns you want to output from the function.
The required long text data is available in the LINES column and there it should be selected as the output column.
Un-nest the LINES table by dragging all of its columns out of the Schema In section and placing them in the Schema Out section. TDLINE field contains the data.
Next, create a target table and execute the job.
The function will return the multi line long text data.