COBOL Inspect | COBOL Inspect Statement | Inspect replacing, tallying, converting | Inspect Examples

Опубликовано: 25 Октябрь 2024
на канале: Topictrick
2,095
42

#COBOL #Inspect #Topictrick #Tutorials

COBOL Tutorial on "COBOL Inspect" or COBOL Inspect tutorial. COBOL Inspect Statement or Inspect Statement in COBOL is generally used for string manipulation operations. It's used of counting and replacing a character in the string. COBOL Inspect function has four different variants i.e. Basic Inspect in COBOL, COBOL INSPECT Tallying, COBOL INSPECT Replacing and COBOL INSPECT Converting clauses. Let's get started with today's tutorial.

► Index Details ◄
0:00 Welcome.
0:19 COBOL Tutorial agenda.
0:49 COBOL Inspect Statement Introduction.
1:29 COBOL Inspect different formats (inspect tallying, inspect varying and inspect replacing).
2:06 COBOL Inspect Statement Syntax.
3:08 COBOL Inspect Statement Rules.
4:16 COBOL Inspect Statement Example.
4:24 COBOL Inspect With Replace Example.
5:02 COBOL Inspect With Tallying Example.
6:26 COBOL Inspect With Converting Example.
7:08 COBOL Inspect Tutorial End.

Important points in respect to COBOL Inspect statement are as follows:

You can use the Inspect clause with the Tallying clause to count specific characters in the field that’s inspected.

You can use the Inspect clause with the Replacing clause to replace specific characters in the field that’s inspected. That field can be alphabetic, alphanumeric, or numeric with usage as Display.

You can use the Inspect clause with the Tallying and Replacing clauses to both count and replace characters in a field.

► COBOL Inspect Examples:

Example 1: COBOL INSPECT REPLACING.
*
WORKING-STORAGE SECTION.
01 WS-DTE PIC X(10) VALUE “10-11-2020”.
PROCEDURE DIVISION.
A000-MAIN-SECTION.
INSPECT WS-DTE REPLACING ALL "-" BY "/".

► Output - 10/11/2020

► Example 2: COBOL INSPECT TALLYING.

WORKING-STORAGE SECTION.
*
01 WS-NME PIC X(15) VALUE “DAVID MURPHY”.
01 WS-CNT PIC 9(03) VALUE ZEROES.
*
PROCEDURE DIVISION.
A000-MAIN-SECTION.
INSPECT WS-NME TALLYING WS-CNT FOR ALL SPACES.
► Output - 004

► Example 3: COBOL INSPECT REPLACING STATEMENT.
WORKING-STORAGE SECTION.
*
01 WS-NME PIC X(15) VALUE “DAVID MURPHY”.
01 WS-CNT PIC 9(03) VALUE ZEROES.
*
PROCEDURE DIVISION.
A000-MAIN-SECTION.
INSPECT WS-NME REPLACING ALL "D" BY "d" AFTER INITIAL "D".
►Output - DAVId MURPHY

► Example 4: COBOL INSPECT CONVERTING Statement.
WORKING-STORAGE SECTION.
*
PROCEDURE DIVISION.
A000-MAIN-SECTION.
INSPECT WS-NME CONVERTING "ABCDEFGHIJKLMNOPQRSTUVWXYZ" TO
"abcdefghijklmnopqrstuvwxyz".
Output - david murphy

►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. ◄

Also, Please visit below mention the link to stay connected with Topictrick on -

► Offical Website : www.topictrick.com
► Youtube : topictrick
► Follow us on Twitter :   / topictrick  
► Facebook :   / topictrick  
► Linkedin :   / top.  .
► Reddit :   / topictrick  
► Mainframe Blog : https://mainframe-forum.blogspot.com

Thank you for your support.
Topictrick™