How to: |
Given a search string, a source string, and a starting position, POSITION returns the position of the search string within the source string. The search starts at the given starting position and searches from left to right. If the string is not found, POSITION returns zero (0). The search is case sensitive.
POSITION(search, source, start)
where:
Alphanumeric
Is the search string.
Alphanumeric
Is the source string.
Numeric
Is the starting position in the source string for the search.
The following request uses POSITION twice, once to find the first occurrence of the character A after starting position 3 in FULLNAME, and once to find the first occurrence of the character a after starting position 3 in FULLNAME.
TABLE FILE WF_RETAIL_CUSTOMER PRINT FULLNAME COMPUTE POS1/I5 = POSITION('A', FULLNAME, 3) ; POS2/I5 = POSITION('a', FULLNAME, 3) ; WHERE RECORDLIMIT EQ 5 ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image.