Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Can I add a redefined variable to another variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Can I add a redefined variable to another variable
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: 3158
Location: Tucson AZ

PostPosted: Thu Mar 29, 2007 12:50 pm    Post subject:
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: 686
Location: Earth

PostPosted: Thu Mar 29, 2007 2:38 pm    Post subject:
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

Site Director


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

PostPosted: Fri Mar 30, 2007 12:19 am    Post subject:
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

Active Member


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

PostPosted: Fri Mar 30, 2007 6:24 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Mar 30, 2007 9:27 pm    Post subject:
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

Active Member


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

PostPosted: Fri Mar 30, 2007 9:31 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us