Creating Dynamic Variables in UiPath

I have a loop which extracts datatables from SAP and an activity in the loop to get the SAP table extract and import to a DataTable in UiPath. I need to to be able to somehow create tablenames and reference these in the loop.

My Loop to go through the SAPTables which i have specified
image

I then have a sequence to get the table data and export this to a UiPath DataTable.
However, as these are all different table names (i.e. pa2001, pa2002, etc.) I need to be able to put the data for the current table name (item) into its own DataTable.

Hi @Nicholas_Doss

I think you can use the Dictionary type variable to simulate what you want.
Put your different DataTable data map to each Dictionary value instead of many variable for furture use.
For instance:
paDic As New Dictionary(Of String, DataTable)
paDic.Add(“pa2001”, pa2001)
paDic.Add(“pa2002”, pa2002)
You can get or change them by paDic(“pa2001”) and paDic(“pa2002”)

2 Likes

Hi @wusiyangjia

I have used your method to do the following.

Create a variable myDictionary as being String, Datatable
Using an assign activity to assign the values to myDictionary
Then I have referenced myDictionary(“PA2001”) to return the value into an argument. However, it does not actually put the data into the datatable PA2001.

Hi @Nicholas_Doss

I don’t know your mean very well.
It’s work well like below.
Sequence

2 Likes

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