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

How to display a Comp variable in cobol program


IBM Mainframe Forums -> FAQ & Basics
Post new topic   Reply to topic
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
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: 2146
Location: At my coffee table

PostPosted: Sun May 25, 2008 2:02 am
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
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: 2146
Location: At my coffee table

PostPosted: Sun May 25, 2008 2:26 am
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

Moderator Emeritus


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

PostPosted: Sun May 25, 2008 2:35 am
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
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: 2146
Location: At my coffee table

PostPosted: Sun May 25, 2008 2:53 am
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
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

Moderator Emeritus


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

PostPosted: Sun May 25, 2008 3:32 am
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
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
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

Moderator Emeritus


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

PostPosted: Mon May 26, 2008 6:43 pm
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
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

Moderator Emeritus


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

PostPosted: Mon May 26, 2008 9:52 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> FAQ & Basics

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top