8 Replies Latest reply: Nov 19, 2014 2:33 AM by anbu cheliyan

# Looping with Concatenation

Hi All,

How the looping is done with concatenation.

Actual:

Month1,

Year1,

KeyData

Resident Temp;

Conatenate

Month2,

Year2,

KeyData

Resident Temp;

Conatenate

Month3,

Year3,

KeyData

Resident Temp;

Conatenate

Month4,

Year4,

KeyData

Resident Temp;

Can we write a Loop statement so that it loops for 4 times with concatenating the data so that my code size decreases?

• ###### Re: Looping with Concatenation

Temp:

KeyData,Month1,Year1,Month2,Year2

1,Jan,2011,Feb,2012

2,Jan,2011,Feb,2012 ];

For I = 1 to 2

Temp1:

Month\$(I) As Month,

Year\$(I) As Year,

KeyData

Resident Temp;

Next

• ###### Re: Looping with Concatenation

HI ,

• ###### Re: Looping with Concatenation

If you have same field names, concatenation happens automatically

• ###### Re: Looping with Concatenation

Temp:

KeyData,Month1,Year1,Month2,Year2

1,Jan,2011,Feb,2012

2,Jan,2011,Feb,2012 ];

For I = 1 to 2

Concatenate

Month\$(I) As Month,

Year\$(I) As Year,

KeyData

Resident Temp;

Next

• ###### Re: Looping with Concatenation

What If i want to load

Key, Month1, Year1 seperately and then Concatenate the Looping Table.?

Because While loading Key, Month1, Year1 I will load one more calculated field and that field will not have value to other rows.

Like below:

Month1 As Month,

Year1 As Year,

KeyData,

X+y = Z

Resident Temp;

Concatenate

For I = 2 to 3

Month\$(I) As Month,

Year\$(I) As Year,

KeyData

Resident Temp;

Next

• ###### Re: Looping with Concatenation

Temp1:

Month1 As Month,

Year1 As Year,

KeyData,

X+Y As Z

Resident Temp;

For I = 2 to 3

Concatenate

Month\$(I) As Month,

Year\$(I) As Year,

KeyData

Resident Temp;

Next

• ###### Re: Looping with Concatenation

Am I doing some mistake?

I should Get only one table But

I am getting two tables with a SynTable.

Temp:

Key, Week1, Week2,Week3, Act1, Act2, Act3, For1, For2, For3, Zero

ABC, 1, 2, 3, 20, 30, 40, 20, 30, 40, Y

BCD, 1, 2, 3, 20, 30, 40, 15, 30, 100

DEF, 1, 2, 3, 20, 30, 40, 25, 50, 200

];

For i = 1 to 3

if (\$(i)=1) then

Main:

Key,

Week\$(i) as Week,

Act\$(i) as Act,

For\$(i) as For,

Zero

Resident Temp;

ENDIF

if (\$(i)>1) then

Concatenate

Main:

Week\$(i) as Week,

Act\$(i) as Act,

For\$(i) as For

Resident Temp;

Next

Drop Table Temp;

• ###### Re: Looping with Concatenation

You missed ENDIF for second If statement

Temp:

Key, Week1, Week2,Week3, Act1, Act2, Act3, For1, For2, For3, Zero

ABC, 1, 2, 3, 20, 30, 40, 20, 30, 40, Y

BCD, 1, 2, 3, 20, 30, 40, 15, 30, 100

DEF, 1, 2, 3, 20, 30, 40, 25, 50, 200

];

For i = 1 to 3

if (\$(i)=1) then

Main:

Key,

Week\$(i) as Week,

Act\$(i) as Act,

For\$(i) as For,

Zero

Resident Temp;

ENDIF

if (\$(i)>1) then

Concatenate

Main:

Week\$(i) as Week,

Act\$(i) as Act,

For\$(i) as For

Resident Temp;

ENDIF

Next

Drop Table Temp;