View previous topic :: View next topic
|
Author |
Message |
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
Hello,
I have a requirement to skip certain input records based on condition. I am trying to attain the below through any utilities - ICETOOL/SYNCSORT, however, i do not have clear direction on whether it is possible to achieve the below results.
Given below is sample input file: It contains file header,batch header,Detail records, batch trailer, File trailer.
Code: |
1FHEADERCLIENT1
2BHEADERCLIENT1
3DETAIL1CLIENT1
3DETAIL2CLIENT1
3DETAIL3CLIENT1
8BTRAILERCLIENT1
9FTRAILERCLIENT1
1FHEADERCLIENT2
2BHEADERCLIENT2
8BTRAILERCLIENT2
9FTRAILERCLIENT2
1FHEADERCLIENT3
2BHEADERCLIENT3
3DETAIL4CLIENT3
8BTRAILERCLIENT3
9FTRAILERCLIENT3 |
Whenever, there are file-batch records without detail record, i want these records to be skipped. In short, my output should look like:
Code: |
1FHEADERCLIENT1
2BHEADERCLIENT1
3DETAIL1CLIENT1
3DETAIL2CLIENT1
3DETAIL3CLIENT1
8BTRAILERCLIENT1
9FTRAILERCLIENT1
1FHEADERCLIENT3
2BHEADERCLIENT3
3DETAIL4CLIENT3
8BTRAILERCLIENT3
9FTRAILERCLIENT3 |
Please note that Client 2 records are skipped ( including the batch header and file header ), because there are no corresponding detail records.
Would appreciate if you can suggest any way this could be done using utilities, other than through coding a new program. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
WHEN=GROUP for batch header, RECORDS=2 and PUSH the entire header record to an extension of the record.
WHEN=GROUP for detail record, RECORDS=2 and PUSH the detail record ID.
OUTFIL to output the header first when located as an extension of the detail record, then the detail record, using the slash operator (/). Output the batch trailer if marked as containing data records. Out all other records as their original size. |
|
Back to top |
|
|
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
I will test the same, and will let you know the results. Thanks for your response. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Narayanan,
If you know for sure that the file will have one file header, one batch header, one file trailer and one batch trailer for each client, you may try SELECTing each client group having more than 4 records (ie at least one detail record)
Something like this:
Code: |
//STEP01 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//*
//IN DD *
1FHEADERCLIENT1
2BHEADERCLIENT1
3DETAIL1CLIENT1
3DETAIL2CLIENT1
3DETAIL3CLIENT1
8BTRAILERCLIENT1
9FTRAILERCLIENT1
1FHEADERCLIENT2
2BHEADERCLIENT2
8BTRAILERCLIENT2
9FTRAILERCLIENT2
1FHEADERCLIENT3
2BHEADERCLIENT3
3DETAIL4CLIENT3
8BTRAILERCLIENT3
9FTRAILERCLIENT3
//OUT DD SYSOUT=*
//*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(81,8,CH) HIGHER(4) USING(CTL1)
//*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,2,CH,EQ,C'FH'),PUSH=(81:ID=8))
OUTFIL BUILD=(1,80) |
OUT
Code: |
1FHEADERCLIENT1
2BHEADERCLIENT1
3DETAIL1CLIENT1
3DETAIL2CLIENT1
3DETAIL3CLIENT1
8BTRAILERCLIENT1
9FTRAILERCLIENT1
1FHEADERCLIENT3
2BHEADERCLIENT3
3DETAIL4CLIENT3
8BTRAILERCLIENT3
9FTRAILERCLIENT3 |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Hi Arun,
Yes, but I don't see how to do that without JOINKEYS, and without forcing a lot of mismatches, so heavy in processing. Perhaps I'm missing something? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Oops, Sorry Bill I was editing my post and missed yours. I have posted the sample code above. |
|
Back to top |
|
|
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
Works like a charm. Thanks Arun. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
You're welcome, Glad it worked for you |
|
Back to top |
|
|
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
I was looking for documentation on synctool, and i see from forums that synctool doesnt have any documentation as such. May i ask you what does this statement do?
What does ID mean?
I really appreciate your help in this. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Narayanan,
For Synctool there is no official documentation, but you can find a detailed description on the PUSH operator description in your Syncsort manual. If you do not have one you can request one from Syncsort support.
ID=8 means that I am attaching an 8-byte numeric group label, where the BEGINing of each group is marked by the presence of 'FH' at pos-2. The GROUP ID is incremented by 1 for subsequent groups.
After the above INREC statement processing, the records will look something like this:
Code: |
----+----1----+----2....pos 80-> 0----+----+
1FHEADERCLIENT1 00000001
2BHEADERCLIENT1 00000001
3DETAIL1CLIENT1 00000001
3DETAIL2CLIENT1 00000001
3DETAIL3CLIENT1 00000001
8BTRAILERCLIENT1 00000001
9FTRAILERCLIENT1 00000001
1FHEADERCLIENT2 00000002
2BHEADERCLIENT2 00000002
8BTRAILERCLIENT2 00000002
9FTRAILERCLIENT2 00000002
1FHEADERCLIENT3 00000003
2BHEADERCLIENT3 00000003
3DETAIL4CLIENT3 00000003
8BTRAILERCLIENT3 00000003
9FTRAILERCLIENT3 00000003 |
|
|
Back to top |
|
|
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
Thank you once again |
|
Back to top |
|
|
|