Summary -

In this topic, we described about the below sections -

The INSPECT statement is used to examine the character(s), replace those character(s) with other character(s), or convert from one character(s) to another character(s).

Note! In this topic, "character(s)" means single character or group of characters.

INSPECT statement used to do the following tasks by using its four formats -

  • INSPECT TALLYING - Counts the specific character(s) occurrences in a data item.
  • INSPECT REPLACING - Replaces all occurrence or some occurrences of chatacter(s) with given character(s) in the data item.
  • INSPECT TALLYING REPLACING - Counts the specific character(s) occurrences and replaces all or some occurrences with specified character(s) in the data item.
  • INSPECT CONVERTING - Converts all occurrences of a specific character(s) to user-supplied replacement character(s) in a data item.

INSPECT TALLYING -

INSPECT TALLYING Counts the specific character(s) occurrences in a data item. The counter data type should be numeric.

INSPECT TALLYING
INSPECT ws-input TALLYING ws-count 
	FOR CHARACTERS.

INSPECT ws-input TALLYING ws-count 
	FOR CHARACTERS 
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal].

INSPECT ws-input TALLYING ws-count
	FOR ALL ws-counting-chars/counting-literal.
	
INSPECT ws-input TALLYING ws-count
	FOR ALL ws-counting-chars/counting-literal
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal].

INSPECT ws-input TALLYING ws-count
	FOR LEADING ws-counting-chars/counting-literal.

INSPECT ws-input TALLYING ws-count
	FOR LEADING ws-counting-chars/counting-literal
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal]. 

INSPECT TALLYING Statement topic updated with complete information and use the link for the navigation.

INSPECT REPLACING -

INSPECT REPLACING replaces all occurrence or some occurrences of chatacter(s) with given character(s) in the data item.

INSPECT REPLACING
INSPECT ws-input REPLACING 
	CHARACTERS BY ws-replacing-char/replacing-literal. 
 
INSPECT ws-input REPLACING 
	CHARACTERS BY ws-replacing-char/replacing-literal 
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal].

INSPECT ws-input REPLACING 
	ALL ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal.

INSPECT ws-input REPLACING 
	ALL ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal 
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal].
	
INSPECT ws-input REPLACING 
	LEADING ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal.

INSPECT ws-input REPLACING 
	LEADING ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal 
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal].
	
INSPECT ws-input REPLACING 
	FIRST ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal.
	
INSPECT ws-input REPLACING 
	FIRST ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal 
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal].

INSPECT REPLACING Statement topic updated with complete information and use the link for the navigation.

INSPECT TALLYING REPLACING -

Counts the specific character(s) occurrences and Replaces all or some occurrences with specified character(s) in the data item.

INSPECT TALLYING REPLACING is used to count and replace the occurrence of character(s).

INSPECT TALLYING REPLACING performs the TALLYING operation first and REPLACING next.

INSPECT TALLYING REPLACING
INSPECT ws-input 
	TALLYING ws-count FOR CHARACTERS
	REPLACING CHARACTERS BY ws-replacing-char/replacing-literal. 

INSPECT ws-input 
	TALLYING ws-count FOR CHARACTERS
	[[BEFORE/AFTER] [INITIAL] ws-delimeter1/delimeter-literal1]
	REPLACING CHARACTERS BY ws-replacing-char/replacing-literal.

INSPECT ws-input 
	TALLYING ws-count FOR CHARACTERS
	REPLACING CHARACTERS BY ws-replacing-char/replacing-literal
	[[BEFORE/AFTER] [INITIAL] ws-delimeter2/delimeter-literal2].

INSPECT ws-input 
	TALLYING ws-count FOR CHARACTERS
	[[BEFORE/AFTER] [INITIAL] ws-delimeter1/delimeter-literal1]
	REPLACING CHARACTERS BY ws-replacing-char/replacing-literal
	[[BEFORE/AFTER] [INITIAL] ws-delimeter2/delimeter-literal2].
	
INSPECT ws-input 
	TALLYING ws-count
	FOR ALL/LEADING ws-counting-chars/counting-literal
	REPLACING ALL/LEADING/FIRST ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal. 

INSPECT ws-input 
	TALLYING ws-count
	FOR ALL/LEADING ws-counting-chars/counting-literal
	[[BEFORE/AFTER] [INITIAL] ws-delimeter1/delimeter-literal1]
	REPLACING ALL/LEADING/FIRST ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal.

INSPECT ws-input 
	TALLYING ws-count
	FOR ALL/LEADING ws-counting-chars/counting-literal
	REPLACING ALL/LEADING/FIRST ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal 
	[[BEFORE/AFTER] [INITIAL] ws-delimeter2/delimeter-literal2].
	
INSPECT ws-input 
	TALLYING ws-count
	FOR ALL/LEADING ws-counting-chars/counting-literal
	[[BEFORE/AFTER] [INITIAL] ws-delimeter1/delimeter-literal1]
	REPLACING ALL/LEADING/FIRST ws-replaced-char/replaced-literal 
	BY ws-replacing-char/replacing-literal 
	[[BEFORE/AFTER] [INITIAL] ws-delimeter2/delimeter-literal2].

INSPECT TALLYING REPLACING Statement topic updated with complete information and use the link for the navigation.

INSPECT CONVERTING -

Converts all occurrences of a specific character(s) to user-supplied replacement character(s) in a data item.

INSPECT CONVERTING works on individual characters in the group of characters.

INSPECT CONVERTING
INSPECT ws-input 
	CONVERTING ws-source/source-literal
	TO ws-target/target-literal.

INSPECT ws-input 
	CONVERTING ws-source/source-literal
	TO ws-target/target-literal
	[[BEFORE/AFTER] [INITIAL] ws-delimeter/delimeter-literal].

INSPECT CONVERTING Statement topic updated with complete information and use the link for the navigation.