Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
interview question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
ksivapradeep

Active User


Joined: 30 Jul 2004
Posts: 98

PostPosted: Mon Nov 29, 2004 3:49 pm    Post subject: interview question
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
References
jz1b0c

Active User


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

PostPosted: Tue Nov 30, 2004 1:37 am    Post subject:
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: 180
Location: Toronto, Canada

PostPosted: Tue Nov 30, 2004 2:12 am    Post subject:
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1