Friday, January 5, 2024

Initialize FILLER data item

INITIALIZE statement wont initialize FILLER data items. If you want to initialize FILLER items as well, then include "WITH FILLER" in the INITIALIZE statement.

If you include "ALL VALUE" clause in the INITIALIZE statement, then it will initialize ONLY the data items that are defined with VALUE clause to the value specified in the VALUE clause.

Below is the sample code to explain the usage of FILLER and VALUE clauses in the INITIALIZE statement.

WORKING-STORAGE SECTION.
01 WS-X.
   05 WS-A    PIC X(16).
   05 WS-A1   PIC X(16) VALUE '1234567890A.CDEF'.
   05 WS-B    PIC X(5).
   05 WS-C    PIC 9(5).
   05 FILLER  PIC 9(5).
PROCEDURE DIVISION.
   MOVE ALL '*'    TO WS-X
   DISPLAY WS-X
   INITIALIZE WS-X WITH FILLER
   DISPLAY WS-X
   MOVE ALL '*'    TO WS-X
   INITIALIZE WS-X ALL VALUE
   DISPLAY WS-X
   STOP RUN.

Output of the above program

***********************************************    
                                     0000000000    
****************1234567890A.CDEF***************    

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.