Back to Browse

COBOL - Inspect statement

2.4K views
Jun 22, 2019
9:18

INSPECT Inspect statement is used to perform the following tasks • Count the number of occurrences of a given character in an input field. • Replace specific occurrences of a given character with another character. Syntax: INSPECT WS-NAME TALLYING (tallying part ) REPLACING (replacing part) Value of WS-INP1 : 'MICHEAL MADHANA KAMA RAJAN' INSPECT WS-INP1 TALLYING WS-COUNT ALL 'A' BEFORE INITIAL 'KAMA' AFTER INITIAL 'MICHEAL'. Output: WS-COUNT= 3 Please refer the video for more examples. Important keywords used in the above examples are TALLYING - TALLYING is used for counting the string characters. REPLACING - To replace the string characters, replacing option is used. FIRST - The FIRST phrase causes only the first valid character to be replaced. BEFORE - BEFORE phrase designates as valid those characters to the left of the delimiter associated with it. AFTER - AFTER phrase designates as valid those characters to the right of the delimiter associated with it.

Download

0 formats

No download links available.

COBOL - Inspect statement | NatokHD