View previous topic :: View next topic
|
Author |
Message |
srrao_kilari
New User
Joined: 28 Nov 2005 Posts: 12 Location: New Delhi
|
|
|
|
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 |
|
|
PKumar
New User
Joined: 28 Sep 2004 Posts: 8
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Sorry, David. It won't float. You'd have to use something like -(8)9.99 |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
twissi
Active User
Joined: 01 Aug 2005 Posts: 105 Location: Somerset, NJ
|
|
|
|
David/Jack,
I thought -9(9).99 & -(9)9.99 wouldn't make any difference, would they?
Regards, Twissi. |
|
Back to top |
|
|
kondakonda
New User
Joined: 20 Mar 2006 Posts: 34
|
|
|
|
Both do not make any difference expect the leading zeros will be there for 9(9).99 |
|
Back to top |
|
|
|