View previous topic :: View next topic
|
Author |
Message |
srikar tenali
New User
Joined: 07 Feb 2007 Posts: 22 Location: hyderabad
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
or 98654512412 is what you have in EMP-NBR-1.
or 986545124 with a bad sign is what you have in EMP-NBR-2.
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
srikar tenali
New User
Joined: 07 Feb 2007 Posts: 22 Location: hyderabad
|
|
|
|
Its Working.Thanks. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
srikar tenali
New User
Joined: 07 Feb 2007 Posts: 22 Location: hyderabad
|
|
|
|
Solution provided by d.sch. is working fine. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Thank you for letting us know it is working
d |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
srikar,
Thanx for letting us know. |
|
Back to top |
|
|
|