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
 

 

Redefine 9(2) comp

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
PrabakarV

New User


Joined: 21 Dec 2007
Posts: 88
Location: My Desk

PostPosted: Mon Jul 02, 2012 9:49 pm    Post subject: Redefine 9(2) comp
Reply with quote

Var declaration:

Code:
05  A              PIC 9(02) COMP.   
05  FILLER               REDEFINES A.
    10  FILLER                        PIC X.           
    10  B          PIC X.       


Proc Division:

Code:
ADD 1 TO A
MOVE B TO C


In here initial value of A is zero before adding one. After that A had '01' in it. But i am not getting the second byte of A in B.

Please let me know if this is a wrong way of declaring. Please help me solve this issue.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jul 02, 2012 10:07 pm    Post subject:
Reply with quote

Suggest you do a lot of reading in the cobol manuals about how numeric data items are stored!!!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Mon Jul 02, 2012 10:31 pm    Post subject:
Reply with quote

What did you get for the value of B?
What did you expect the value of B to be?
Back to top
View user's profile Send private message
PrabakarV

New User


Joined: 21 Dec 2007
Posts: 88
Location: My Desk

PostPosted: Mon Jul 02, 2012 11:37 pm    Post subject:
Reply with quote

I want B to have value '1'. But i have low values in there which was moved at the start of program. I know this is wrong way of declaring but not 100% sure. I like to confirm my understanding.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Mon Jul 02, 2012 11:48 pm    Post subject:
Reply with quote

When you move zero to A, B will have LOW-VALUES. That is just the way COBOL works -- as Craq mentioned, you need to spend LOTS of time in the COBOL manuals understanding internal formats for data in COBOL. If you want B to have the value '1' (hex F1), you need to move 241 to A.
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: Tue Jul 03, 2012 12:42 am    Post subject:
Reply with quote

Hello,

Do you want an x'F1' or an x'01' in B?

If you post what you Really Want, someone should be able to help.

As it is now, all we can recommend is to spend the time in the documentation. We really do not understand your goal. . .
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Jul 03, 2012 4:36 am    Post subject:
Reply with quote

Robert Sample wrote:
WIf you want B to have the value '1' (hex F1), you need to move 241 to A.


I know you know Robert, but it does depend, with a PIC 99 COMP, on compile options whether 241 would actually fit into the field... may end up with 41 only, and max of 99.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Tue Jul 03, 2012 5:25 am    Post subject:
Reply with quote

You are right, Bill -- and I should have said that. Thanks for catching it!
Back to top
View user's profile Send private message
jepson

New User


Joined: 24 Oct 2008
Posts: 7
Location: India

PostPosted: Tue Jul 03, 2012 4:11 pm    Post subject:
Reply with quote

wouldn't B have the value of x'01' ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Jul 03, 2012 4:25 pm    Post subject: Reply to: Redefine 9(2) comp
Reply with quote

From what has been described, yes, X'01' would be the value of B. It is unclear if that is the "1" which is required but poorly-described, or if "1" as in X'F1' is what is expected.

We await TS's return on that.
Back to top
View user's profile Send private message
Jarek.B

New User


Joined: 21 Jun 2012
Posts: 2
Location: UK

PostPosted: Wed Jul 04, 2012 9:48 pm    Post subject:
Reply with quote

PrabakarV wrote:
I want B to have value '1'. But i have low values in there...


You have a binary 1 in B but DISPLAY B won't display it what may confuse you. Still, you may see it on sysout if you switch your editor to hex mode.
If you want character 1 (hex code F1 in EBCDIC) then make A a character item: A PIC 9(2) without COMP.

Coded,tested,posted. 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: Wed Jul 04, 2012 10:09 pm    Post subject:
Reply with quote

Hello,

Suggest PrabakarV look at the lengths and displacements generated by the compiler. . .

If this info is not clear to you, post it here and someone will be able to clarify.

It should help understand what is happening.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Thu Jul 05, 2012 5:37 pm    Post subject:
Reply with quote

Try using TRUNC(BIN) compiler option.
Back to top
View user's profile Send private message
slade

New User


Joined: 24 Nov 2007
Posts: 1
Location: NJ

PostPosted: Sun Jul 08, 2012 9:29 am    Post subject: Reply to: Redefine 9(2) comp
Reply with quote

Hi,
If PrabakarV is still in the building, he might also supply us the PIC, etc. for "C".
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 Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm


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