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 we directly display the COMP-3

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

New User


Joined: 13 Jul 2012
Posts: 1
Location: India

PostPosted: Tue Aug 07, 2012 12:47 pm    Post subject: Can we directly display the COMP-3
Reply with quote

Hi,
I want know the reason that why can't we directly display the COMP-3 variable directly, and why it is always required to move to the Numeric variable and then only we can display.

If we display directly what error will occur.
Back to top
View user's profile Send private message

Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Tue Aug 07, 2012 1:02 pm    Post subject: Reply to: Cobol about COMP-3 variable
Reply with quote

Who told you such lies?
Is this an interview question?
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Aug 07, 2012 1:18 pm    Post subject: Re: Cobol about COMP-3 variable
Reply with quote

Manish Dhole wrote:
I want know the reason that why can't we directly display the COMP-3 variable directly, and why it is always required to move to the Numeric variable and then only we can display.

If we display directly what error will occur.
Such a deal of confusion in such a small post.

First, you can DISPLAY COMP-3, without any error -- why do you think there should be an error? Have you tried soemthing?

COBOL Comp-3 is a binary field type that "packs" two digits into each byte (using the BCD). This halves the storage requirements compared to a character, or COBOL "display" field. However, comp-3 is not commonly found in PC languages and so the understanding about it is beyond words!

For examples on how comp-3 data is stored, let's see this
Code:
     Value  Comp-3, hex
       +0           0C
       +1           1C
      +12        01 2C
     +123        12 3C
    +1234     01 23 4C

The left column in the table decimal value being stored, and the right column is the hexadecimal value you will see in the file and the values in the file/SYSOUT make sense to you or not depends on if you understand COMP-3 notation or not.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Aug 07, 2012 1:26 pm    Post subject:
Reply with quote

Anuj,

Nice post icon_smile.gif

Probably we need to have a sticky how a COMP,COMP2,COMP3 is stored ??
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Aug 07, 2012 1:34 pm    Post subject:
Reply with quote

Once in a while my mood swings to a better side...icon_wink.gif. Possibly, we can have sticky but this is an "expert forum" ... icon_biggrin.gif
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Aug 07, 2012 1:53 pm    Post subject:
Reply with quote

Expert forum might help groom others to experts icon_wink.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Tue Aug 07, 2012 2:11 pm    Post subject: Reply to: Cobol about COMP-3 variable
Reply with quote

Well, this sticky might be of help with the question.

You get the same effect with COMP-3.

It can be convenient to move to a signed-edited field before DISPLAYing it, but the only "problem" is with interpreting the sign and the right-most digit correctly. Setting the display to HEX can also reveal the values.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Aug 07, 2012 5:28 pm    Post subject:
Reply with quote

Quote:
why can't we directly display the COMP-3 variable directly, and why it is always required to move to the Numeric variable
1. COMP-3 variables are numeric, period. You can check this in the COBOL Language Reference manual (link at the top of this page) by reading 5.1.6.6 Classes and categories of data.

2. Who told you you could not use DISPLAY on a COMP-3 variable? You would be wise to stop listening to that person's comments about COBOL -- no matter who it is -- because their advice is completely and totally WRONG! There have been many examples posted on this forum where DISPLAY VAR is used and VAR is defined as COMP-3.
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 to display value of an exit param... lind sh CICS 2 Sun Oct 09, 2016 12:28 pm
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 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
This topic is locked: you cannot edit posts or make replies. Get and display content of an address... lind sh CICS 1 Mon Aug 08, 2016 9:18 am


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