Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
INITIALIZE Filler got NULL instead of Spaces

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: INITIALIZE Filler got NULL instead of Spaces
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: 6968
Location: porcelain throne

PostPosted: Wed Aug 15, 2007 11:25 pm    Post subject:
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

Site Director


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

PostPosted: Wed Aug 15, 2007 11:27 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Thu Aug 16, 2007 1:33 am    Post subject:
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    Post subject: Reply to: INITIALIZE Filler got NULL instead of Spaces
Reply with quote

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

Senior Member


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

PostPosted: Thu Aug 16, 2007 12:47 pm    Post subject:
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: 686
Location: Earth

PostPosted: Thu Aug 16, 2007 2:35 pm    Post subject:
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: 356
Location: New York

PostPosted: Thu Aug 16, 2007 4:35 pm    Post subject: Reply to: INITIALIZE Filler got NULL instead of Spaces
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: 6968
Location: porcelain throne

PostPosted: Thu Aug 16, 2007 5:37 pm    Post subject:
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: 149
Location: Ottawa Canada

PostPosted: Thu Aug 16, 2007 7:00 pm    Post subject:
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

Senior Member


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

PostPosted: Thu Aug 16, 2007 7:34 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us