Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Redefines Clause not giving expected result

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sudhakar_lendave

New User


Joined: 21 Nov 2006
Posts: 48
Location: mumbai

PostPosted: Thu Aug 23, 2007 6:30 pm    Post subject: Redefines Clause not giving expected result
Reply with quote

Code:
IDENTIFICATION DIVISION.             
PROGRAM-ID. PGM.                     
DATA DIVISION.                       
WORKING-STORAGE SECTION.             
01  WS-RECORD.                       
    05 A   PIC X(5) VALUE ALL SPACES.
    05 B REDEFINES A                 
           PIC 9(5).                 
01  C  PIC 9(5) VALUE ALL ZEROS.     
                                     
PROCEDURE DIVISION.                 
    MOVE '231'  TO A.               
    DISPLAY 'A : ', A.               
    DISPLAY 'B : ', B.               
    STOP RUN.                       


Now when i execute this code
Code:

A : 231 
B : 231 

This means a and B both contains '231 '
Since B is PIC 9(5), it should show 00231

I am not getting why this is happening.

What should i do to get 00231?


Sudhakar.
Back to top
View user's profile Send private message

dr_te_z

New User


Joined: 08 Jun 2007
Posts: 71
Location: Zoetermeer, the Netherlands

PostPosted: Thu Aug 23, 2007 6:44 pm    Post subject:
Reply with quote

move 231 to B.
Back to top
View user's profile Send private message
sudhakar_lendave

New User


Joined: 21 Nov 2006
Posts: 48
Location: mumbai

PostPosted: Thu Aug 23, 2007 6:49 pm    Post subject:
Reply with quote

thanks dr_te_z,
but the thing is my variable A gets populated whenever i read a file.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Aug 23, 2007 6:58 pm    Post subject:
Reply with quote

Why should B display 00231?
Back to top
View user's profile Send private message
sudhakar_lendave

New User


Joined: 21 Nov 2006
Posts: 48
Location: mumbai

PostPosted: Thu Aug 23, 2007 7:03 pm    Post subject:
Reply with quote

Sorry steve i wasn't specific.

Actually whenever i read a file, A gets the data in it.

Now i wanted this A should be compared with C which is numeric.

So i think, redefining A with B will give me B as a numeric.
and now i can compare B and C.

But it's not working.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Aug 23, 2007 7:09 pm    Post subject:
Reply with quote

all you have when you redefine an alpha field as numeric is a numeric field that has been populated with alpha data.

you need to extract the numeric value (COBOL intrinsic function NUMVAL) from the alpha field, storing the results in a numeric field, then make your compare.
Back to top
View user's profile Send private message
sudhakar_lendave

New User


Joined: 21 Nov 2006
Posts: 48
Location: mumbai

PostPosted: Thu Aug 23, 2007 7:21 pm    Post subject:
Reply with quote

Thanks Dick.. it's working now.

________________
Sudhakar.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts scheduling between OPC and TWS give u... nsbl IBM Tools 4 Sun Mar 12, 2017 5:35 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us