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

Display COMP-3 variable in Enterprise COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
akodakka

New User


Joined: 20 May 2010
Posts: 75
Location: India

PostPosted: Fri Apr 19, 2013 6:18 pm
Reply with quote

I am going back to the basics .

I have coded as below and i was expecting the display in a unreadable format as the variable is COMP3 but i am getting the sysout as readable format..any basics that i am missing?

Code:

01  TEST-DIGIT                     PIC 9(05).           
01  TEST-COMP3                     PIC 9(03) COMP-3.   
                                                       
PROCEDURE DIVISION.                                     
    MOVE 90 TO TEST-DIGIT                               
    COMPUTE TEST-DIGIT = TEST-DIGIT * 2                 
    MOVE TEST-DIGIT TO  TEST-COMP3                     
    DISPLAY TEST-COMP3                                 
    INITIALIZE TEST-DIGIT                               
               TEST-COMP3                               
    COMPUTE TEST-COMP3 = 89 * 3                         
    DISPLAY TEST-COMP3                                 
    GOBACK.                                             
Back to top
View user's profile Send private message
charanmsrit

New User


Joined: 25 Oct 2007
Posts: 81
Location: Australia

PostPosted: Fri Apr 19, 2013 6:24 pm
Reply with quote

Hi,

your terminology "unreadable" is a perception.

have a look at your compile listing and see what assembler instructions are generated by DISPLAY command. that should answer your question. use compiler option LIST
Back to top
View user's profile Send private message
akodakka

New User


Joined: 20 May 2010
Posts: 75
Location: India

PostPosted: Fri Apr 19, 2013 6:39 pm
Reply with quote

Hi i checked my listing but didn't get assember command for thr diaplay all i get from my listing is as below

Code:

NAME:            ENTRY TYPE AMODE C_OFFSET CLASS NAME        STATUS   
                                                                     
LEARN01           MAIN_EP      31 00000000 B_TEXT                     
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Fri Apr 19, 2013 6:52 pm
Reply with quote

akodakka wrote:
Hi i checked my listing but didn't get assember command for thr diaplay all i get from my listing is as below

Code:

NAME:            ENTRY TYPE AMODE C_OFFSET CLASS NAME        STATUS   
                                                                     
LEARN01           MAIN_EP      31 00000000 B_TEXT                     


RTFM about the display verb for your version of COBOL!
Back to top
View user's profile Send private message
akodakka

New User


Joined: 20 May 2010
Posts: 75
Location: India

PostPosted: Fri Apr 19, 2013 6:56 pm
Reply with quote

My apologies!!
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: Fri Apr 19, 2013 7:22 pm
Reply with quote

When you DISPLAY, any COMPUTATIONAL fields will be converted to a "readable" format.

If you want to see the internal format, REDEFINES it as PIC X(of appropriate size) or make it subordinate to a group item. DISPLAY the PIC X field or the group item, and then SET HEX ON when you view the output.

Or search here for the "Junk Buster".
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 19, 2013 7:46 pm
Reply with quote

There is a link to IBM Manuals at the top of this page. If you click on it, find the Enterprise COBOL Application Programming Reference manual, and read 6.2.10 in this manual on the DISPLAY statement, you will find
Quote:
If identifier-1 is a binary, internal decimal, or internal floating-point data item, identifier-1 is converted automatically to external format as follows:

Binary and internal decimal items are converted to zoned decimal. Negative signed values cause a low-order sign overpunch.

Internal floating-point numbers are converted to external floating-point numbers for display such that:

A COMP-1 item will display as if it had an external floating-point PICTURE clause of -.9(8)E-99.

A COMP-2 item will display as if it had an external floating-point PICTURE clause of -.9(17)E-99.
Internal decimal means COMP-3 if you don't know that.

The real question is why you were unable to do this research yourself -- and there are not very many good answers to that question.
Back to top
View user's profile Send private message
Santoshgude

New User


Joined: 06 May 2013
Posts: 3
Location: INDIA

PostPosted: Wed May 08, 2013 12:24 pm
Reply with quote

Hi akodakka,

As per my knowledge,If we need to display COMP#3 move into another field then first we need to move to a working variable having COMP3 equalennt length in naormal bytes.Then that working variable you can move to COMP#3 then Display will work ..

Let me know if you confused.

Thanks,
Santosh.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed May 08, 2013 12:43 pm
Reply with quote

Quote:
Let me know if you confused.

did You read and try to understand the topic before posting ???

we are not confused... YOU ARE icon_cool.gif

You are mixing up two different concepts ,

the use of the DISPLAY clause which as already explained automatically converts numeric fields to a <displayable> format

the process of converting ON YOUR OWN numeric fields to a to a <displayable> format

You should see now how Your comment does not apply to the topic.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed May 08, 2013 4:45 pm
Reply with quote

Santosh, first your post is poorly written so the meaning of what you are saying is not clear without re-reading it.

Second, you are flat out wrong. Enterprise COBOL will convert a COMP-3 variablle to USAGE DISPLAY when you issue a DISPLAY on that variable without needing to move the COMP-3 variable anywhere.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Wed May 08, 2013 7:02 pm
Reply with quote

Make the comp-3 variable a part of a larger group, then display that group:

01 Group
05 field1 comp-3.

DISPLAY Group

Then you can play with it.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed May 08, 2013 7:21 pm
Reply with quote

That's new: somebody is complaining that he is not getting "junk characters"... icon_smile.gif

Use signed fields (PIC S9(5) and PIC S9(3)), use positive and negative values, with any luck you will see numbers like '9{' or '9}'.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu May 09, 2013 7:33 pm
Reply with quote

My favorite fix I ever did was because of signed vs unsigned display fields.

The printer ID in a customer shop got moved from alpha to numeric, then back. They would send a print to ID 12345J and it would end up on printer 123451.

That was a lot of fun explaining it to people who didn't know about that kind of thing.
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 Replace each space in cobol string wi... COBOL Programming 3
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
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top