We help IT Professionals succeed at work.

Loop through dynamic array, set each position as variable.

RWayneH
RWayneH asked
on
I have a scenario that I have to loop through values that are in a dynamic array or string.  Looking for some guidance in understand this.



AllTabs=SAPGuiSession("Session").SAPGuiWindow("Display Normal Order 200760677").SAPGuiTabStrip("TABSTRIP_CHAR").GetROProperty("allitems")

AllTabs output could be  "GR_01;GR_02;GR_03;SG_01;SG_02;SG_03;SG_04;SG_05;SG_06;SG_07;SG_08;SG_09;SG_10;SG_11;SG_12;SG_13;SG_14;SG_15;SG_16;SG_17;"

I am trying to loop thru the values starting with GR_01, and defining it as a var, like make it H = to whatever is in first position.

For i = 0 to ubound(AllTabsB)
            CurrentTab=SAPGuiSession("Session").SAPGuiWindow("Display Normal Order 200760677").SAPGuiTabStrip("TABSTRIP_CHAR").GetROProperty("selecteditem")
                  If CurrentTab = H Then
                  MsgBox "On right tab"
                        SAPGuiSession("Session").SAPGuiWindow("Display Normal Order 200760677").SAPGuiTabStrip("TABSTRIP_CHAR").Select i
                  Else
                  MsgBox "On WRONG tab"
                  End If
            Datatable.GetSheet("Results").AddParameter AddAdditionalResultParametersForFunction(i),""
      Next
Comment
Watch Question

Test your restores, not your backups...
Top Expert 2016
Commented:

Perhaps this, if I am understanding correctly, assuming the case will match, if not then do UCase() on both sides of the If statement values.


AllTabs = SAPGuiSession("Session").SAPGuiWindow("Display Normal Order 200760677").SAPGuiTabStrip("TABSTRIP_CHAR").GetROProperty("allitems")

AllTabsArray = Split(AllTabs, ";")
For i = 0 To UBound(AllTabsArray)
    CurrentTab = SAPGuiSession("Session").SAPGuiWindow("Display Normal Order 200760677").SAPGuiTabStrip("TABSTRIP_CHAR").GetROProperty("selecteditem")
    If CurrentTab = AllTabsArray(i) Then
        MsgBox "On right tab"
        SAPGuiSession("Session").SAPGuiWindow("Display Normal Order 200760677").SAPGuiTabStrip("TABSTRIP_CHAR").Select i
    Else
        MsgBox "On WRONG tab"
    End If
    Datatable.GetSheet("Results").AddParameter AddAdditionalResultParametersForFunction(i),""
Next

Author

Commented:
Thank you, I just had to chg one thing for it to work in Ln8, instead of .Select i     it was .Select AllTabsArray(i)  Nothing major, and the procedure worked great.  Appreciate the help.

Author

Commented:
This helped me understand the use of Arrays,  Thanks.
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Welcome.