IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

INITIALIZE Filler got NULL instead of Spaces


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bigcoolbudy

New User


Joined: 12 Jun 2006
Posts: 12

PostPosted: Wed Aug 15, 2007 11:14 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 15, 2007 11:25 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Aug 15, 2007 11:27 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Aug 16, 2007 1:33 am
Reply with quote

Next time, move spaces to the group name and then initialize it - that will take care of your numeric fields.
Back to top
View user's profile Send private message
bigcoolbudy

New User


Joined: 12 Jun 2006
Posts: 12

PostPosted: Thu Aug 16, 2007 2:48 am
Reply with quote

Thanks for the quick replies. It is really helpful.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Aug 16, 2007 12:47 pm
Reply with quote

Or use INITILAIZE with REPLACING pharse.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Aug 16, 2007 2:35 pm
Reply with quote

Anuj,
Are you sure that INITIALIZE with REPLACING clause can affect FILLERS?
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Thu Aug 16, 2007 4:35 pm
Reply with quote

Hi,

We also encountered the same problem few times. We moved spaces instead of INITIALIZE verb and problem was solved.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 16, 2007 5:37 pm
Reply with quote

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
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu Aug 16, 2007 7:00 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Aug 16, 2007 7:34 pm
Reply with quote

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'. icon_redface.gif

P.S.: Ill effect of replying post in haste. icon_sad.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts the system or user abend SF0F R=NULL COBOL Programming 0
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
Search our Forums:

Back to Top