The reason we cannot use the READ_TEXT function in an ABAP mapping is twofold:
- It requires table parameters - which cannot be used in ABAP dataflows
- It does raise exceptions if no data is found - a condition which would be okay for us
Therefore the solution could be to write a new SAP function module using the READ_TEXT function inside but doing exactly what we want it to do.
The code I came up with is:
This function does not have any exceptions by itself, so even if the READ_TEXT function does raise one, it will finish successfully and return an empty text.
This function we can now import into the SAP datastore and use it like any other SAP function inside a SAP dataflow.
In this example I used it in a second query, the first query got an extra column called VBELN_POSNR which is the concatenation of those two column (mapping: VBELN || POSNR).
I have uncovered a couple of bugs in the product when playing with this exercise. The basic problem is always the datatype. You import a function and when opening it in the object library the column length is wrong, e.g. all varchar(10). So you have to adjust it manually by editing this column.
Or the function expects a varchar(70) but we assign the concat of VBELN || POSNR which is a varchar(16) to it. Result is an execution error when running the ABAP. So you need to make this column you pass into, a varchar(70).