I have an error in a report when I try to split a field that doesn’t have the index value in the field. the first 22 worked but the 23rd didn’t exist but it may in some cases. I have potentially 1 to 78 indexes and it may vary.
Another option is to use Report Functions. In the Report Properties, there’s a Code section and you can write small VB routines:
Public Function ConvertToTable(ByVal s as String) as String
Dim sa() as string
sa = split(s, "~")
if (sa.Length < 78) then
return("")
end if
Return sa(77)
End Function
Interesting, I haven’t used report functions. So this looks like it would make a table of 78 and even if the text I’m splitting has a variable amount less than 78. Then I can check the value isn’t “” and use it.
All standard Epicor reports use Report Functions so check out what they’re doing. There’s no syntax check until you upload it so do a little at a time and build on it.
The field data below has separated returns of chr(13) I can split each and put them in specific fields on the report until I hit one missing in the index value then everything I’ve tried will return an error.
A)W/C 7.63 X 9.7 X 30.18 W/SKIN B)W/C 5.13 X 9.7 X B)W/C 5.13 X 9.7 X 30.18 C)W/C 7.63 X 9.7 X 30.18 W/SKIN D)W/C 5.13 X 9.7 X 30.18 E)S/C 1.67 X 12.5 X 31 W/SKIN F)F/C .67 X 12.5 X 25 W/SKIN G)D/C 1.5 X 28.18 X 31 W/SKIN H)W/C .125 X 18.5 X 26 (PLS-.125) I)W/C .125 X 1.5 X 30.18 (PLS-.125) J)F/C .5 X 30.18 X 35.4 W/SKIN K)F/C .5 X 10 X 13 W/SKIN L)F/C 3 X 20.5 X 30 W/SKIN M)F/C .5 X 20.5 X 26.5 W/SKIN N)W/C 3 X 10 X 30 W/SKIN O)W/C 2 X 9.72 X 30.18 W/SKIN P)W/C 4.13 X 9.72 X 30.18 W/SKIN Q)F/C 2X9.72X30.18 W/SKIN U)CASE ASSY R)LAM A-F,J,I&V V)W/C.13X1.5X30.18 W/ S)LAM K - M W)W/C 5.13X9.72X30.18 W/S T)LAM O-Q,H,W&X X)W/C1.88X7.6X26.18W/NNN U)CASE ASSYR)LAM A-F,J,I&V V)W/C.13X1.5X30.18 W/S)LAM K - M W)W/C 5.13X9.72X30.18 W/ST)LAM O-Q,H,W&X X)W/C1.88X7.6X26.18W/NNN
This is the code in a field expression that works. Each field uses a specific number of the index.
And you’re sure its a base 1 (meaning GetValue(1) returns the first element), and not base 0 (where GetValue(0) returns the first, and GetValue(22) would return the 23rd) ??
the problem is each record changes it the number of elements. may be one to 78. as soon as the number doesn’t exist there is an error. I’ve even tried a IIF it is over a number to put “” and it still evaluates if it contains the index and errors. I haven’t found a way to ignore the error.
Are you sure you’re getting the Split that you think? I’m only guessing at what your data is supposed to be, but the following looks like it failed to split some “records”
Public Function GetItem(ByVal s as String, itm as integer) as String
Dim sa() as string
sa = split(s, chr(13))
if (sa.Length < itm) then
return("")
end if
Return sa(itm)
End Function
Then your expression would be same on every item but you would vary the index: