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
 

 

Eliminate records based on flag priority

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

New User


Joined: 05 Oct 2006
Posts: 2

PostPosted: Tue May 19, 2009 8:29 pm    Post subject: Eliminate records based on flag priority
Reply with quote

Hi,
Good Morning,

I request help in achieving the below requirement:

Input file:
Code:

CASEID   FLAG       NAME
(Char4)  (Char1)   (Char5)

ABCD      'C'      <blank> 
ABCD      'S'      <blank>
ABCD      'S'      <blank>   
ABCD      ' '       NAME1
ABCD      ' '       NAME2
EFGH      'C'      <blank>
EFGH      'C'      <blank>
EFGH      'S'      <blank>
EFGH      'S'      <blank>
EFGH      'S'      <blank>
IJKL      'C'      <blank>
IJKL      ' '       NAME3
IJKL      ' '       NAME4
IJKL      ' '       NAME5
MNOP      'S'      <blank> 
MNOP      'S'      <blank> 
MNOP      ' '       NAME6
QRST      'C'      <blank>
QRST      'C'      <blank>
UVWX      'S'      <blank>
UVWX      'S'      <blank>
UVWX      'S'      <blank>
YZYZ      ' '       NAME7
YZYZ      ' '       NAME8



Now, based on the flag, it should eliminate records belonging to a CaseID
with priority in order of ' ' (space) > 'S' > 'C'
i.e. say if two records with 'S' and ' ' are present for a CASEID, the output
should contain all the record(s) with ' ' flag
or say if 'C' and 'S' flag types of records are present for a CASEID, the output should contain all the record(s) with 'S' flag

The expected output for above example file is given below:

Code:

CASEID   FLAG       NAME
(Char4)  (Char1)   (Char5)
ABCD      ' '       NAME1
ABCD      ' '       NAME2
EFGH      'S'      <blank>
EFGH      'S'      <blank>
EFGH      'S'      <blank>
IJKL      ' '       NAME3
IJKL      ' '       NAME4
IJKL      ' '       NAME5
MNOP      ' '       NAME6
QRST      'C'      <blank>
QRST      'C'      <blank>
UVWX      'S'      <blank>
UVWX      'S'      <blank>
UVWX      'S'      <blank>
YZYZ      ' '       NAME7
YZYZ      ' '       NAME8



Could you please suggest a solution. COBOL solution doesn't look feasible to me, so ICETOOL is the only option I can think of.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue May 19, 2009 9:04 pm    Post subject:
Reply with quote

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD *
ABCDC
ABCDS
ABCDS
ABCD NAME1
ABCD NAME2
EFGHC
EFGHC
EFGHS
EFGHS
EFGHS
IJKLC
IJKL NAME3
IJKL NAME4
IJKL NAME5
MNOPS
MNOPS
MNOP NAME6
QRSTC
QRSTC
UVWXS
UVWXS
UVWXS
YZYZ NAME7
YZYZ NAME8
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
COPY FROM(IN) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,4,CH) ON(5,1,CH) WITHALL -
  WITH(1,81) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:5,1,
     CHANGE=(1,C' ',C'1',C'S',C'2'),NOMATCH=(C'3'))
  OPTION EQUALS
  SORT FIELDS=(1,4,CH,A,81,1,CH,A)
  OUTREC OVERLAY=(81:C'BB',83:SEQNUM,8,ZD,RESTART=(1,4))
  OUTFIL FNAMES=T1,INCLUDE=(83,8,ZD,EQ,1),BUILD=(1,82)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(81,2,CH,EQ,C'VB'),
    BUILD=(1,80)
/*


OUT would have:

Code:

ABCD NAME1       
ABCD NAME2       
EFGHS             
EFGHS             
EFGHS             
IJKL NAME3       
IJKL NAME4       
IJKL NAME5       
MNOP NAME6       
QRSTC             
QRSTC             
UVWXS             
UVWXS             
UVWXS             
YZYZ NAME7       
YZYZ NAME8       
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue May 19, 2009 10:17 pm    Post subject: Reply to: Eliminate records based on flag priority
Reply with quote

yespatel,

The following DFSORT JCL will give you the desired results. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//STEP0100 EXEC PGM=SOR
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *       
ABCDC                 
ABCDS                 
ABCDS                 
ABCD NAME1             
ABCD NAME2             
EFGHC                 
EFGHC                 
EFGHS                 
EFGHS                 
EFGHS                 
IJKLC                 
IJKL NAME3             
IJKL NAME4             
IJKL NAME5             
MNOPS                 
MNOPS                 
MNOP NAME6             
QRSTC                 
QRSTC                 
UVWXS                 
UVWXS                 
UVWXS                 
YZYZ NAME7             
YZYZ NAME8             
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=(5,1,CH,EQ,C' '),OVERLAY=(81:C'1')),             
        IFTHEN=(WHEN=(5,1,CH,EQ,C'S'),OVERLAY=(81:C'2')),             
        IFTHEN=(WHEN=(5,1,CH,EQ,C'C'),OVERLAY=(81:C'3'))               
                                                                       
  SORT FIELDS=(1,4,CH,A,81,1,CH,A),EQUALS                             
                                                                       
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(82:5,1,SEQNUM,8,ZD,RESTART=(1,4))),
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(81:81,1))             
                                                                       
  OUTFIL INCLUDE=(81,2,SS,EQ,C'1 ,2S,3C'),BUILD=(1,80)                 
/*                                                                     
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue May 19, 2009 10:40 pm    Post subject:
Reply with quote

Kolusu,

Clever solution! icon_cool.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue May 19, 2009 11:40 pm    Post subject:
Reply with quote

Hello,

Quote:
COBOL solution doesn't look feasible to me,
FWIW, the cobol solution is rather trivial - basically the same as Skolusu posted. . .

Create a new sort key for the " ", C, and S (i.e. 1, 2, 3) and internally sort the file by case and the new key, then only write the records that contain the highest "priority" for that case to the output file.
Back to top
View user's profile Send private message
yespatel

New User


Joined: 05 Oct 2006
Posts: 2

PostPosted: Wed May 20, 2009 10:31 am    Post subject: Eliminate records based on flag priority
Reply with quote

Hi all,

Genius stuffs,

Thank you very much for your help, Frank, Kolusu, Dick..

All solutions equally brillient, can use any of them

Cheers,

yespatel
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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


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