Page 1 of 1

Moving x(3) to S9(3) COMP.

Posted: Fri Feb 24, 2006 12:11 pm
by arrbee
Hi,

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.

Code: Select all

IDENTIFICATION DIVISION.       
PROGRAM-ID. COMP01.            
ENVIRONMENT DIVISION.          
DATA DIVISION.                 
WORKING-STORAGE SECTION.       
01 WS-NUM-1  PIC  X(05).       
01 WS-NUM-2  PIC S9(05) COMP.  
PROCEDURE DIVISION.            
MAIN-PARA.                     
    MOVE 'ABCDE' TO WS-NUM-1.  
    DISPLAY WS-NUM-1.          
    MOVE WS-NUM-1 TO WS-NUM-2. 
    DISPLAY WS-NUM-2.          
    STOP RUN.                  
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?

Posted: Fri Feb 24, 2006 3:25 pm
by Guest

Hi,

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. :-)

Prashant

Posted: Tue Aug 14, 2012 12:45 pm
by Shivankoo
Greetings!

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!

Posted: Tue Aug 14, 2012 1:20 pm
by NicC
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.

Topic deleted by Admin

Posted: Wed Jan 27, 2016 8:34 pm
by academyindia4
<< Content deleted By Admin >>