View previous topic :: View next topic
|
Author |
Message |
Chetan Kumar
New User
Joined: 03 Dec 2012 Posts: 46 Location: India
|
|
|
|
Hi,
If we move spaces to record level variable (at 01 level). What will happen to numeric fields which are at the elementary levels. Also what will happen to Filler and Occurs Variables. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you move space to a group item, everything subordinate to it will be set to space.
What happens after that depends.
Do you have a specific problem? |
|
Back to top |
|
|
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
Any numeric fields will be filled with spaces which on z/OS is X'40'. This will translate into a numeric value or will be invalid.
If you use the INITIALIZE statement then it will move a value of 0 into all numeric fields and spaces into alphanumeric. Any FILLER items are left unchanged. |
|
Back to top |
|
|
Chetan Kumar
New User
Joined: 03 Dec 2012 Posts: 46 Location: India
|
|
|
|
Bill Woodger wrote: |
If you move space to a group item, everything subordinate to it will be set to space.
What happens after that depends.
Do you have a specific problem? |
Hi,
In one of the existing programs instead of initializing the Record level group item , spaces are moved to the group item.
As far I know, Group Level move always acts as alphanumeric move irrespective of the type of data moved.
so in this case, if we move spaces to group item, even numeric item will contain spaces.. so if it is used for computation then it will throw error.
So I believe it is always good practice to initialize group variables instead of moving spaces to it.
Thanks. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Now you get the the person in your group that knows how INITIALIZE works! Look it up and study it. Pay close attention to what it does with FILLER items, and to what it does with REDFINES items, and how it treats different types of PICTURE clauses.
I would go so far as to make a small program and actually try it out. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
For me it is always good practice to set an initial value only when it is needed.
There is no point in:
Code: |
MOVE ZERO TO A
MOVE 9312T-CANCELLATION-AMOUNT TO A |
Equally no point in
Code: |
INITIALIZE RECORD-CONTAINING-A
MOVE 9312T-CANCELLATION-AMOUNT TO A |
|
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Agree with Bill. I see that type of coding more often than I care to. Also, if a record area needs to be repeatedly initialized, I will usually initialize it once at the beginning of the program, save it off, then move it back to accomplish the reinitializing with one group move. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes. Usually what is really needed to be set to initial values is tables of counts and amounts for "break" processing. And the efficient way to do that is as Terry has outlined.
Since you only set it up once, you can do all sorts of extra checking (number of entries, lengths of entries, etc) and do things like setting up USAGE INDEX fields to the maxima of tables, so that you can have efficient loop control. It doesn't matter how much you put in there, as it only happens once. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
That's what she said. |
|
Back to top |
|
|
Chetan Kumar
New User
Joined: 03 Dec 2012 Posts: 46 Location: India
|
|
|
|
Thank you all. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
In my early days, I used to MOVE SPACE to a group item for a record being output, before filling in the indivdual details.
My reasoning way, if I get bad numeric data because I forgot to put something in a field, then the abend will spot it for me.
Turned out to be fairly useless, as it doesn't help with alpha-numeric fields, and it takes far more than just having space in a field to make an abend. So I check the compiler listing and ensure that I haven't missed any fields (easily done, even in those days).
What you have done with your INITIALIZE is made the content of a field valid, whereas before it was sufficiently invalid to cause a S0C7. No actual value has been MOVEd to that field, you need to find out why.
You have "fixed" the code by just setting the field to zero, You need to find out if that is the correct value, or whether there is some other problem you are now masking. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
"You need to find out if that is the correct value, or whether there is some other problem you are now masking."
But that wasn't in the contract! |
|
Back to top |
|
|
|