cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Table In Table Out

Former Member
0 Likes
371

Hi Experts,

I have a situation wherein I want to input a table (as context) and output a table (as result). I have gone thru various forums (SCN included) and the general impression I get is that this is possible. However I have tried various options (loops, temporary variables with initialization etc.) but haven't got the results I am expecting.

The first thing I tried was a simple table input (the table had just one column but multiple rows, each cell of the table had an individual's name e.g if there are three rows in the table then each row contains one individual's name e.g John, Sarah and Michael).

So my input table looks like

User
John
Sarah
Michael

I used this table as context and then within the function I used a decision table (similar to one below) to find colors

UserColor
JohnViolet
JohnIndigo
JohnBlue
SarahGreen
SarahYellow
MichaelOrange
MichaelRed

Now when I executed the simulation using input "Sarah" in the context. the output I get is a table output similar to one below (which is good)

Color
Green
Yellow

However now I want to run a loop where the system first takes John as input context, processes the decision table,  then takes Sarah as input context and processes the decision table and finally takes Michael as input context and then processes the decision table.

I expect that the final result should be a combination of all outputs (for each individual iteration) and should look like below

Color
Violet
Blue
Indigo
Green
Yellow
Orange
Red

However in actuality, when I run the loop, I get the following output

Color
Orange
Red

When I see the simulation steps, I see that the system did actually run 3 iterations (one each for John, Sarah and Michael) and calculated the correct result for each iteration but when it presented me the final result, it showed only that of the last iteration (for Michael) and hence I see only the Orange and Red as final output instead of all the colors.

Is it possible to see the output (combination of all three iterations). Please advise.

BR,

Surya

Accepted Solutions (1)

Accepted Solutions (1)

christianlechne
Active Contributor
0 Likes

Hi Surya,

I just implemented your scenario and I think I know where the problem is located:

The function has as context the list of the users (data object table) and as result object a table which consists of the colors:

The assigned ruleset consist of one rule that changes the result data object after processing a loop expression

The loop itself simply iterates over each entry in the user list and calls a decision table which has the setting "Return all matches found":

The crucial point is here that the rule is defined as inserting into the result data object after processing the decision table. This leads to an append of the result values to the table.

You also have the option to change the table which will lead to an overwriting of the existing entries:

In your case i guess you have the CHANGE of the result data object as in this case my function only delivers the values of the last iteration whereas the INSERT into the result data object delivers the result as you described and expected.

BR

Christian

Former Member
0 Likes

This works perfectly Christian. Thank you very much for your time and patience.

Answers (1)

Answers (1)

christianlechne
Active Contributor
0 Likes

Hi Surya,

that is for sure possible. It is a little bit difficult to figure out the bug in your rules. Can you perhaps post screenshots of how you iterate over the input table and evaluate the decision table and how you modify the result table.

I would guess that you overwrite the result of your decision evaluation in each loop iteration. You should make sure that you use an insert into the result table instead of changing it

BR

Christian

Former Member
0 Likes

Thanks Christian. I should have some screenshots ready for you shortly.