Excel Grouping and Looping in SAP

I have an excel file with three Columns of data and I want to copy all the data into SAP. I need a way to paste in 20 rows at a time into SAP and repeat the process until all have been pasted. Im still learning how to use UIpath, so any suggestions or help would be greatly appreciated.

Assign NoOfSegments=total no of rows/20
loop through each of the segment in Enumerable.Range(0,NoOfSegments).ToList

Assign row(list of datarow)=inputDatatable.AsEnumerable.Skip(segment*20).Take(20).toList

//This will take 1st 20 in the first loop, next 20 in the 2nd loop and so on

Hi @jokano1

See the solution below from @Lak_Ui and additionally check the SAP Training,

  • SAP Academy course , to help you to learn the automation techniques and the best practices for SAP WinGUI automation

Best regards, Lev

1 Like

@Lak_Ui Thank you for your response.

Just for clarification:

  1. I will get total number of rows from read range, then, dtTableVariable.Rows.Count/20 into a variable.

  2. I would use a “For each (segment)” loop to loop through the segments with the formula you mention above.

  3. Use another assign (“row” in your example) and the formula above.

If im adding activities to paste the segments into SAP, i would add those actions in another loop with the “row” variable from step 3? another For each loop, im assuming?

Hi @jokano1

You can use the same loop in step2 inside of which you will be defining row variable
for pasting as well

Hi @Lak_Ui

I was able to get the row count and calculate the segments, but im having trouble with the looping portion. I am attaching the file of the test flow i created.

Excel_Pasting.xaml (8.1 KB)

Excel_Pasting.xaml (9.4 KB)
Please check this

Hi @jokano1

Did you get a chance to check this?

Yes, I got it working! Thanks for your help.

1 Like

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