SAP Data Services, SAP Fiori, SAP HANA Studio

Handling Long Text – Migration Perspective

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.
Fig 1.Source data
  • Data Transformation: By utilizing the Row generation transform in a script and dataflow, we achieve the split of the long string into equal parts.
Fig2: Data Flow
  • Script: Initialize a variable with a maximum length of the long text using the script in BODS.
Fig3:Inside the script
  • Data Flow: Create a data flow that contains all the transformations to be done.
Fig4: Screenshot inside the data flow
  • 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.
Fig 5: Rowgen transform
  • 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

Fig 6: Query split
  • 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.
Fig 7:Query_not_null
  • Execute the job to get the multiple strings, as shown below
Fig 8: After transformation
  • Data Load: Use FM RFC_SAVE_TEXT to load data into SAP. Build Data flow as shown below:
Fig 9: Load flow

Use the SELECT DISTINCT statement to find the driver records (e.g., TDNAME) from the STXL table.

Fig 10:Qry_driver_rec

Qry_TEXT_LINES contains the data for the long text.

Fig 11:Qry_TEXT_LINES

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).

Fig 12:Query_NEST
Fig: 13Qry_TEXT_LINES

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.

Fig 14:Qry_Call_RFC_SAVE_TEXT
Fig 15: FM-RFC_SAVE_TEXT
Fig 16: Messages from RFC
Fig 17: Loaded data

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.

Fig 18:Job for reading data from SAP

Extract the TDNAME(Hearder data ) from STXL for the particular TDID and pass it through the FM READ_TEXT

Fig 19: Query_RFC
Fig 20: 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.

Fig 21: Output Parameter

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.

Fig 22: Long text from SAP

The function will return the multi line long text data.