How do I Unstring a file in Cobol?

Example -2 : UNSTRING source-string DELIMITED BY �/� OR �#� OR ALL SPACES INTO destination-string1 DELIMITER IN hold-delimiter1 COUNT IN char-counter1 destination-string2 DELIMITER IN hold-delimiter2 COUNT IN char-counter2 destination-string3 DELIMITER IN hold-delimiter3 COUNT IN char-counter3 destination-string4 …

What does delimited by size mean in Cobol?

In above example WS-DATA-ITEM1 is delimited by size,so complete string content will be moved to destination string(WS-DESTINATION). WS-DATA-ITEM2 is delimited by SPACES, partial content (characters up to first space) will be moved.

What is pointer in string in Cobol?

When the POINTER phrase is specified, an explicit pointer field is available to the COBOL user to control placement of data in the receiving field. The user must set the explicit pointer’s initial value, which must not be less than 1 and not more than the character position count of the receiving field.

What is string and Unstring in Cobol?

String is used to combine two or more strings/variables in to a single string. UNSTRING verb is used to unstring/divide the source string into different sub-strings.

How do you count spaces in a string in Cobol?

we can use following logic. INSPECT FUNCTION REVERSE (Source-string) TALLYING space-count FOR LEADING SPACES. COMPUTE length-of-string = 6 – space-count. Move Source-string(space-count+1 : length-of-string ) TO ws-target-string.

How do you remove leading and trailing spaces in Cobol?

INSPECT FUNCTION REVERSE (W-OUTPUT-AMNT) TALLYING W-TRAIL FOR LEADING SPACE. SUBTRACT W-TRAIL FROM LENGTH OF W-OUTPUT-AMNT GIVING W-LENGTH. DISPLAY “RESULT:” W-OUTPUT-AMNT(1:W-LENGTH) “:”. MOVE SPACE TO W-OUTPUT-AMNT.

What is string and Unstring?

How do I remove a character from a string in Cobol?

PROCEDURE DIVISION. PERFORM VARYING WS-I FROM 1 BY 1 UNTIL WS-I > FUNCTION LENGTH(WS-STR) IF WS-STR(WS-I:1) = ‘*’ THEN CONTINUE ELSE MOVE WS-STR(WS-I:1) TO WS-LETTER(WS-J) ADD 1 TO WS-J ADD 1 TO WS-CNT END-IF END-PERFORM DISPLAY WS-CHAR STOP RUN.

How do you remove trailing spaces and zeros in Cobol?

MOVE ZERO TO W-TRAIL. INSPECT FUNCTION REVERSE (W-OUTPUT-AMNT) TALLYING W-TRAIL FOR LEADING SPACE. SUBTRACT W-TRAIL FROM LENGTH OF W-OUTPUT-AMNT GIVING W-LENGTH.

How do I remove spaces between strings in Cobol?

DISPLAY ‘ — METHOD ONE — ‘ INSPECT FUNCTION REVERSE(ONE-A) TALLYING ONE-A-TLY FOR LEADING SPACES. SUBTRACT ONE-A-TLY FROM LENGTH OF ONE-A GIVING ONE-A-LEN. INSPECT FUNCTION REVERSE(ONE-B) TALLYING ONE-B-TLY FOR LEADING SPACES. SUBTRACT ONE-B-TLY FROM LENGTH OF ONE-A GIVING ONE-B-LEN.

How do you reverse a string in Cobol using inspect?

INSPECT FUNCTION REVERSE (Source-string) TALLYING space-count FOR LEADING SPACES. COMPUTE length-of-string = 6 – space-count. Move Source-string(space-count+1 : length-of-string ) TO ws-target-string. Above INSPECT command get the no of leading spaces from the string.

Can We reverse the string in COBOL?

We can use COBOL function REVERSE for the same. REVERSE function returns the character string of same length of the argument. this way we read last character first and by repeating the same process, reverse value of the field can be achieved.

What is COBOL subroutine?

COBOL – Subroutines. Cobol subroutine is a program that can be compiled independently but cannot be executed independently. There are two types of subroutines: internal subroutines like Perform statements and external subroutines like CALL verb.

What is the use of COBOL?

COBOL is primarily used in business, finance, and administrative systems for companies and governments. COBOL is still widely used in legacy applications deployed on mainframe computers, such as large-scale batch and transaction processing jobs. COBOL statements have an English-like syntax, which were designed to be self-documenting and highly readable.

You Might Also Like