View previous topic :: View next topic |
Author |
Message |
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Mon Sep 27, 2021 7:51 am Post subject: Initaiize group variable |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Sep 27, 2021 8:05 pm Post subject: Re: Initaiize group variable |
|
|
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 |
|
|
Terry_Heinze Supermod
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
|
Posted: Tue Sep 28, 2021 10:00 am Post subject: |
|
|
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 |
|
|
haatvedt Beginner
Joined: 14 Nov 2003 Posts: 66 Topics: 0 Location: St Cloud, Minnesota USA
|
Posted: Tue Sep 28, 2021 12:21 pm Post subject: |
|
|
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 |
|
|
Terry_Heinze Supermod
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
|
Posted: Wed Sep 29, 2021 8:43 am Post subject: |
|
|
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 |
|
|
Spolacek Beginner
Joined: 17 Dec 2002 Posts: 17 Topics: 2 Location: NJ, USA
|
Posted: Wed Oct 06, 2021 11:28 am Post subject: |
|
|
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 |
|
|
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Mon Oct 11, 2021 7:51 am Post subject: |
|
|
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 |
|
|
|
|