View previous topic :: View next topic
|
Author |
Message |
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
hi,
how to display comp-3 value this question asked in one interview what i told is normally using display statement he didnt agree with that i made argue with this by telling that comp-3 will convert the usage to DISPLAY while diplaying the value.and another this i got is the comp-3 value has to move in to another variable and we have to display which one is correct.
regards,
siva pradeep |
|
Back to top |
|
|
jz1b0c
Active User
Joined: 25 Jan 2004 Posts: 160 Location: Toronto, Canada
|
|
|
|
Simply displaying a comp-3 will work out
01 ws-comp3 pic 9(10) comp-3 value 12345.
now display ws-comp3 will give 0000012345
possibly his question might be to avoid those zeros. because in statements it doesnt look good to display zeroes.
this code will give you the answer
01 WS-C1 PIC 9(10) COMP-3 VALUE 12345.
01 WS-R2 PIC X(10).
MOVE WS-C1 TO WS-R2.
DISPLAY 'WS-R2 ' WS-R2.
INSPECT WS-R2 REPLACING LEADING ZEROS BY SPACES.
DISPLAY 'WS-R2 ' WS-R2. |
|
Back to top |
|
|
jz1b0c
Active User
Joined: 25 Jan 2004 Posts: 160 Location: Toronto, Canada
|
|
|
|
YOU CAN ALSO DO LIKE THIS
01 WS-C2 PIC ZZZZZZZZZ9.
01 WS-C1 PIC 9(10) COMP-3 VALUE 12345.
MOVE WS-C1 TO WS-C2.
DISPLAY 'WS-C2 ' WS-C2.
THIS WILL ALSO GIVE YOU 12345. |
|
Back to top |
|
|
|