Skip to main content

Problem:

The following demo shows the use of 'initialize' on a group field.  It returns a value of 'wwxxyy' whilst you may have expected a return of spaces.

       working-storage section.

       01 aa.

           03 bb.

              05 filler       pic xx occurs 10.

           03 cc              pic x(10) value "wwxxyy".

       procedure division.

           move "ppqqrrss" to bb

           initialize aa

           display aa.

Resolution:

Although it seems odd, this is in fact correct behaviour.  If you study the Language Reference Manual for the verb INITIALIZE, general rule 3 reads 'Index and pointer data items, and elementary FILLER data items are not affected by the execution of an INITIALIZE statement'

To achieve the results you want you will need to rename 'filler' to something else, for example:

      working-storage section.

       01 aa.

           03 bb.

              05 filler2      pic xx occurs 10.

           03 cc              pic x(10) value "wwxxyy".

       procedure division.

           move "ppqqrrss" to bb

           initialize aa

           display aa.

Old KB# 7209