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
 

 

Redefining a COMP-3 Variable.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    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

dbzTHEdinosauer

Global Moderator


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

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: 2150
Location: At my coffee table

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

Site Director


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

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: 22
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: 1592

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: 22
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

Site Director


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

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: 1592

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
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 Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


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