View previous topic :: View next topic
|
Author |
Message |
bigcoolbudy
New User
Joined: 12 Jun 2006 Posts: 12
|
|
|
|
Hi, I have a copybook in which we have FILLER at multiple place. I do INITIALIZE the group level of this copybook with assumtion that this will also move spaces in FILLER, but the data file generated have NULL character at FILLER positions rather then SPACES.
Please help me to understand why this is happening.
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
if you looked at the literature and read about the INITIALIZE statement, you would have known that INITIALIZE does not affect items with FILLER as a Reference Name. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The FILLER fields are not initialized because that is one of the rules of INITIALIZE. INITIALIZE does not place values in all fields. There are several exceptions.
I suggest you look at the COBOL Language Reference that is linked to via the "Manuals" link at the top of each web page to find all of the rules. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Next time, move spaces to the group name and then initialize it - that will take care of your numeric fields. |
|
Back to top |
|
|
bigcoolbudy
New User
Joined: 12 Jun 2006 Posts: 12
|
|
|
|
Thanks for the quick replies. It is really helpful. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Or use INITILAIZE with REPLACING pharse. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Anuj,
Are you sure that INITIALIZE with REPLACING clause can affect FILLERS? |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Hi,
We also encountered the same problem few times. We moved spaces instead of INITIALIZE verb and problem was solved. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
element reference names of FILLER will receive no attention by the initialize statement.
other than the obvious reason that there would be duplicate reference names at the same level within a structure, a simple example will show you why this behaviour is convenient:
Code: |
01 AREA.
05 DATE.
10 YEAR PIC 9(4).
10 FILLER PIC X(1) VALUE '/'.
10 MONTH PIC 9(2).
10 FILLER PIC X(1) VALUE '/'.
10 DAY PIC 9(2).
05 FILLER PIX X(3) VALUE ' - '.
05 TIME.
10 HOUR PIC 9(2).
10 FILLER PIC X(1) VALUE '.'.
10 MINUTES PIC 9(2).
10 FILLER PIC X(1) VALUE ':'.
10 SECONDS PIC 9(2).
...
INITIALIZE AREA
MOVE IN-YEAR TO YEAR
...
MOVE IN-SEC TO SECONDS
|
This way you don't have to move the literals /,-,.,:
or if you were generating a fixed-len CVS (or semicolon field delimited) file, you could define each FILLER with a VALUE of ';'. Then you would only need to populate the fields. The INITIALIZE would then space or zero out any field defined with a Reference Name not equal to FILLER, and leave the original defined VALUES in the fields defined with a Reference Name of FILLER.
I wrote a REXX Edit Macro, that would change Reference Names of FILLER to FILLER001, FILLER002, etc... thus causing the INITIALIZE to also space out the X-type fillers and zero fill numeric type, when I needed the filler areas spaced or zero filled.
To move spaces to an area then INITIALIZE the area, is a solution based on ignorance. You still have to INITIALIZE the area if there are numeric fields. You can also skip this silliness if you provide a VALUE clause to the FILLER element, so the compiler does the work for you, instead of wasting run-time cycles.
If your fillers are overlayed, so that they need to be 're-initialized', change your Reference Names from FILLER to FILLERnnn. The only impact is the dictionary the compiler builds during compile time (and is not used afterwards), and the MOVE SPACES/ZEROS that are generated. |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
One tiny addition to the topic.
Always keep an eye out for fields under a REDEFINES. INITIALIZE will not look at these fields when it initializes the underlying storage. It will use the original definition - not the REDEFINED definition. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
agkshirsagar wrote: |
Are you sure that INITIALIZE with REPLACING clause can affect FILLERS? |
My bad, Elementary FILLER data items will not be affected by 'INITIALIZE with REPLACING clause'.
P.S.: Ill effect of replying post in haste. |
|
Back to top |
|
|
|