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
 

 

How to display a Comp variable in cobol program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> FAQ & Off Topics
View previous topic :: :: View next topic  
Author Message
ug123
Warnings : 1

New User


Joined: 01 Mar 2007
Posts: 39
Location: Chennai

PostPosted: Sun May 25, 2008 1:38 am    Post subject: How to display a Comp variable in cobol program
Reply with quote

Could anyone please tell me how to display a Comp variable in a Cobol program.

Thanks,
Ugandar
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sun May 25, 2008 2:02 am    Post subject:
Reply with quote

Display usually works, might mess up the sign, but a move and display would fix that......
Back to top
View user's profile Send private message
ug123
Warnings : 1

New User


Joined: 01 Mar 2007
Posts: 39
Location: Chennai

PostPosted: Sun May 25, 2008 2:06 am    Post subject: Reply to: How to display a Comp variable in cobol program
Reply with quote

Actually i have a value 'FA60' which i can see in the hex format and the valid readable format for that value is 64096. I want to display this value.

Thanks,
Ugandar.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sun May 25, 2008 2:26 am    Post subject: Re: Reply to: How to display a Comp variable in cobol progra
Reply with quote

ug123 wrote:
Actually i have a value 'FA60' which i can see in the hex format and the valid readable format for that value is 64096. I want to display this value.
If it is a signed two byte field, then it is -31328.
If the field is larger than two bytes, or unsigned, then 64096 is correct.
Try a "display dataname" and either get 64096 or 6409F or -31328 or 3132H....
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: Sun May 25, 2008 2:35 am    Post subject:
Reply with quote

Hello,

Post the "comp variable" definition.

If you display a group field containing this, the display will not be what you want - you need to display the individual field.
Back to top
View user's profile Send private message
ug123
Warnings : 1

New User


Joined: 01 Mar 2007
Posts: 39
Location: Chennai

PostPosted: Sun May 25, 2008 2:37 am    Post subject:
Reply with quote

01 WS-BINARY.
05 WS-BINARY-N PIC 9(4) BINARY.


WS-BINARY contains X'FA60'
if we convert this to decimal we can get 64096
so i need to display 64096
can u tell me what I have to do for this

Thanks,
Ugandar
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sun May 25, 2008 2:53 am    Post subject:
Reply with quote

Have you tried 'DISPLAY WS-BINARY-N'?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun May 25, 2008 3:17 am    Post subject:
Reply with quote

05 WS-DISPLAY-N PIC 9(005).

Try moving WS-BINARY-N to WS-DISPLAY-N and
DISPLAY WS-DISPLAY-N
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: Sun May 25, 2008 3:32 am    Post subject:
Reply with quote

Hello,

Quote:
so i need to display 64096
Do you really need to "display" this or do you need to make it visable in some report or on some panel?

If you explain the actual requirement, we can probably offer better suggestions.
Back to top
View user's profile Send private message
ug123
Warnings : 1

New User


Joined: 01 Mar 2007
Posts: 39
Location: Chennai

PostPosted: Mon May 26, 2008 1:04 pm    Post subject: Reply to: How to display a Comp variable in cobol program
Reply with quote

01 WS-BINARY.
05 WS-BINARY-N PIC 9(4) BINARY.


WS-BINARY contains X'FA60'
If we check the spool we can see the above value as below
F6
A0

The equivalent decimal value is 64096
i need to see 64096 in spool
can u plz tell me how it is possible

Thanks,
Ugandar
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 May 26, 2008 3:59 pm    Post subject:
Reply with quote

WS-BINARY is not a comp field it is a group item!
DISPLAY WS-BINARY-N.
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: Mon May 26, 2008 6:43 pm    Post subject: Reply to: How to display a Comp variable in cobol program
Reply with quote

Ugandar,

Was there a reason to completely repost you eariler post with no added info from you?

As you were told - do not display the group field.

You were also asked for some info. You should provide the requested info. . .

d
Back to top
View user's profile Send private message
ug123
Warnings : 1

New User


Joined: 01 Mar 2007
Posts: 39
Location: Chennai

PostPosted: Mon May 26, 2008 8:13 pm    Post subject: Reply to: How to display a Comp variable in cobol program
Reply with quote

Hi all,

Actually the problem is with compiler options.
i have changed the compiler options and now its working fine with the following code.

WS-BINARY
WS-BINARY-N PIC 9(4) BINARY.
WS-NUM PIC 9(5).
WS-NUM-N REDEFINES WS-NUM PIC 9(5) COMP.

MOVE WS-BINARY-N TO WS-NUM-N

Thanks,
Ugandar.
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: Mon May 26, 2008 9:52 pm    Post subject:
Reply with quote

Sorry, but that makes no sense. . . It might work, but it is silly.

A 9(5) comp field is not a proper redefines for a 9(5) field.


If you had done what was suggested by using the original elementary field (which you are using now anyway), you would have succeeded without this strange addition to the code. . .

And there is no mention of some change to compiler options.
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 -> FAQ & Off Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


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