Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
Hi,
I want to know whether can we compare two records which are in same file and write to output file based on conditions.
Here is my requirement.
Input file is FB and LRECL is 23.
UNUM is 9(6)
ACCNO is 9(6)
CUST is 9(6)
NO is 9(3)
ID is x(2) will have either DM or SPACES
Code:
Condition 1:
Input file:
UNUM ACCNO CUST NO ID
11111 22222 33331 10 DM
11111 22222 33332 20
Output File:
11111 22222 33331 10 DM
If there are two records of same 'UNUM' and 'ACCNO', then check whether 'ID' field is populated or having spaces. If 'ID' is populated then we need to write that particular record to output
Code:
Condition 2:
Input file:
UNUM ACCNO CUST NO ID
11111 22222 33331 10 DM
11111 22222 33332 20 DM
Output File:
11111 22222 33332 20 DM
If there are two records of same 'UNUM' and 'ACCNO', and for those both records if the 'ID' field is having same VALUE or SPACES, then we need to compare 'NO' field. The record which has least 'NO' value should be written to output
Code:
Condition 3:
Input file:
UNUM ACCNO CUST NO ID
11111 22222 33331 20 DM
11111 22222 33332 20 DM
Output File:
11111 22222 33332 20 DM
If there are two records of same 'UNUM' and 'ACCNO', and for those both records if the 'ID' field is having same VALUE or SPACES and 'NO' field is having same value, then we need to compare 'CUST' field. The record which has greater 'CUST' value should be written to output
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
bhaskar_kanteti,
Your condition2 does not match the output. You say you need to pick the least 'NO' valued record but in your output you picked 20 record which is the highest number record. If it indeed is a typo then the following DFSORT/ICETOOL JCL will give you the desired results