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

Sort out the unique fields


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

New User


Joined: 06 Jan 2008
Posts: 11
Location: India

PostPosted: Mon Nov 16, 2009 4:28 pm
Reply with quote

Hi..
My input file is of Lrecl 11 and its in the below format:
My key field is 1-9 bytes.

111111111__
111111111__
111111111CR
111111112HR
111111112CR
111111112BR
111111113__
111111113__
111111113__

My output file should be lik the below:

111111111CR
111111112HR
111111112CAR
111111112BAR
111111113__

if Pos10-11 is having values (for the same key) i should write that to the output file (See: 111111112). If Pos10-11 is having all blanks then output only one key with a blank (see:111111113) if pos10-11 is having spaces as well as values, then output the key only with the values (See:111111111)

Can someone help me in this?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Nov 16, 2009 11:59 pm
Reply with quote

Where did the CAR and BAR output records come from? They aren't in the input file (the input file does have CR and BR records).

What is the RECFM and LRECL of the input file?

Quote:
if pos10-11 is having spaces as well as values, then output the key only with the values (See:111111111)


Can you have input records like this:

111111114__
111111114__
111111114CR
111111114CR
111111114HR

If so, what would you expect as output for these input records?

If there are blank records, are they always before the non-blank records, or can the blank records be anywhere? For example, would this be possible:

111111115__
111111115HR
111111115__
Back to top
View user's profile Send private message
Deepa Natarajan

New User


Joined: 06 Jan 2008
Posts: 11
Location: India

PostPosted: Tue Nov 17, 2009 9:11 am
Reply with quote

Sorry for d typo!
there is no CAR and BAR records. tat shud be CR and BR only.

if my input file is like below:
111111114__
111111114__
111111114CR
111111114CR
111111114HR

My output shud be:

111111114CR
111111114CR
111111114HR

if there r blank values and a value, remove the blank values.

Yes, the blank records can occur anywhere.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Nov 18, 2009 2:26 am
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for based on the examples you gave and your explanations:

Code:

 //S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//IN DD DSN=...  input file (FB/11)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/11)
//TOOLIN   DD    *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(12:SEQNUM,8,ZD)
  SORT FIELDS=(1,9,CH,A,10,2,CH,D)
  OUTREC OVERLAY=(20:SEQNUM,8,ZD,RESTART=(1,9))
  OUTFIL FNAMES=T1,OMIT=(10,2,CH,EQ,C' ',AND,20,8,ZD,GT,1)
/*
//CTL2CNTL DD *
  SORT FIELDS=(12,8,ZD,A)
  OUTREC BUILD=(1,11)
/*


I used these input records for SORTIN:

Code:

111111111         
111111111         
111111111CR       
111111112HR       
111111112CR       
111111112BR       
111111113         
111111113         
111111113         
111111114         
111111114         
111111114CR       
111111114CR       
111111114HR       
111111115         
111111115HR       
111111115         


and got these output records for SORTOUT:

Code:

111111111CR   
111111112HR   
111111112CR   
111111112BR   
111111113     
111111114CR   
111111114CR   
111111114HR   
111111115HR   
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Nov 18, 2009 3:53 am
Reply with quote

Deepa Natarajan,

Here is another way of doing it
Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DSN=Your 11 byte FB input file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,11,C'0')),                 
  IFTHEN=(WHEN=(10,2,CH,EQ,C' '),OVERLAY=(12:C'1'))           
  SORT FIELDS=(1,9,CH,A,12,1,CH,A),EQUALS                     
  OUTREC OVERLAY=(13:SEQNUM,8,ZD,RESTART=(1,9))               
  OUTFIL OMIT=(12,1,ZD,EQ,1,AND,13,8,ZD,GT,1),BUILD=(1,11)   
//*
Back to top
View user's profile Send private message
Deepa Natarajan

New User


Joined: 06 Jan 2008
Posts: 11
Location: India

PostPosted: Wed Nov 18, 2009 9:16 am
Reply with quote

Thanks for your help, franker n kolusu!
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top