View previous topic :: View next topic |
Author |
Message |
newuser Beginner
Joined: 12 Jun 2003 Posts: 16 Topics: 8
|
Posted: Mon Jul 28, 2003 3:00 pm Post subject: Delete x previous records based on condition |
|
|
Hello,
My input file has layout like:
Code: |
Record1AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
1111111111111111111111111111
2222222222222222222222222222
SUMMARYXXXXXXXXXXXXXXXXX
Record2AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
3333333333333333333333333333
5555555555555555555555555555
SUMMARYXXXXXXXXXXXXXXXXX
Record3AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
4444444444444441111111111111
7799999999999999222222222222
SUMMARYXXXXXXXXXXXXXXXXX
|
Here, lets say these are records for 3 transactions, identified by Record1, Record2 and Record3.
As the last record of each of this transaction, there is a SUMMARY record.
The Summary records in actual, includes the SUMMARY line and 2 records above this line (the numeric records in this sample).
I need to conditionally see if the record is SUMMARY line and if so, need to delete the SUMMARY line and 2 records above it.
So my output file will look like:
Code: |
Record1AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
Record2AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
Record3AAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
|
Is there an easy utility solution for this? We have Sort, Fileaid and SAS at our shop.
Regards |
|
Back to top |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Mon Jul 28, 2003 5:09 pm Post subject: |
|
|
Hi New,
You haven't described your problem adequately.
It sounds like you want to delete the SUMMARY recs and any recs containing 111.. 222.. 333.. 444.. or 555..
You did not mention whether 111.. etc can be any chars or that they will always be one or the other of these chars.
An alernative is to tell us if you can uniquely identify Recordx and SUMMARY recs. As an example, is there a "rec type" field in each of the recs; do the "Record x/SUMMARY" recs contain numeric data in a field that the 111../222.. recs don't, or whatever can differentiate them. You get the idea.
Regards, Jack. |
|
Back to top |
|
|
newuser Beginner
Joined: 12 Jun 2003 Posts: 16 Topics: 8
|
Posted: Mon Jul 28, 2003 5:54 pm Post subject: |
|
|
slade,
No...there is no identifiers for the 2 records just above the SUMMARY record..But I will always have SUMMARY as the identifier in the first position of the record for the SUMMARY record...I need to locate this record, and if found, need to delete the SUMMARY record and 2 records just above the SUMMARY record...
And No, the records just above are not numeric...I have included here just for clarity.....I just need to delete the 2 records above the SUMMARY record and the SUMMARY record itself.
Hope this clears my question....Pls advise! |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Wed Jul 30, 2003 7:18 am Post subject: |
|
|
newuser,
I am learning assembler so I wrote a program, DELBLOCK, to serve your purpose. If you want I can send the load module. Once you have the load module you will have to include following step in your job to do the deletions - Code: |
//EXECPGM EXEC PGM=DELBLOCK
//STEPLIB DD DSN=WHERE.U.COPIED.LOAD.PDS,DISP=SHR
//DDIN DD DSN=INPUT.DATASET,DISP=SHR
//DDOUT DD DSN=OUTPUT.DATASET,DISP=SHR |
Regards,
Diba. |
|
Back to top |
|
|
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Wed Jul 30, 2003 3:48 pm Post subject: |
|
|
One way to do this in EZTREVE (may not be the best way)
1.
Read the input file and create two outputs
output 1 -> same as input file with record number at the end of each record
output 2 -> when u get to summary record in the input file -> write 3 records
1st record -> record number of summary record
2nd record -> summary record record number - 1
3rd record -> summary record record number - 2
2.
write a compare program to compare the 2 outputs from above
if matched
don't write
else
write
. |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Jul 30, 2003 4:41 pm Post subject: |
|
|
Well, of course you could do this using DFSORT with an E15 exit that had the appropriate logic. You'd have to save each pair of records in a buffer and tell DFSORT to "delete" them until you could check the third record, and "accept", "insert" or "delete" each current or saved record appropriately. The advantage of using the E15 exit is that you could do it in one copy pass over the data and still have DFSORT do its fast I/O. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
|
|