So i need to sort the INPUT file based on the key(NASCO-SUB-ID,NASCO-DEP-ID,SRC-SYS-KEY) to get the latest record with respect to the Timestamp.
The key which i have mentioned above forms the unique key for that input file. so i need to retrieve the latest record containing the highest timestamp from the input file for each unique key.
In the Input file, some of the records contains 'blanks' for the columns NASCO-SUB-ID,NASCO-DEP-ID respectively.
when i tried to sort using JCL, the records conatining blanks in the Key field are getting eliminated.
All the records contain SRC-SYS-KEY column in the input file.
The key( the three fields which u specified) wont be unique if the records contains 'blanks' for the columns NASCO-SUB-ID, NASCO-DEP-ID. so these recods fall under duplicate cond and was eliminated due to SUM fields.
Correct me if i am wrong, there will be one record which has SRC-SYS-KEY but NASCO-SUB-ID and NASCO-DEP-ID are balnk respectively.
let me know how will you decide the uniqueness of records if the fields NASCO-SUB-ID, NASCO-DEP-ID are balnk. are there any other fields to decide this, if not then it is difficult to separate them out as they fall under one category.
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
Quote:
when i tried to sort using JCL, the records conatining blanks in the Key field are getting eliminated.
The records containing blanks in the key fields(NASCO-SUB-ID,NASCO-DEP-ID) will get eliminated only when the other field (SRC-SYS-KEY)has got the same(duplicate) values.
consider 2 records with the value in the 3 fields.
blank blank 100
blank blank 100
when you give SUMFIELDS= NONE these will be considered as duplicates.
According to my understanding You dont want this to be considered as duplicates right? Correct me if am wrong.
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
Could you please try this.
1) Seperate the input file into two, one (File 1)without blanks in those two fields and the other (File 2) with blanks in those 2 fields. This can be done using OUTFIL\INCLUDE.
2) Sort the file 1 on those 3 fields and then eliminate the duplicates using SUM FIELDS=NONE
3) Sort the file on the 3rd key field and then eliminate the duplicates.
4) concatenate both the files to get the final output.
Techies, please advise if this can be done in a better way than is.
***************************** Top of Data ******************************
001
002
004
**************************** Bottom of Data ****************************
This will not eliminate all the records which are having blanks in those 2 fields. It will just eliminate those records which has duplicate values in the 3 rd field with blanks in the other two fields.