Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Redefining a COMP-3 Variable.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
srikar tenali

New User


Joined: 07 Feb 2007
Posts: 18
Location: hyderabad

PostPosted: Thu May 08, 2008 1:48 pm    Post subject: Redefining a COMP-3 Variable.
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
References
PostPosted: Thu May 08, 2008 1:48 pm    Post subject: Re: Redefining a COMP-3 Variable. Reply with quote

dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 1189
Location: germany

PostPosted: Thu May 08, 2008 2:13 pm    Post subject:
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: 1086
Location: At my desk

PostPosted: Thu May 08, 2008 9:58 pm    Post subject:
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

Global Moderator


Joined: 23 Nov 2006
Posts: 6983
Location: 221 B Baker St

PostPosted: Fri May 09, 2008 4:31 am    Post subject:
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: 18
Location: hyderabad

PostPosted: Fri May 09, 2008 6:25 pm    Post subject: Reply to: Redefining a COMP-3 Variable.
Reply with quote

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

Super Moderator


Joined: 30 May 2003
Posts: 1474

PostPosted: Fri May 09, 2008 8:40 pm    Post subject:
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: 18
Location: hyderabad

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

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

Global Moderator


Joined: 23 Nov 2006
Posts: 6983
Location: 221 B Baker St

PostPosted: Sat May 10, 2008 2:37 pm    Post subject: Reply to: Redefining a COMP-3 Variable.
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: 1474

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

srikar,

Thanx for letting us know.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1