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

How to display comp-3 value


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

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Mon Nov 29, 2004 3:49 pm
Reply with quote

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
View user's profile Send private message
jz1b0c

Active User


Joined: 25 Jan 2004
Posts: 160
Location: Toronto, Canada

PostPosted: Tue Nov 30, 2004 1:37 am
Reply with quote

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
View user's profile Send private message
jz1b0c

Active User


Joined: 25 Jan 2004
Posts: 160
Location: Toronto, Canada

PostPosted: Tue Nov 30, 2004 2:12 am
Reply with quote

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
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 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
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top