STRINGThe STRING verb concatenates the partial or complete contents of two or morestrings or literals into one single data item. Below example illustrates howthe string is used.String Example:01WS-DATA-ITEM1 PIC X(10)“THIS IS ”.01WS-DATA-ITEM2 PIC X(20)“STRING FIRST”.STRING WS-DATA-ITEM1DELIMITED BY SIZE.WS-DATA-ITEM2DELIMITED BY SPACES‘ EXAMPLE. ‘DELIMITED BY SIZEINTOWS-DESTINATIONThis example will concatenate the strings WS-DATA-ITEM1 and WS-DATA-ITEM2 intoWS-DESTINATION. In above example WS-DATA-ITEM1 is delimited by size,so completestring content will be moved to destination string(WS-DESTINATION).
WS-DATA-ITEM2is delimited by SPACES, partial content (characters up to first space) will bemoved. And complete literal (i.e. ‘) will be moved.Now WS-DESTINATION will contain “THIS IS STRING EXAMPLE”.WITH POINTER is optional, value associated with it (Pointer-integer) determinesthe starting character position for insertion into the destination string, andpointer-integer must be an integer item.ON OVERFLOW is optional, this clause specifies what needs to be done when overflowcondition occurred. Overflow condition occurs in following conditions.
The pointer-integer is not pointing to a character position within the destination string whenthe STRING executes. I.e.less than 1 or exceeding the length of destination string.If all source strings together are not accommodated in destination string thenoverflow occurs.DELIMITED BY phrase specifies the content of source string to be transferred.DELIMITED BY SPACES, Data item or literal - Transfers the data till sepcificeddelimeter foundDELIMITED BY SIZE, Transfers complete string.Data movement from a particular source string ends when either;1. The end of the source string is reached2. The end of the destination string is reached3. The delimiter is detected.The STRING statement ends when either;1. All the source strings have been processed.2. The destination string is full.3.
POINTER is a four-byte data item that holds the address of another data item. PROCEDURE-POINTER is a four- or eight-byte data item (depending on the operating system) that contains the address of a program-entry point. Rule s of COBOL Pointer Variable. A POINTER data item cannot have a PICTURE clause.
The figurative constant NULL (or NULLS) can be used to initialise POINTER and PROCEDURE-POINTER data. No other literal value can be assigned to POINTER data.In addition to the new data types, vendors implement special registers for use with address data:ADDRESS OF a register that exists for each record (level 01 or 77) in the Linkage Section of the Data Division.