Joined: 23 Feb 2007 Posts: 25 Location: Dallas, TX
Hi,
Iam trying to sort an 84 byte fixed block file which has a few headers, a number of detail records and a few trailers.
1. The header record has its first two bytes as '10', followed by a timestamp when that header was created.
2. The detail record has its first two bytes as '20'.
3. The trailer record has its first two bytes as '30', followed by a number in the packed decimal format S9(9) Comp-3
4. The number of headers would always be equal to the number of trailers.
I want to build a file out of it that has just the first header present in the given file and just one trailer. In the trailer record that I finally get, the first two bytes, that is '30' should be followed by the sum of numbers present in all the trailer records in the packed decimal format. The detail records should be untouched and should be present in the file between the header and trailer without any editing.
The file looks something like this
Code:
Command ===> Scroll ===> CSR
****** ***************************** Top of Data *****************************
000001 101999-12-30-23.38.22.113649
000002 205319457130004002 AA NN
000003 209000001360112006 BP YN
000004 206191145740208003 CVM YN
000005 30.....
000006 101999-12-30-23.38.22.329272
000007 205319390000001016 DV NN
000008 209000001360121007 BP YN
000009 206111210000001014 BP YN
000010 30.....
****** **************************** Bottom of Data ***************************
Thus, in the final output, we should have
Code:
****** ***************************** Top of Data *****************************
000001 101999-12-30-23.38.22.113649
000002 205319457130004002 AA NN
000003 209000001360112006 BP YN
000004 206191145740208003 CVM YN
000005 205319390000001016 DV NN
000006 209000001360121007 BP YN
000007 206111210000001014 BP YN
000008 30.....
****** **************************** Bottom of Data ***************************
where the type '30' record should be followed by the number 6(total number of type '20' records) in packed decimal format.
The problem is that though am able to get rid off the extra type '10' records but Iam getting a S0C7 in the CTL3CNTL step due to which Iam not able to sum and filter out the type '30' records.
Can any one please help me out with this ??? Thanks in advance !
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
Hello,
At a quick glance, it appears that your data is Zoned Decimal while your control statement refers to Packed Decimal. Try changing the PD to ZD in the SUM statement.
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
I'm not real good at this, but from what your code looks like, why aren't just creating T1 as the header with sequence (include the first and 10 only), T2 as the data with sequence (include 20 only) and T3 as the trailer with sequence, summing on the packed field (include 30 only). sort on the 10/20/30 and the seq and drop the seq on output?
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
Hello,
What is in the 30 records starting in position 3? Whatever it is, it does not seem to be numeric for 5 bytes.
I copied your step onto my machine, changed the input to dd *, and got the 0c7. I then changed the value in the first 30 record to 11111 and the value in the second 30 record to 22222 and when the "summed" 30 record was created, i have 33333 (the sum). I also changed the SUM to use ZD for my test.
I'd copy/paste my results, but the remote emulator this site uses is fairly horrible - among other things, it doesn't do copy/paste.
When i go back onsite in the morning i'll send my output if you're interested.
Please look at the 5 bytes starting in position 3 of the 30 recs in hex and see if they even look like packed decimal numbers. Might they be comp rather than comp-3?
Joined: 23 Feb 2007 Posts: 25 Location: Dallas, TX
Hi Dick,
Its S9(9) COMP-3 and it starts from the 3rd byte in the record.... Iam still puzzled as to why am getting the S0C7 abend... its kinda getting on my nerves now...
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
Hello,
Please look at the data in hex (TSO/Browse) and post back what is in the first 10 bytes of the '30' records. Hopefully, a test of only a few can be run.
Once you post the hex for the 30 records, we will be able to determine why the 0c7. When you post them, please use the "code" tab at the top of the reply panel. "Code" uses a fixed font and lines up better.
Do you have access to the code that creates the records? A look at that may prove interesting also.
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
You're welcome.
Well, that 30 record looks good. What's the chance of making a copy of the input file and only running 2 "groups of data - verifying that both 30's have a valid packed number?
Is it possible that deeper into the file is one or more corrupted 30?
I'm going to be on the road in a short while, but hope to get back online tonight and tweak my test file to include PD rather than the test i did w/ ZD.
Joined: 23 Feb 2007 Posts: 25 Location: Dallas, TX
Hi Dick,
Thanks for your reply. The problem exists with Type '20' records. When the type 20 records are included, I get a S0C7 abend but when I exclude them, the job runs fine and the sum is also calculated correctly for the type '30' records.
Although the my sort logic does not include type '20' records but Iam confused why Iam getting a S0C7 cos of it. Could you please figure out where the problem lies in my logic ?
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
I know it's a stupid question, but it looks like you are summing in cntl3 the type 30 trailers and it looks like you are expecting the type 30 trailers to be in the T2 file but it also looks like the T2 file has no type 30 trailers since the T2 dataset got created by the cntl2 which omits all 30's and includes everything else.....