How to loop multiple rows

Hello all,
I need to enter some values in SAP…
I have created My flow as below

  1. read the excel file and store it as DT
  2. For each row in DT

Now how to enter these values in SAP using type into activity.
If I give row(0).tostring it entering only column A, 200,210,2000,2200,

what I need is it should enter 200,300,400
How to loop horizontally.


1 Like

Each row is an array. You can fine tune this fundamental concept into shape. So here it is:

'Width of each row is the count of columns of the table
Assign ColumnCount=DT.Columns.Count()
For Each row in DT
'Initialize Column counter 
Assign x = 0
   Assign cellValue=row(x).ToString()
  ' Do something with cellValue 
  ' Example x=0 then put cell value in SAP Box1, 
  ' if x=2 then put cell value in SAP Box2, etc.

   'Read next column in current row
   Assign x=x+1
'next row
End For Each


Here row(0) refers to first column.

You need to use row(1).ToString and row(2).ToString to take second and third column.


Hope these steps would help you resolve this

  1. Use a FOR EACH ROW loop and pass the dt variable as input

  2. Inside the loop use a assign activity like

Counter = 0

Where counter is a variable of type int32 with default value as 0 created in variable panel

  1. Followed by this assign use a WHILE LOOP inside the loop and pass the condition like this

counter < dt.Columns.Count

  1. Inside this while loop use a TYPE INTO Activity like this with the inlut


This will type the first row and first column

  1. Inside the same while loop next to the above activity use a assign activity like this

counter = counter + 1

Now this will increment the loop and type first row second column and then in next loop - first row third column
Once all three columns are typed, while loop will get over and next row in for each row will start

Which in turn will start again the while loop and type second row first column, second row second column and second row third column

Like wise it goes for all rows and columns

But make sure that you have used dynamic selectors in type into activity by replacing changing attribute values with * wild card symbol
Only then the three columns value will get type to its respective fields
Else it will type in the same field again and again

Hope this would help you

Cheers @tkiran

1 Like

Hi Palaniyappan,

It works… thank you so much

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.