cancel
Showing results for 
Search instead for 
Did you mean: 

Appending results to a Result table in a Loop Expression

former_member471901
Discoverer
0 Kudos

I have a table of items that I want to loop through. In the loop is a search tree. The search tree may add several lines to an error table.

I want to do two things:

1) For each node in the search tree that creates an error line, add it to the error table.

2) For each iteration through the loop, add these error lines found to a result error table.

So for instance, one iteration through the loop may find 3 errors from 3 separate search tree nodes. I want those added to the final error result set.


Can somebody advise me how to do this, or provide an example?

Accepted Solutions (0)

Answers (1)

Answers (1)

christianlechne
Active Contributor
0 Kudos

Hi Anthony,

there are several ways how you can acheive this requirement, but it depneds how our error table might look like. In general I assume that the error table is either part of the BRFplus context or is the result object.

In general you can assign the table as a result object to your loop expression and to your search tree. Within the search tree you have to use the multiple match mode in order to iterate the complete tree and return all matches found. The matches will be appended to the result table by BRFplus, so there is no need to do anything. As result nodes you can either assign another context value or an expression that returns as result a line of the error table. To make it a little bit more concrete: Let us assume your error table consists of lines that just represent an error code (so a table with one column). You can then assign expressions of type constant as result nodes to your search tree. These constants contain the relevant error code and get appended to the table whenever the corresponding conditions are fulfilled.

The same way is valid if you use a structure.



As an alternative you can completly omit the table and write your error messages into the application message log using the log message action (using the non-persitent option). In this case the reesult of the search tree (and of course of the loop) is not a table anymore. This way you can write your messages into the applications log memory (resuing the messages of your backend including an easy usage of placeholders). You can then either just persist the messages after the call of the BRFplus function in the backend or even adjust them and then do the persistency.

Last but not least perhaps it might also be an option to replace the search tree by a decision table and its features (liek completness check etc). As for the search tree you have to use the multiple match mode (aka return all matches found) in order to fill a result table.

Hope that helps

BR

Christian

former_member471901
Discoverer
0 Kudos

Hi Christian,

Thank you! A detailed and very helpful explanation - much appreciated!

BR,

Tony.