Use SAP Data Services to Read Long Text from ECC

This post will show you how to use SAP Data Services to extract long text for document info records (DIRs) from SAP ECC and load them into a target table.  This approach can be used for other objects as well.

The high-level steps involve:

  1. Extract table STXH into staging database
  2. Get parameter values for /BODS/READ_TEXT from t-code CV03n
  3. Use function /BODS/READ_TEXT in Data Services to read long text
  4. Output results from function into target table

The first step is to import the /BODS/READ_TEXT function into SAP Data Services.

In the Data Services Designer, navigate to the local object library, expand the SAP ECC datastore, right-click on Functions and click Import By Name.

Enter /BODS/READ_TEXT into the Name field and click import.

2016-09-14_9-58-16

The function should now be available in the datastore (if you receive an error the function was not installed during initial installation or the user security needs updated).

2016-09-14_10-02-22

Next create a data flow and extract the STXH table into a staging database (typically you should not be reading directly from ECC; best practice is to replicate tables to staging database and read from there).

The next step is to retrieve the parameter values to enter into the /BODS_READ_TEXT function.

In ECC navigate to t-code CV03n and enter a Document Number and Document Type.  The document will be displayed.  Click the Long Text button to the right of the Description field.

2016-09-15_8-33-07

Click Go-To > Header.  The Text Header window displays all the information required to populate the parameters in the function.

2016-09-15_8-39-10

Next create a data flow in Data Services with STXH as the source.  Create a query and connect it to the source.  Open the query and right-click in the Schema Out window and click New Function Call.

2016-09-16_10-09-49

Select the SAP ECC datastore as the function category and select the /BODS/READ_TEXT function.

The function will need to be populated with information taken from the Long Text Header window for the DIRs.  Most of the values will be hard-coded except for the Name parameter; we will be passing the TDNAME column from the STXH table into this field.

2016-09-15_9-05-50

Click the Next button.  Select the Columns you want to output from the function.  The LINES column contains the mult-line information and should be included.

2016-09-16_10-22-42

Create another query and attach it to the first query which has the function.

2016-09-16_10-32-56

 

In the second query we will need to unnest the LINES column.  Drag all of the columns from the Schema In into the Schema Out section.  Right-click on the LINES column and select Unnest.

2016-09-16_10-24-35

Now create a target table and execute the job.  The function returns the multi-lines for the DIR.  FYI the TDNAME concatenates the Client, Document Type, Document Version, Document Part, and Document Number.  These would need to be parsed out.

2016-09-16_10-35-36

 

Leave a comment