
How to transpose a string into a table using…
You are probably aware that Excel has a great function to convert a row of data into a column. This action is called “transpose”. In some cases you might want to do the same in BRF+, for example converting words within a sentence into individual words in a single column.
There are no standard solutions within Business Rule Framework to transpose. This means that you have to build this functionality yourself.
It makes sense to create a separate application in BRF+ that contains core functions that replicate functionality, such as the transpose requirement. The aim is to collect functions that can be used in any other application that is linked to a specific object (e.g. sales order, production order or purchase order). This system application will contain functions that is not meant to be called in ABAP code, but only called within other BRF+ functions in other applications. It is probably best to call this the application containing support functions.
These support functions are stored in a system application to make them immediately available in all clients within a SAP system. Obviously has the impact that the signature for these support functions have to be stable when they are going to be used in other BRF+ functions. Normally that should not be a problem because these support functions should not be complex.
For example, you want to transpose the text “Business Rule Framework” into a table with one column containing three rows with the words “Business”, “Rule” and “Framework”.
How do you do that within BRF+?
You can achieve this goal by having two support functions:
- GET_SUBSTRING, and
- CONVERT_STRING_TO_TABLE
The GET_SUBSTRING function uses sentence and to derive the first word.
That sounds a very straightforward task, but you will discover that the formula functions within BRF+ cannot use the pace as a delimiter.
So you need to build a loop to scan the sentence from left to right and find the first character that is identified as a delimiter.
You stop as soon as you have found a single word.
The CONVERT_STRING_TO_TABLE puts words into a table.
That requires a loop to call the support function GET_SUBSTRING.
Every time a word is found then this needs to be removed in your original sentence, else you trigger an endless loop.
There will be obstacles along the way, but eventually you end up with a very efficient support function that is universal.
When you have created your first support function, you find out that these will be valid in any SAP system, irrespective which SAP client and independent to what extend this client has deviated from standard SAP.
You will start collecting these universal support functions. Who knows, you might even be able to monetize them or trade them for support functions other BRF+ consultants have made.