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

Can I add a redefined variable to another variable


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

New User


Joined: 26 Jun 2006
Posts: 7

PostPosted: Thu Mar 29, 2007 9:51 am
Reply with quote

Can I add a redefined variable to another variable?
eg:

01 B PIC X(5).
01 A redefines B 9(5).
....
Add A to C.

Now when i display C i get junk values.
C was already initialized.

thanks in advance.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Mar 29, 2007 12:50 pm
Reply with quote

Yes, you can add a redefined variable to another variable.
"junk values" is descriptive but not very informative.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Mar 29, 2007 2:38 pm
Reply with quote

Junk values will be there if you dont initialize that variable. (A,C in this case)
What what does 'C' contain?
Initialize both variables with desired values then you will get correct results. icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Mar 30, 2007 12:19 am
Reply with quote

Hello,

Your posted code is incomplete and/or invalid. You need to post what value you put in A/B as well as the value in C. Before and ADD is issued, there must be valid numbers in the operands.

From what you posted, i'm surprised that a s0c7 did not occur.

If these (A/B,C) are user entered values, they must be checked to ensure they contain valid numeric values. If this is not done, the job will eventually abend in production.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Mar 30, 2007 6:24 pm
Reply with quote

No S0C7 becuase the data are not packed decimal.

It is possible for the code generated from DISPLAY arithmetic to convert to packed decimal and then back, which could elicit a S0C7, but I think this is only with signed fields.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Mar 30, 2007 9:27 pm
Reply with quote

Phrzby Phil wrote:
No S0C7 becuase the data are not packed decimal.

It is possible for the code generated from DISPLAY arithmetic to convert to packed decimal and then back, which could elicit a S0C7, but I think this is only with signed fields.
Not quite, the mainframe can add primarily two ways, either packed or binary.
The zoned digits are packed to work areas, added and unpacked back. While the pack/unpack are immune to exception, the add packed is not.
To add binary, the zoned digits are packed, converted to binary, added, converted to decimal and unpacked. While the pack/unpack are immune to exception (as are the binary add and the convert to decimal), the convert to binary is not.
Not all garbage results in a S0C7, but there's a good chance that one can happen from random junk.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Mar 30, 2007 9:31 pm
Reply with quote

Thanks for the correction.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top