STRING DELIMITED BY SIZE

 

STRING DELIMITED BY SIZE
 
The following COBOL program depicts the use of 
STRING DELIMITED BY SIZE     
 
 
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PGM040.
       AUTHOR. MAINFRAMEWIZARD.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-TITLE      PIC X(3)  VALUE SPACES.
       01 WS-FIRST-NAME PIC X(20) VALUE SPACES.
       01 WS-LAST-NAME  PIC X(20) VALUE SPACES.
       01 WS-FULL-NAME  PIC X(43) VALUE SPACES.
       PROCEDURE DIVISION.
       10000-MAIN-PARA.
             MOVE 'MR#'               TO WS-TITLE
             MOVE 'MAINFRAME#WIZARD#' TO WS-FIRST-NAME
             MOVE 'COM#'              TO WS-LAST-NAME
             STRING WS-TITLE      DELIMITED BY SIZE
                    WS-FIRST-NAME DELIMITED BY SIZE
                    WS-LAST-NAME  DELIMITED BY SIZE
                    INTO WS-FULL-NAME
             DISPLAY 'RESULTANT STRING IS  = '
               WS-FULL-NAME
             STOP RUN.
 
 
 
The output of the program is 
 
RESULTANT STRING IS  = MR#MAINFRAME#WIZARD#   COM#                                                                       
 
 
 
 
 
 

Comments

yes we can write in this way .It is valid when the resulting string don't have any space. It the resulting string have space then we have to change the code

I think after WS-TITLE it should be delimited by space otherwise characters would overlap, please correct me if I am wrong.

As the title is 3 bytes and the literal used (mr#) is 3 bytes, there should be no overlap.

The example would have been more informative if there had been multiple sets of "data" used rather than just the one. I'm not sure why the # "delimier" was inserted~ 

 

Maybe i am missing what you are asking.