|
View previous topic :: View next topic
|
| Author |
Message |
vsrao_2k
New User
Joined: 12 Dec 2005 Posts: 13
|
|
|
|
I have a file with 4 columns. I'm using ICETOOL to get the latest record. Apart from this, I want to get the records, if last and last but one record are same.
Example:
FIELD1 FIELD2 FIELD3 FIELD4
1501 20090828 CA 20090928
1501 20090828 CA 20091029
1501 20090828 CA 20091130 - I want only this record (Last)
2504 20090622 CA 20090604
2504 20090622 CA 20090721
2504 20090622 CA 20090914
2504 20090622 CA 20091022
2504 20090622 CA 20091117 - I want only this record (Last)
2508 20081102 CA 20090812
2508 20081102 CA 20090910
2508 20091102 CA 20091113 - I want this record also
2508 20081102 CA 20091113 - I want this record (Last)
The FIELD 1 position in the file will start at 6. So I am using the condition
SELECT FROM(INDD1) TO(OUTDD1) ON(6,4,BI) LAST.
I want to include the duplicate records also in the FIELD 4.
Please help me how I can do this.
Thanks
Sreenivas |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Sreenivas,
You need to do a better job of explaining what you want to do. I can't figure out what 6,4,BI corresponds to in the input record examples you showed, or what you mean by "I want to include the duplicate records also in FIELD 4".
What is the starting position, length and format of the field or fields you want to use to determine "duplicates"? By "last" record, do you mean the last one in the input order, or do you want to sort the records in some way and select the last sorted record(s)?
Please show an example that corresponds to your description.
What is the RECFM and LRECL of the input file?
If the "last" n records (e.g. 4) are the same, do you want all of them? Or do you always want only the last 2 even if there are more than 2? |
|
| Back to top |
|
 |
vsrao_2k
New User
Joined: 12 Dec 2005 Posts: 13
|
|
|
|
Hi Frank,
Please find below additional details:
Input and Output files are having same length of 37. Here is copy boook.
| Code: |
01 DCLEMPTABLE.
10 COMPANYV54 PIC S9(4) USAGE COMP.
10 PRODUCTV54 PIC X(3).
10 REFNOV54 PIC S9(9) USAGE COMP.
10 ACTIVFROMV54 PIC S9(9) USAGE COMP.
10 ATRNTYPEV54 PIC X(2).
10 TRANDATEV54 PIC S9(9) USAGE COMP.
10 OTRNTYPEV54 PIC X(2).
10 DOCNOV54 PIC S9(9) USAGE COMP.
10 AMOUNTV54 PIC S9(9)V9(2) USAGE COMP-3.
10 BILLACCTV54 PIC S9(11)V USAGE COMP-3. |
Code'd
The Input file is already SORTED Based on the REFNO. I want to select last occurance of the REFNO. So I have included the condition SELECT FROM(INDD1) TO(OUTDD1) ON(6,4,BI) LAST
I am not able to include below condition:
Condition 1) I want to check TRANDATE for the last record. If last 2 or more records are having same TRANDATE same as last record, I want to keep all those records for each REFNO.
If the "last" n records (e.g. 4) are the same, do you want all of them? Or do you always want only the last 2 even if there are more than 2?
Yes, I want all the records, not one or two. The records that satisfy the condition
TRANDATE of Last record = Trandate of any of previous records(n), I want to keep all the records.
I have mapped my Input file with COPYBOOK
| Code: |
COMPANYV54 PRODUCTV54 REFNOV54 ACTIVFROMV54 ATRNTYPEV54 TRANDATEV54
#2 #3 #4 #5 #6 #7
BI 1:2 AN 3:3 BI 6:4 BI 10:4 AN 14:2 BI 16:4
<---+> <-> <---+----1> <---+----1> <> <---+----1>
1 PAA 1501 20090828 CA 20090928
1 PAA 1501 20090828 CA 20091029
1 PAA 1501 20090828 CA 20091130 (X)
1 PAA 2504 20090622 CA 20090604
1 PAA 2504 20090622 CA 20091022
1 PAA 2504 20090622 CA 20091117 (X)
1 PAA 10505 20071105 CA 20080627
1 PAA 10505 20091105 CA 20091106
1 PAA 10505 20091105 CA 20091113 (X)
1 PAA 10505 20081105 CA 20091113 (X)
1 PAA 11508 20081001 CA 20081103
1 PAA 11508 20081001 CA 20081103
1 PAA 11508 20081001 CA 20081103
1 PAA 11508 20081001 CA 20090203 (X)
1 PAA 11508 20081001 CA 20090203 (X)
1 PAA 11508 20081001 CA 20090203 (X) |
Code'd
I want all the record marked as X in the output file. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT/ICETOOL job that will do what you asked for:
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//IN DD DSN=... input file (FB/37)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/37)
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(6,4,BI) LAST USING(CTL1)
COPY FROM(IN) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(6,4,BI) ON(16,4,BI) WITHALL -
WITH(1,38) USING(CTL3)
/*
//CTL1CNTL DD *
OPTION COPY
INREC OVERLAY=(38:C'BB')
/*
//CTL2CNTL DD *
INREC OVERLAY=(38:C'VV')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(38,2,CH,EQ,C'VB'),
BUILD=(1,37)
/*
|
|
|
| Back to top |
|
 |
vsrao_2k
New User
Joined: 12 Dec 2005 Posts: 13
|
|
|
|
| Thank Frank. I have completed my job and I got results as expected. Thanks you so much for your help and support. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|