This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL
Moderators: dbzTHEdinosauer, Moderator Group
arrbee Active Member
Joined: Fri Feb 24, 2006 11:33 am
We are using "IBM Enterprise COBOL for z/OS 3.3.1" at our shop. I used the following code and surprisingly it did not give any compilation error or abend.
01 WS-NUM-1 PIC X(05).
01 WS-NUM-2 PIC S9(05) COMP.
MOVE 'ABCDE' TO WS-NUM-1.
MOVE WS-NUM-1 TO WS-NUM-2.
After executing the job I got the below result in the sysout:
ABCDE - display ws-num-1
12345 - display ws-num-2
Can you please tell me why?
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)
It wont give you an abend irrespective of the COBOL version you are using as when you try to move an alphanumeric to comp the best way to do is to redefine the alphanumeric to numeric and then move it to comp but then if you dont do the intermediate conversion cobol would internally represent it in teh hexadecimal form as
A B C D E
C C C C C
1 2 3 4 5
Hope i cleared ure doubt.
Joined: Mon Dec 13, 2010 4:15 pm
Did you get ABCD in your comp field after using REDEFINES with alphanumeric to numeric and then moving it to comp?I'm curious about it
Thanks and Regards
//EMPIRE EXEC PGM=WIFE
//SYSIN DD DSN=VARSHA.ME.HOME,DISP=SHR
//SYSOUT DD DUMMY
NicC Active Member
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm
Shivankoo - the code used was posted - do you see a redefines there? If there was another action taken at the time it may be that Arrbee does not remember as it was over 6 YEARS ago. Please try and avoid activating old posts.
<< Content deleted By Admin >>
Free tutorials from mainframegurukul
JCL Tutorial Covers all important JCL concepts.
Cobol Tutorial This tutorials covers all Cobol Topics from STRING to COMP-3.
DB2 Tutorial DB2 Tutorial focuses on DB2 COBOL Programming.
SORT Tutorial This Tutorial covers all important aspects of DFSORT with examples
CICS Tutorial This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Mainframe Interview questions
Mainframe Tools and others