Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

skip records while processing but write in o/p

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
utkarshtewari

New User


Joined: 26 Mar 2007
Posts: 9
Location: UK

PostPosted: Fri May 25, 2012 4:25 pm    Post subject: skip records while processing but write in o/p
Reply with quote

Hi,
I have a report starting with first two lines of header and these headers appear after page breaks.
I had to read data from this file and process. I want to keep the first set of headers and copy as it is in the output file but want
to get rid of other headers. How can we do it using sort?

input
----------
1HEADER LINE 1 RUN DATE
HEADER LINE 2
122345576777777777
8888
888888888
99999999
00000987GFFFDSD
456GTREYEYTYEWY
1HEADER LINE 1 RUN DATE
HEADER LINE 2
sdhjlkqkjqdwklwqDSAJDSSDss
SHyuiu q ewdsa
sdsasdsDAfiqeqwoeq
sahjsdakjsadjdjd

Output
-------------
1HEADER LINE 1 RUN DATE
HEADER LINE 2
122345576777777777
8888
888888888
99999999
00000987GFFFDSD
456GTREYEYTYEWY
sdhjlkqkjqdwklwqDSAJDSSDss
SHyuiu q ewdsa
sdsasdsDAfiqeqwoeq
sahjsdakjsadjdjd

Thanks.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri May 25, 2012 4:47 pm    Post subject: Reply to: skip records while processing but write in o/p
Reply with quote

Add a sequence number in the Sort, OMIT heading lines if sequence number greater than two, loose the sequence number (BUILD for instance) before final output.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Fri May 25, 2012 4:56 pm    Post subject:
Reply with quote

Code:
//SRTJK EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
1HEADER LINE 1 RUN DATE
HEADER LINE 2
122345576777777777
8888
888888888
99999999
00000987GFFFDSD
456GTREYEYTYEWY
1HEADER LINE 1 RUN DATE
HEADER LINE 2
SDHJLKQKJQDWKLWQDSAJDSSDSS
SHYUIU Q EWDSA
SDSASDSDAFIQEQWOEQ
SAHJSDAKJSADJDJD
//SYSOUT DD SYSOUT=*
//T2     DD SYSOUT=*
//T1 DD DSN=&&T1,SPACE=(TRK,(5,5)),
//  DISP=(MOD,PASS)
//TOOLIN   DD *
  COPY FROM(IN1) TO(T1) USING(CTL1)
  COPY FROM(T1) TO(T2) USING(CTL2)
//*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=(2,14,CH,EQ,C'HEADER LINE 1'),
          BUILD=(1:1,80,81:SEQNUM,4,ZD)),
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 2'),
          BUILD=(1:1,80,81:SEQNUM,4,ZD))
//CTL2CNTL DD *
  OMIT COND=(81,4,ZD,GT,1)
  OUTREC FIELDS=(1,80)


Output
Code:
1HEADER LINE 1 RUN DATE
HEADER LINE 2
122345576777777777
8888
888888888
99999999
00000987GFFFDSD
456GTREYEYTYEWY
SDHJLKQKJQDWKLWQDSAJDSSDSS
SHYUIU Q EWDSA
SDSASDSDAFIQEQWOEQ
SAHJSDAKJSADJDJD
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri May 25, 2012 5:07 pm    Post subject:
Reply with quote

what if there are 3 headers?

suggested control cards (check syntax, probably not correct) based on Bill's solution
UNTESTED
INREC BUILD=(1:1,80,81:SEQNUM,6,ZD)
OUTREC/OUTFIL OMIT=((2,11,CH,EQ,C'HEADER LINE') AND (81,6,ZD,GT,2)),FIELDS=(1,80)


one pass
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Fri May 25, 2012 5:14 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
what if there are 3 headers?

suggested control cards (check syntax, probably not correct) based on Bill's solution
UNTESTED
INREC BUILD=(1:1,80,81:SEQNUM,6,ZD)
OUTREC/OUTFIL OMIT=((2,11,CH,EQ,C'HEADER LINE') AND (81,6,ZD,GT,2)),FIELDS=(1,80)


one pass



Even if there are 5 headers the CTL1 one should be modified like
Code:

//TOOLIN   DD *
  COPY FROM(IN1) TO(T1) USING(CTL1)
  COPY FROM(T1) TO(T2) USING(CTL2)
