Table stored in Data table for validation (attached file for your DT reference)
comm_purch.xlsx (9.8 KB)
Note: Each value separated by comma in 2 columns in DT (Refer screenshot below)
Example values store in variable:
Str_Commodity = “D” or “E” or M
Str_PurgOrg = “0002” or “HCGA” or “IADM”
Requirement:
Need to match 2 string variables values with any one of the value (separated by comma) both 2 columns in Data table.
Expected output:
When Str_Commodity = “D” and Str_PurgOrg = “0002” then expected output in str_status variable is “Yes”
When Str_Commodity = “D” and Str_PurgOrg = “HCHK” then expected output in str_status variable is “No”
ppr
(Peter Preuss)
May 6, 2024, 11:41am
2
Assign Activity:
hasFound | Boolean
(From d in dtData.AsEnumerable
Where d("Commodity").ToString.Trim.Split(","c).Any(Function (c1) c1.Trim.Equals( Str_Commodity))
Where d("PurchOrg").ToString.Trim.Split(","c).Any(Function (c2) c2.Trim.Equals( Str_PurgOrg))
Select r=d).Any()
UPD1 -
However kindly note:
there would be a match or you should organize the checks different
Anil_G
(Anil Gorthi)
May 6, 2024, 11:45am
3
@Sathish_Kumar_S
Try this
dt.AsEnumerable.Any(function(x) x("Commodity").ToString.Split(","c).Any(function(y) y.Trim.Equals(str_commodity)) AndAlso x("org").ToString.Split(","c).Any(function(y) y.Trim.Equals(str_purgorg)))
This gives true if atleast one row matches else it wont
Cheers
1 Like
ppr:
Str_Commodity
Sorry i made a mistake in the logic…
*When Str_Commodity = “D” and Str_PurgOrg = “HCHK” then expected output in str_status variable is Should be "YES
*When Str_Commodity = “D” and Str_PurgOrg = “PIND” then expected output in str_status variable is Should be “No”
ppr
(Peter Preuss)
May 6, 2024, 11:49am
5
then go ahead with the given approaches. Kindly note that we handled the return as Boolean as this is the appproproate Datatype for a check
system
(system)
Closed
May 9, 2024, 11:50am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.