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

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

Post Reply
User avatar
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

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

Post by arrbee » Fri Feb 24, 2006 12:11 pm

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?
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

Guest

Post by Guest » Fri Feb 24, 2006 3:25 pm


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

Shivankoo
Member
Posts: 14
Joined: Mon Dec 13, 2010 4:15 pm

Post by Shivankoo » Tue Aug 14, 2012 12:45 pm

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!
Thanks and Regards
Shivankoo Sharma

//EMPIRE EXEC PGM=WIFE
//SYSIN DD DSN=VARSHA.ME.HOME,DISP=SHR
//SYSOUT DD DUMMY

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Tue Aug 14, 2012 1:20 pm

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.
Regards
Nic

academyindia4

Topic deleted by Admin

Post by academyindia4 » Wed Jan 27, 2016 8:34 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
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.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others