where TT01 is the header record and RT01 is the trailer record(TD01 - detail record).
1) I have to eliminate duplicates by comparing the 3 fields in the header record with that of all the records in the control file(in the above case position 5,6,7). This control file should contain the 3 fields specified above for the last 20 headers. I have to write the control file through this program.
2) Also i have to check whether the header record is having the corresponding trailer record. If you check the second header it does not have a trailer record, so it is not a good one and have to write the entire set to an error file. If the 3 field values are not in the control file also if it has a trailer record then it's a good one and i have to write this to the output file.
3) And the control file which is a flat file should have only 20 records, if it is more i have to delete the old records and maintain only 20 records.
I have already posted this under cobol but wanted to know whether this is possible in DFSORT, if so it would be helpful for me.
It's not clear what you want from what you've posted. You need to supply more details. Please show an example of the control file, all of the different variations for the groups of records that can appear in the input file, and the expected output records.
I don't understand what you mean by "This control file should contain the 3 fields specified above for the last 20 headers". Please explain what you mean more clearly with an example.
I also don't understand what you mean by number 3). Please explain what you mean more clearly with an example.
Also, give the RECFM and LRECL of the control file and the input file.
The length of the control file is 3, which should contain fields in position 5,6 and 7 of the input file (of the header- TH01). We are using this file for comparing with the input file also we have to write the header details into this file.
The input file has a record length 80 which is given above. Also the record length of error file and output file is 80.
So the control file should be written like this
and i should take care it contains only 20 records because if i compare the input file headers(position 5,6,7) with that of these 20 records in the control file, it would be sufficient for eliminating duplicates.
So the input file headers fields (position 5, 6,7) should be compared with all the 20 records(position 1,2,3) and check for duplicates, also it should check for the trailer record for the corresponding header.
In the above case the first header does have duplicates, also it has a trailer record, so it should go the output file like
The second header doesn't have duplicates but no trailer record , so it should go to the error file like
The third header have duplicates (even though it has a trailer record) ,so again it should be written to the output file similar to the first header.
Please let me if i need to provide any other information.
In the above case the first header does have duplicates
The second header doesn't have duplicate
I can't figure out what you mean by "duplicates". I thought by "duplicates" you meant a match between the header and control file. The first header has ABC and there's a matching ABC in the control file. But the second header has DEF and there's a matching DEF in the control file, yet you say the second header doesn't have a duplicate. So I can't figure out what it is you mean.
Please explain more clearly what you mean by "duplicate" and why the first header has a duplicate but the second header doesn't.
Please show a more complete example of input records including a header/trailer with a duplicate, a header/trailer without a duplicate, a header/no trailer with a duplicate and a header/no trailer without a duplicate, and show the corresponding output records.
and i should take care it contains only 20 records
And what do you want to do if it contains more than 20 records? Keep only the first 20 records? Keep only the last 20 records? Or what?
and the control file is having 2 records like
So the header record(position 5,6,7) will be compared with this control file(both the records).
For the first TT01 header there is no matching record in the control file so it is not a duplicate one but still it should check for the trailer RT01 record for the corresponding header. The first header have a corresponding trailer, hence it goes to the output file like
The second header also doesn't have a matching record in the control file
but it also doesn't have a trailer record so it is a partial one which will go to the error file like:
The third header have matching record in the control file, so it will go to the error file
RT01312 adding with the second header.
The fourth header also have a matching record in the control file, it will be written to the error file:
Basically, first duplicate check should be made, if duplicates are not found we have to check whether it has a corresponding trailer. If duplicates are found, no need to check for the trailer record because we are confirming that it should go to the error file. But it should be written to the error file from header to the corresponding trailer.
2) Regarding your second question, i want to keep only last 20 records in the control file. The control file is a flat file and i want to delete the old records.
3) Also in addition to writing into the output and error file, if a duplicate is not found also if it has a trailer record then the position 5,6,7 of the header record should be written to the control file.
1) If the control file has more than 20 records, you want to keep the last 20 records (for example, if the control file has 22 records, you want to keep records 3-22). Right?
2) If a "group" has a header record and a trailer record and if the header record does NOT have a match in the control file, you want to write that "group" to the output file, and you want to add its header string to the control file. And all other records go to the error file. Right?
Does every group have one and only one TD record? Or can a group have no TD records or more than one TD record?
Please run this job and post the //SYSOUT messages - I want to see what level your at:
1ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 23:35 ON TUE MAY 29, 2007 -
ICE201I E RECORD TYPE IS F - DATA STARTS IN POSITION
Thanks a lot. But i tried running the job, it is failing in 'COPY FROM(CF) USING(CTL2)'. I think CTL2 is missing in between. Please correct me if i am wrong because this is the first time i am using ICETOOL. I am going through the manuals to understand it better.
And now i got the sample input file, hence the record length of the input file, output file and error file is 900. The control file will be of length 24(position 58-81 of the input file) but i want to keep it as 80.
The record in the input file looks like:
TH0101.00999395OA ADF B200607 1323
So, the fields to be compared are 1) the field from position 58-59 2) 60-61 3) 62-81
And the control file will look like
because position 62-81 is blank in the input file.
I hope the changes required for the new record lengths would be:
1) 'SELECT FROM(CON1) TO(T4) ON(5,3,CH) NODUPS USING(CTL4)'
this will be changed to 'SELECT FROM(CON1) TO(T4) ON(58,24,CH) NODUPS USING(CTL4)'
COPY FROM(CF) USING(CTL2) 00060907
ICE606I 0 DFSORT CALL 0003 FOR COPY FROM CF TO OUTFIL USING CTL2CNTL TERMINATED
ICE602I 0 OPERATION RETURN CODE: 16
1ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0003
ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND MORE
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 04:12 ON THU MAY 31, 2007 -
OUTFIL FNAMES=T1,BUILD=(5:1,3,36:X) 00047007
OUTFIL FNAMES=CFOUT,BUILD=(1,3) 00048007
ICE146I 0 END OF STATEMENTS FROM CTL2CNTL - PARAMETER LIST STATEMENTS FOLLOW
ICE201I E RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE222A 0 3 BYTE FIXED RECORD LENGTH IS NOT EQUAL TO 80 BYTE LRECL FOR CFOUT
ICE751I 0 C5-K21008 C6-K90007 C7-K90000 C8-K90007 E9-K90007 E7-K11698
ICE052I 3 END OF DFSORT
I really apologize for the change in the requirement. The problem is even i got the proper sample input file yesterday only, before that just i know the logic that needs to be implemented.
Now the changes in the requirement are only the record lengths.
The record length of input, error and output file is 900 which was 7 before.
Similarly the record length of control file is 24 which was 3 before. I just said i want to keep the length of control file as 80 so that it will be having data only in 24 bytes and the rest will be fillers.
Also before, the position 5,6,7 of the input file was compared with position 1,2,3 of the control file. Now fields in position 1) 58-59 2) 60-61 3) 62-81 of the input file will be compared with position 1)1-2 2) 3-4 3) 5-24 of the control file.
The change here is the position of the fields which needs to be compared.
where TT01 is the header record and RT01 is the trailer record
and all of your previous examples followed that.
Now you are showing data with TH01 and TT01 and you wonder why the solution I gave you doesn't work. Well, it was set up for TT01 headers - you never mentioned TH01 headers before. At this point, I don't know what you want any more.
Sorry for the confusion. I have mentioned TT01 and RT01 as headers and trailers in my initial post. After that in the sample file i got the headers and trailers as TH01 and TT01 respectively. I should have commmunicated this to you.
Now i have replaced TT01 with 'TH01' and RT01 with 'TT01' in your revised job and now it is working perfectly fine as per the requirement.