By using Reference modification, move the last two chars to a new working storage variable and then check whether that new variable is > spaces. If yes, then last two chars of the string is ALPHANUMERIC else not.
It's amazing how these "simple" ques can get complicated. Prodigy asked if you can test that the last 2 chars of a field are alphanuneric, but his example shows the last 2 chars as alphabetic.
Does he mean A or AN. My guess is that he meant A, else he would have used something like W6 as his last 2 chars. Also does he consider a space an alpha; the alpha class test does.
Anyway, I'd try:
Code:
IF HIS-FLD(n:2) IS NOT ALPHABETIC
OR
HIS-FLD(n:1) = SPACE
OR
HIS-FLD(n + 1:1) = SPACE
DISPLAY 'FIELD IS NOT ALPHA AND/OR CONTAINS SPACES'
ELSE
DISPLAY 'FIELD LOOKS OK TO ME'
END-IF
It gets even more complicated if the last 2 chars are not always in the same place.
The given example was '- 12345WE'. Now what happens if the value is '- 123WE' ?
Can this happen?