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

Can we directly display the COMP-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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

Superior Member


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

PostPosted: Tue Aug 07, 2012 1:18 pm
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

Global Moderator


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

PostPosted: Tue Aug 07, 2012 1:26 pm
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

Superior Member


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

PostPosted: Tue Aug 07, 2012 1:34 pm
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

Global Moderator


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

PostPosted: Tue Aug 07, 2012 1:53 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Aug 07, 2012 2:11 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Aug 07, 2012 5:28 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Call program, directly from panel CLIST & REXX 9
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts How to display the leading zeros of a... DB2 7
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
Search our Forums:

Back to Top