#COBOL #topictrick
COBOL STRING Statement or COBOL STRING Function is used for COBOL String Handling and COBOL string manipulation. Today's COBOL String tutorial has COBOL string examples for better understanding. COBOL string delimited by space or string in COBOL delimited by size is used for COBOL string compare and COBOL string length. Let's begin with the mainframe COBOL string tutorial.
► Index Details ◄
0:00 Welcome to COBOL STRING Statement.
0:06 Introduction to COBOL string Clause.
0:35 String Manipulation Overview.
1:28 Definition of String statement in COBOL.
2:06 COBOL String Statement Syntax.
3:17 COBOL String Clause.
4:57 COBOL String in COBOL Program
9:34 Mainframe Tutorial Ends.
Introduction.
String manipulation is an integral part of any programming language. Most of the time, you have a requirement to concatenate, split, or extract characters from the string. In COBOL, you have various functions that can be used to manipulate string as per need. Let's look at STRING statement.
COBOL STRING STATEMENT / COBOL STRING VERB / COBOL STRING CLAUSE.
The COBOL STRING Function strings together the partial or complete contents of two or more data items or literals into one single data item.
COBOL STRING STATEMENT SYNTAX.
STRING EF-NAME DELIMITED BY " "
" " DELIMITED BY SIZE
LT-NAME DELIMITED BY SPACE
INTO EMP-CMP-NAME
WITH POINTER WS-FIELD.
END-STRING.
COBOL STRING EXAMPLE.
IDENTIFICATION DIVISION.
PROGRAM-ID. PGMDSP01.
AUTHOR. Topictrick.
INSTALLATION. Topictrick.
DATE-WRITTEN. 06/17/2020.
DATE-COMPILED. 06/17/2020.
*
PROJ DESC : SAMPLE COBOL PROGRAM TO MERGE STRINGS
: BY USING COBOL STRING CLAUSE.
*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
DATA DIVISION.
*
FILE SECTION.
*
WORKING-STORAGE SECTION.
*
01 WS-EMP-NAME.
05 WS-FNAME PIC X(15) VALUE SPACE.
05 FILLER PIC X(01) VALUE SPACE.
05 WS-LNAME PIC X(20) VALUE SPACE.
*
01 WS-EMP-FNAME PIC X(35) VALUE SPACES.
PROCEDURE DIVISION.
*
000-MAIN-LOGIC.
PERFORM 005-PRT-EMP-DATA
STOP RUN.
*
005-PRT-EMP-DATA SECTION.
010-MOVE-DATA.
MOVE 'ROGGER' TO WS-FNAME.
MOVE 'MURPHY' TO WS-LNAME.
PERFORM 020-MRG-DATA THRU
020-EXIT
DISPLAY 'NAME OF EMPLOYEE : ', WS-EMP-NAME.
DISPLAY 'NAME OF EMPLOYEE : ', WS-EMP-FNAME.
010-EXIT.
EXIT.
020-MRG-DATA.
STRING WS-FNAME DELIMITED BY " "
" " DELIMITED BY " "
WS-LNAME DELIMITED BY " "
INTO WS-EMP-FNAME
END-STRING.
020-EXIT.
EXIT.
►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 -
► Official Website : https://www.topictrick.com
► Youtube : topictrick
► Follow us on Twitter : / topictrick
► Facebook : / topictrick
► Linkedin : / topictrick
► Reddit : / topictrick
► Mainframe Blog : https://mainframe-forum.blogspot.com
► Medium Blog : / topictrick
Thank you for your support.
Topictrick™