It is used to tally the occurrence of a single character or groups of characters in a data field.
INSPECT identifier-1 TALLYING identifier-2 FOR
ALL|LEADING literal-1|identifier-3
[BEFORE|AFTER INITIAL identifier-4|literal-2] - Optional.
INSPECT identifier-1 TALLYING identifier-2 FOR
CHARACTERS
[BEFORE|AFTER INITIAL identifier-4|literal-2] - Optional.
Main String is identifier-1 and count is stored in identifier-2. Literal-1 or Identifier-3 is a character or group-of-characters you are looking in the main-string.
INSPECT further qualifies the search with BEFORE and AFTER of the initial occurrence of identifier-4 or literal-2.
Example:
WS-NAME – ‘MUTHU SARAVANA SURYA CHANDRA DEVI’
INSPECT WS-NAME TALLYING WS-COUNT ALL ‘S’
BEFORE INITIAL ‘SARAVANA’ AFTER INITIAL ‘CHANDRA’
END-INSPECT
Result: WS-COUNT contains – 1
INSPECT- FOR REPLACING
It is used to replace the occurrence of a single character or groups of characters in a data field.
INSPECT identifier-1 REPLACING
ALL|LEADING literal-1|identifier-2 BY identifier-3|literal-2
[BEFORE|AFTER INITIAL identifier-4|literal-2] - Optional.
INSPECT identifier-1 REPLCING CHARACTERS
BY identifier-2 BEFORE|AFTER INITIAL identifier-3|literal-1
INSPECT-FOR COUNTING AND REPLACING
It is a combination of the above two methods.
INSPECT identifier-1 TALLYING <tallying part > REPLACING <replacing part>
No comments:
Post a Comment