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

Display COMP values.


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

New User


Joined: 28 Nov 2005
Posts: 12
Location: New Delhi

PostPosted: Tue Aug 22, 2006 2:59 pm
Reply with quote

I have field X with S9(09)v99 contains a value move which was moved from COMP-3. So now my X contains some numeric value that ends with {, }, H, I etc which are equivalent to C9, C8, C7 .... like this. I want this to be printed as -54858 or 8786 depending upon postive or negative. Can anybody suggest for this.
Back to top
View user's profile Send private message
PKumar

New User


Joined: 28 Sep 2004
Posts: 8

PostPosted: Tue Aug 22, 2006 3:47 pm
Reply with quote

Hi Killari,

As u want to display X's value which is of Comp type , u need to move X value which is of type display . I mean a field for ex Y defined with size S9(09)v99 . Then u can display the value of Y instead of X. I think i am able to reach ur requirement.

Regards
PKumar
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Aug 22, 2006 5:46 pm
Reply with quote

The alpha character at the end of your value contains the sign. x'c0' thru x'c9' are positive x'd0' thru x'd9' are negitive and x'f0' thru' 'f9' are unsigned.

Define your recieving field as PIC -(9)9.99. This will display the value with a floating '-' in front for negative values and nothing for positive values.

Note that there has been an additional two print positions added, one for the '.' and one for the sign.

Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Aug 24, 2006 3:39 am
Reply with quote

Sorry, David. It won't float. You'd have to use something like -(8)9.99
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Aug 24, 2006 4:33 am
Reply with quote

I thought it floated pretty well. If you define the field as ?(8)9.99 you chance truncating the hi order digit of a s9(9)v99 comp-3 field. Of course, the COMP-3 field never was explicitly defined, My assumption is that it was a also a S9(9)v99 COMP-3 field.

Code:

WORKING-STORAGE SECTION.                                     
                                                             
01 WS-C3                 PIC S9(9)V99  COMP-3               
                                       VALUE -123456789.01. 
01 WS-DISP8              PIC -(8)9.99.                       
01 WS-DISP9              PIC -(9)9.99.                       
                                                             
LINKAGE SECTION.                                             
                                                             
PROCEDURE DIVISION.                                         
                                                             
PROGRAM-START.                                               
                                                             
    MOVE WS-C3     TO WS-DISP8.                             
    DISPLAY 'WS-C3 ' WS-C3 ' WS-DISP8 ' WS-DISP8.           
                                                             
    MOVE WS-C3     TO WS-DISP9.                             
    DISPLAY 'WS-C3 ' WS-C3 ' WS-DISP9 ' WS-DISP9.           
                                                             



Code:

WS-C3 1234567890J WS-DISP8 -23456789.01
WS-C3 1234567890J WS-DISP9 -123456789.01


Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Aug 24, 2006 4:44 am
Reply with quote

Sorry again, David. I thought I "saw" -9(9).99, not what you had,
-(9)9.99. My mistake; you were correct.
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Thu Aug 24, 2006 10:01 am
Reply with quote

David/Jack,

I thought -9(9).99 & -(9)9.99 wouldn't make any difference, would they?

Regards, Twissi.
Back to top
View user's profile Send private message
kondakonda

New User


Joined: 20 Mar 2006
Posts: 34

PostPosted: Thu Aug 24, 2006 3:52 pm
Reply with quote

Both do not make any difference expect the leading zeros will be there for 9(9).99
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top