IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Filter records if trailer count is not matching


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Apr 17, 2009 2:55 am
Reply with quote

I have one file in which
Char 1-3 Indicates record type(00-HEADER,05-DETAIL,09-TRAILER)
In header there is sequence number and in trailer there is record count(including corrosponding header and trailer record)
I want to filter this file if record count in trailer is not matching with actual records present for perticular header-trailer block.
For an example.. for below input file
Code:

0000001
05D1
05D2
05D3
05D4
0900006
0000002
05D5
05D6
05D7
0900005
0000003
05D8
05D9
0900005


Output should be
Code:

0000001
05D1
05D2
05D3
05D4
0900006
0000002
05D5
05D6
05D7
0900005


And Error file should contain
Code:

0000003
05D8
05D9
0900005


As for records with header sequence number=00003 actual record count is 00004 but at trailer (09) it is showing 00005, this block is written in error file and not in actual output file.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Apr 17, 2009 3:39 am
Reply with quote

Sambhaji,

The following DFSORT JCL will give you the desired results.


Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
0000001                                                               
05D1                                                                   
05D2                                                                   
05D3                                                                   
05D4                                                                   
0900006                                                               
0000002                                                               
05D5                                                                   
05D6                                                                   
05D7                                                                   
0900005                                                               
0000003                                                               
05D8                                                                   
05D9                                                                   
0900005                                                               
//OUTPUT   DD SYSOUT=*                                                 
//ERROR    DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(91:1,2)),                           
  IFTHEN=(WHEN=GROUP,BEGIN=(1,2,ZD,EQ,0),PUSH=(81:ID=5,SEQ=5)),       
  IFTHEN=(WHEN=(1,2,ZD,EQ,9),OVERLAY=(91:C'YY',1,80),HIT=NEXT),       
  IFTHEN=(WHEN=(1,2,ZD,EQ,9,AND,86,5,ZD,NE,3,5,ZD),OVERLAY=(91:C'NN'))
  SORT FIELDS=(81,5,CH,A,91,2,CH,A)                                   
                                                                       
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,ZD,EQ,9),PUSH=(91:91,82))       
  OUTFIL FNAMES=OUTPUT,REMOVECC,BUILD=(1,80),                         
  INCLUDE=(91,2,CH,EQ,C'YY',AND,1,2,ZD,NE,9),                         
  SECTIONS=(81,5,TRAILER3=(93,80))                                     
                                                                       
  OUTFIL FNAMES=ERROR,REMOVECC,BUILD=(1,80),                           
  INCLUDE=(91,2,CH,EQ,C'NN',AND,1,2,ZD,NE,9),                         
  SECTIONS=(81,5,TRAILER3=(93,80))                                     
/*
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Apr 17, 2009 4:06 am
Reply with quote

Thanks Kolusu,

It is working exactly as expected. Thanks for the efforts.

I will try to understand logic as I had least worked with WHEN=GROUP and PUSH with ID and SEQ.
If I stuck to any Hedge on this I will PM you
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 17, 2009 4:20 am
Reply with quote

Hello,

Quote:
If I stuck to any Hedge on this I will PM you
It would be better to post any questions back here in your topic.

PMs are for Private dialog, not technical questions. If you need something to be clarified, it is almost positive that someone else does also. By posting the dialog in the topic, more people can benefit from the information icon_smile.gif

Thank you,

d
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Apr 17, 2009 4:33 am
Reply with quote

I agree on that Dick..
I will post it here...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top