Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
JustynaK
Partner - Contributor II

For each loop with a variable

Hi,

i have data:

Table:

Equ,

Class

 

I need to use For each loop based on Equ values, but inside the loop I need to create a variable with corresponding Class value - how to do that? 

For each i in FieldValueList ('Table')

let vClass = ???

load final table..

next i

Appreciate your help

 

 

Labels (3)
1 Solution

Accepted Solutions
Vegar
MVP

You could solve this by creating an mapping table from equ to class. 

 

Table: Load Ecu, Class From Source;

MapClass: Mapping Load Ecu, Class Resident Table;

For each i in FieldValueList ('Ecu') //FieldValueList takes field name as parameter, not table name

     let vClass = applymap('MapClass', '$(i)', 'Not mapped');

      load final table..

next i

View solution in original post

3 Replies
rubenmarin

Hi, you can add the value as: 

For each vClass in FieldValueList ('Class')

LET vClass = '$(i)';

But note that this variable will be overwritten with each iteration of the for each bucle. Is this what you want?

Vegar
MVP

You could solve this by creating an mapping table from equ to class. 

 

Table: Load Ecu, Class From Source;

MapClass: Mapping Load Ecu, Class Resident Table;

For each i in FieldValueList ('Ecu') //FieldValueList takes field name as parameter, not table name

     let vClass = applymap('MapClass', '$(i)', 'Not mapped');

      load final table..

next i

JustynaK
Partner - Contributor II
Author

Hi, no this is not what I mean. Because for each Equ I need to take the exact class that is assigned to Equ. 

So having data:

Table:

Equ        Class

1              A

2              B

3              A

4              C

I need a loop 

For each i in fieldvaluelist('Equ') e.g. 1

load some data

where Class = A,

for i=2...

load

where Class = B

...