Friday 26 March 2021

COBOL String Statement | STRING in COBOL | COBOL STRING Examples [COBOL string delimited by space].

COBOL STRING STATEMENT, STRING in COBOL
COBOL String Statement.

Welcome back to today's session on STRING in COBOL. In this session, you'll learn how to concatenate a string in COBOL by using the COBOL STRING statement. COBOL STRING tutorial begins with an introduction to string statements in COBOL. Followed by the COBOL string example and COBOL string statement syntax. Let's get started with the COBOL string statement.  


COBOL STRING Tutorial - Agenda.
  • Introduction. 
  • What is STRING in COBOL?
  • COBOL STRING Data Flow Overview.
  • COBOL STRING Syntax. 
  • COBOL STRING Example.
  • Conclusion.  

Introduction. 

String manipulation is an integral part of any programing language. In COBOL, you generally used COBOL STRING, COBOL UNSTRING statement, and COBOL Inspect statement to perform different string operations, such as splitting string or concatenating string.

What is COBOL STRING Statement [string in COBOL]?

In layman's terms, the COBOL STRING statement is used to couple or concatenate two or more fields into a single field. Here, you use the Delimited By clause to specify the delimiter that marks the end of each field that is to be concatenated.   

STRING statement in COBOL can be used in conjunction with reference modification in COBOL. With the STRING, the programmer can use POINTER and ON OVERFLOW. NOT ON OVERFLOW as well as an END-STRING scope terminator can also be used. 

You can use the COBOL STRING statement, instead of a series of MOVE statements to merge data from different fields.

COBOL STRING DATA Flow Overview. 

When the COBOL STRING statement is executed. The system transfers characters from the source fields to the destination field. The sequence in which the sending fields are processed is the order in which they are specified in the COBOL String statement. 

In the following COBOL STRING statement, the flow of data is illustrated in the diagram for better understanding. 

   STRING ID-1 ID-2 DELIMITED BY ID-3
          ID-4 ID-5 DELIMITED BY SIZE
     INTO ID-7 WITH POINTER ID-8
   END-STRING


COBOL STRING Syntax.

The syntax of the COBOL STRING statement is fairly simple and easy to use. The output field or literal-3 should be of type string. However, all other literals must be of data types character or string.

COBOL String Statement syntax, COBOL String
STRING in COBOL Syntax.

  • identifier-1, literal-1: are sending fields.
  • DELIMITED BY phrase: Identify the end of the string. If you specify DELIMITED by SIZE then the entire variable data will be sent to destination fields.  
  • INTO phrase: It defines the destination field.  
  • POINTER phrase: It points to the position of the character in the receiving field.

#1. COBOL String Example. 

In the following example, the employee's first name and last name are combined and stored into EMP-NAME. 
 
    STRING FNAME DELIMITED BY " "
           " "   DELIMITED BY " "
           LNAME DELIMITED BY " "   
      INTO EMP-NAME 
    END-STRING.

#Output- DAVID MURPHY

#2. COBOL String Delimited BY SIZE.

In the following example, the employee's first name and last name are combined and stored into EMP-NAME. 
 
    STRING FNAME DELIMITED BY SIZE
           LNAME DELIMITED BY SIZE   
      INTO EMP-NAME 
    END-STRING.

#Output- DAVID    MURPHY

STRING in COBOL - Youtube video. 

This COBOL string tutorial is linked with the COBOL string function or COBOL String tutorial. This tutorial provides an overview of the COBOL string function along with different parameters such as COBOL string delimited by space, COBOL string pointer, and COBOL string overflow. Please watch this video and consider subscribing to our channel.

    

Conclusion. 

Finally, this marks an end to today's JCL Interview Questions. This tutorial outlines the COBOL string function along with different parameters such as COBOL string delimited by space, COBOL string pointer, and COBOL string overflow.

Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™
Created with Artisteer

No comments:

Post a Comment

New In-feed ads