We have a "string" / Character(15) variable which we need to validate characters 5 through 10 are numbers. This is pretty straightforward when writing raw code and using regular expressions, or when using Genexus to build Java objects, but we are using Genexus and building to RPG IV.
I'm relatively new (less than a year) to this platform, so I'm not sure how to do this. I'm told that the regex functionality in the version Genexus we use doesn't work for RPG. My suggestion to pull a substring and get the val() of it will cause an error if it's not all numbers, halting the program. Apparently, there's no way to gracefully handle the error in our version Genexus/RPGLE.
Does anyone have experience dealing with this? Can someone point us in a good direction, using Genexus for RPG, to resolve this issue?
You may write a procedure that does the checking "by hand".
i.e.:
&str = '1234567890ABCDEF' // this would be the input string
&isValid = 1 // this would be the output
if len(&str) > 9
for &index = 5 to 10
&char = substr(&str, &index, 1)
do case
case &char = '0'
case &char = '1'
case &char = '2'
case &char = '3'
case &char = '4'
case &char = '5'
case &char = '6'
case &char = '7'
case &char = '8'
case &char = '9'
otherwise
&isValid = 0
exit
endcase
endfor
else
&isValid = 0
endif