IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Redefining a COMP-3 Variable.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
srikar tenali

New User


Joined: 07 Feb 2007
Posts: 22
Location: hyderabad

PostPosted: Thu May 08, 2008 1:48 pm
Reply with quote

Code:

01  EMPL-REC.

     05  EMPL-REC-KEY-1.                 
          10  EMP-NBR-1           PIC S9(13) COMP-3.           
          10  EMP-CITY-1          PIC X(03).   
               
     05  EMPL-REC-KEY-2 REDEFINES EMPL-REC-KEY-1.                 
          10  EMP-NBR-2           PIC S9(10) COMP-3.           
          10  EMP-SUB-2           PIC S9(3) COMP-3.           
          10  EMP-CITY-2          PIC X(03).                 
   


Given above is File format of a record.
After the first read of the file, EMP-NBR-1 has 0098654512412 but EMP-NBR-2 has value 098654512 and EMP-SUB-2 has 2.
What values should i use in PIC clause of redefined variable so as to read the entire vaue correctly( i.e. EMP-NBR-2 should have value 0098654512 and EMP-SUB-2 should have 412)
Or please suggest any other method to divide the 13 digit comp-3 variable into first 10 and 3 digits.

Thanks in Advance,
Srikar
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu May 08, 2008 2:13 pm
Reply with quote

Code:

emp-nbr-1  pic s9(13) comp-3.  7 bytes  1 sign
emp-city-2 pic x(03).                 3 bytes
                                                               total 10 bytes

emp-nbr 2 pic s9(10) comp-3       6 bytes and 1 sign
emp-sub-2 pic s9(3) comp-3        2 bytes and 1 sign.
emp-city-2 pic x(03).                   3 bytes
                                                               total 11 bytes

have no idea how you really want to subdefine your field, but:

emp-nbr-2  pic 9(10) comp-3       5 bytes no sign
emp-sub-2 pic s9(3) comp-3        2 bytes and sign
emp-city-2 pic x(03).                   3 bytes
                                                               total 10 bytes

correctly redefines empl-rec-key-1
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu May 08, 2008 9:58 pm
Reply with quote

Code:
X'0098654512412C'
or 98654512412 is what you have in EMP-NBR-1.
Code:
X'009865451241'
or 986545124 with a bad sign is what you have in EMP-NBR-2.
Code:
            X'2C??'
or 2 is what you have in EMP-SUB-2 where the '??' is the hex content of the first byte in EMP-CITY-2.

You should have a compiler warning about the fact that the redefined area is larger than the redefined area.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri May 09, 2008 4:31 am
Reply with quote

Hello Srikar,

There is no way to use only redefines and get what you want. . .

To get what you want, create a 9(13) field in ws and move EMP-NBR-1 to it. Redefine the 9(13) field with 2 other fields - the first 9(10) and the second 9(3).

Code:
01 num-13   pic 9(13).
01 more-nums redefines num-13.
   05 num-10  pic 9(10).
   05 num-3   pic 9(3).

    move EMP-NBR-1 to num-13.

   whatever code you need for num-10 and num-3. . .
Back to top
View user's profile Send private message
srikar tenali

New User


Joined: 07 Feb 2007
Posts: 22
Location: hyderabad

PostPosted: Fri May 09, 2008 6:25 pm
Reply with quote

Its Working.Thanks.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri May 09, 2008 8:40 pm
Reply with quote

srikar,

Does that mean we'll never hear from you again? If it's not too much trouble, could you please let us know how you got it "Working"?
Back to top
View user's profile Send private message
srikar tenali

New User


Joined: 07 Feb 2007
Posts: 22
Location: hyderabad

PostPosted: Sat May 10, 2008 10:20 am
Reply with quote

Solution provided by d.sch. is working fine.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat May 10, 2008 2:37 pm
Reply with quote

Thank you for letting us know it is working icon_smile.gif

d
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon May 12, 2008 8:24 pm
Reply with quote

srikar,

Thanx for letting us know.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top