timcons2 Respected Contributor.
Respected Contributor.
616 views

Re: How to select row data to run in datatable

Jump to solution

hi

I have multiple row data in a single datatable.

And I would like to pick some of the row data to run. e,g, I only want to run row 1, 3, 6 from 9 row of data in the table.

I create one column called run and if the run is Y, then the record of data will be selected to run. If no, then it will move to next row of record.

Appreciate if someone can mentor me how to work it.

0 Likes
1 Solution

Accepted Solutions
Highlighted
liorde Honored Contributor.
Honored Contributor.

Re: How to select row data to run in datatable

Jump to solution

Hi there.

Are you talking about an Excel datatable?
You take data at runtime and you wish to decide what to do with the current row?
If yes, then you should loop over the current rowcount of this data-table and have an additional loop inside that you will be able to "break" if the spcified "run" column, is not set to 'Y'.

Maybe something like this :

rows = datatable.GetRowCount

For idx = 1 to rows

    datatable.SetCurrentRow(idx)
    
    For j = 1 To 1 
        
        run_row = datatable.Value("RUN")
        ' check if to run this row or not
        If (ucase(run_row) <> "Y") Then
            Exit for ' like BREAK in C-language
        End If

        ' your code
        ' your code
        ' your code

    Next
    
    ' your code
    ' your code
    ' your code
        
Next

0 Likes
1 Reply
Highlighted
liorde Honored Contributor.
Honored Contributor.

Re: How to select row data to run in datatable

Jump to solution

Hi there.

Are you talking about an Excel datatable?
You take data at runtime and you wish to decide what to do with the current row?
If yes, then you should loop over the current rowcount of this data-table and have an additional loop inside that you will be able to "break" if the spcified "run" column, is not set to 'Y'.

Maybe something like this :

rows = datatable.GetRowCount

For idx = 1 to rows

    datatable.SetCurrentRow(idx)
    
    For j = 1 To 1 
        
        run_row = datatable.Value("RUN")
        ' check if to run this row or not
        If (ucase(run_row) <> "Y") Then
            Exit for ' like BREAK in C-language
        End If

        ' your code
        ' your code
        ' your code

    Next
    
    ' your code
    ' your code
    ' your code
        
Next

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.