MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Initaiize group variable

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 629
Topics: 176
Location: Stockholm, Sweden

PostPosted: Mon Sep 27, 2021 7:51 am    Post subject: Initaiize group variable Reply with quote

I've seen the following code all over the place:-
Code:

move space to copybook
initialize copybook

In my mind, this is tautology and totally unnecessary. Surely, the second line should be enough ?
Or is there some quirk I'm missing. (And before anyone says that the first line ensures that FILLER fields are set to space, if they're filler fields, then logically they're not used)
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Sep 27, 2021 8:05 pm    Post subject: Re: Initaiize group variable Reply with quote

misi01 wrote:

In my mind, this is tautology and totally unnecessary. Surely, the second line should be enough ?
Or is there some quirk I'm missing. (And before anyone says that the first line ensures that FILLER fields are set to space, if they're filler fields, then logically they're not used)


misi01,

INITIALIZE is a convenient, however it is a costly instruction as the compiler generates at least 3 instructions. So if you have large copybooks, then having a INITIALIZE statement in a loop can hurt performance. you can use INITIALIZE statements but narrow it down to ONLY numeric items. This may help reducing any S0C7 abends down the lane for any computations involving the numeric items.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Tue Sep 28, 2021 10:00 am    Post subject: Reply with quote

One option would be to INITIALIZE the copybook one time, save it off, and every time thereafter, move the saved off initialized copybook to copybook.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
haatvedt
Beginner


Joined: 14 Nov 2003
Posts: 66
Topics: 0
Location: St Cloud, Minnesota USA

PostPosted: Tue Sep 28, 2021 12:21 pm    Post subject: Reply with quote

One thing to consider is that the Initialize verb does NOTHING to FILLER areas and as such they would have garbage in them without the preceeding MOVE SPACES
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
Back to top
View user's profile Send private message
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Wed Sep 29, 2021 8:43 am    Post subject: Reply with quote

Good point. Be sure to read all about INITIALIZE in the manual. It does/does not do what you might expect.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
Spolacek
Beginner


Joined: 17 Dec 2002
Posts: 17
Topics: 2
Location: NJ, USA

PostPosted: Wed Oct 06, 2021 11:28 am    Post subject: Reply with quote

If you're using COBOL version 6, there's an extension to the INITIALIZE verb that will also initialize FILLER fields.

Here's how the COBOL Language Reference describes it:

Code:
FILLER phrase

When the FILLER phrase is specified, the receiving elementary data items that have an explicit or implicit FILLER clause will be initialized.


https://www.ibm.com/docs/en/cobol-zos/6.3?topic=pdf-version-documentation

For example:

INITIALIZE MY-COPYBOOK FILLER.
Back to top
View user's profile Send private message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 629
Topics: 176
Location: Stockholm, Sweden

PostPosted: Mon Oct 11, 2021 7:51 am    Post subject: Reply with quote

Thanks for the FILLER comment.
Talking about performance, my 2 cents' worth would also be for large tables. I always initialize the first line in the table, then I loop round moving row 1 to rows 2-n. Much faster and cheaper.
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group