//*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=(2,14,CH,EQ,C'HEADER LINE 1'),
          BUILD=(1:1,80,81:SEQNUM,4,ZD)),
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 2'),
          BUILD=(1:1,80,81:SEQNUM,4,ZD))
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 3'),
          BUILD=(1:1,80,81:SEQNUM,4,ZD))
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 4'),
          BUILD=(1:1,80,81:SEQNUM,4,ZD))
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 5'),
          BUILD=(1:1,80,81:SEQNUM,4,ZD))
//CTL2CNTL DD *
  OMIT COND=(81,4,ZD,GT,1)
  OUTREC FIELDS=(1,80)


This solution should work not sure about efficiency icon_sad.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri May 25, 2012 5:36 pm    Post subject:
Reply with quote

Pandora-box, it can all be done in one pass. Use OVERLAY for the sequence, no need to BUILD all the time. Just edited from yours, untested.

Code:
  OPTION COPY
  INREC IFTHEN=(WHEN=(2,14,CH,EQ,C'HEADER LINE 1'),
          OVERLAY=(81:SEQNUM,4,ZD)),
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 2'),
          OVERLAY=(81:SEQNUM,4,ZD)),
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 3'),
          OVERLAY=(81:SEQNUM,4,ZD)),
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 4'),
          OVERLAY=(81:SEQNUM,4,ZD)),
        IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 5'),
          OVERLAY=(81:SEQNUM,4,ZD))
  OMIT COND=(81,4,CH,GT,C'0001')
  OUTREC FIELDS=(1,80)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri May 25, 2012 5:43 pm    Post subject:
Reply with quote

does not OMIT/INCLUDE STATEMENT (which means it is not part of INREC or OUTREC/OUTFIL)
apply before the INREC?

whereas the OMIT/INCLUDE parameters of the INREC/OUTREC/OUTFIL statement apply to the data in the current sort phase.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Fri May 25, 2012 6:06 pm    Post subject:
Reply with quote

Thanks Bill and I have modified your advice slightly

One pass

Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(2,14,CH,EQ,C'HEADER LINE 1'),
        OVERLAY=(81:SEQNUM,4,ZD)),
      IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 2'),
        OVERLAY=(81:SEQNUM,4,ZD)),
      IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 3'),
        OVERLAY=(81:SEQNUM,4,ZD)),
      IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 4'),
        OVERLAY=(81:SEQNUM,4,ZD)),
      IFTHEN=(WHEN=(1,13,CH,EQ,C'HEADER LINE 5'),
        OVERLAY=(81:SEQNUM,4,ZD))
OUTFIL OMIT=(81,4,CH,GT,C'0001'),BUILD=(1,80)
Back to top
View user's profile Send private message
utkarshtewari

New User


Joined: 26 Mar 2007
Posts: 9
Location: UK

PostPosted: Fri May 25, 2012 8:54 pm    Post subject:
Reply with quote

Thanks everyone...
This was a part of bigger piece but by building up over your inputs i have found a solution.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri May 25, 2012 9:46 pm    Post subject: Reply to: skip records while processing but write in o/p
Reply with quote

utkarshtewari,

Using WHEN=GROUP with RECORDS=n will be much easier to tag the header records and eliminate them. You don't have to validate each and every header record. You just need to identify the first header record and change the value of N in RECORD=n parameter to tag them. In your sample you showed 2 headers. So use RECORDS=2.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                           
1HEADER LINE 1 RUN DATE                                   
HEADER LINE 2                                             
122345576777777777                                         
8888                                                       
888888888                                                 
99999999                                                   
00000987GFFFDSD                                           
456GTREYEYTYEWY                                           
1HEADER LINE 1 RUN DATE                                   
HEADER LINE 2                                             
SDHJLKQKJQDWKLWQDSAJDSSDSS                                 
SHYUIU Q EWDSA                                             
SDSASDSDAFIQEQWOEQ                                         
SAHJSDAKJSADJDJD                                           
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,7,CH,EQ,C'1HEADER'),   
                RECORDS=2,PUSH=(81:ID=5))                 
  OUTFIL BUILD=(1,80),OMIT=(81,5,ZD,GT,1)                 
//*


will produce
Code:

1HEADER LINE 1 RUN DATE       
HEADER LINE 2                 
122345576777777777           
8888                         
888888888                     
99999999                     
00000987GFFFDSD               
456GTREYEYTYEWY               
SDHJLKQKJQDWKLWQDSAJDSSDSS   
SHYUIU Q EWDSA               
SDSASDSDAFIQEQWOEQ           
SAHJSDAKJSADJDJD             
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Run stats processing on zIIP Engine Virendra Shambharkar DB2 9 Fri Oct 14, 2016 10:24 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us