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

Move Spaces to Record (at 01 Level).


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

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Tue May 27, 2014 10:14 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 27, 2014 10:24 pm
Reply with quote

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

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Tue May 27, 2014 10:30 pm
Reply with quote

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

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Wed May 28, 2014 8:47 am
Reply with quote

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

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Wed May 28, 2014 9:18 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed May 28, 2014 10:58 pm
Reply with quote

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

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu May 29, 2014 1:07 am
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 29, 2014 3:36 am
Reply with quote

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

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu May 29, 2014 7:46 pm
Reply with quote

That's what she said.
Back to top
View user's profile Send private message
Chetan Kumar

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Mon Jun 02, 2014 2:52 pm
Reply with quote

Thank you all.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 02, 2014 5:28 pm
Reply with quote

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

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Wed Jun 04, 2014 5:54 pm
Reply with quote

"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
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts How to load to DB2 with column level ... DB2 6
Search our Forums:

Back to Top