IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

interview question

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL
View previous topic :: View next topic  
Author Message
ksivapradeep



Joined: 30 Jul 2004
Posts: 98

Posted: Mon Nov 29, 2004 3:49 pm    Post subject: interview question  

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



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

Posted: Tue Nov 30, 2004 1:37 am    Post subject:  

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



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

Posted: Tue Nov 30, 2004 2:12 am    Post subject:  

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  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM