|
|
| Author |
Message |
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 87 Location: India
|
|
|
|
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 |
|
| Back to top |
|
 |
References
|
|
 |
Skolusu
DFSORT Developer
Joined: 07 Dec 2007 Posts: 357 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
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
111111222222333331010DM
111111222222333332020
222222222222333331010DM
222222222222333332020DM
333333222222333331020DM
333333222222333332020DM
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(01,12,CH) FIRST USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(01,06,CH,A, $ UNUM
07,06,CH,A, $ ACCNO
22,02,CH,D, $ ID
19,03,ZD,A, $ NO
13,06,ZD,D) $ CUST
//* |
Hope this helps...
Cheers |
|
| Back to top |
|
 |
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 87 Location: India
|
|
|
|
Hi Skolusu,
Thanks for your beautiful solution.
This gave me the desired output.
Its really so simple and easy.
Thank you so much. |
|
| Back to top |
|
 |
|
|
|