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

Problem getting required output


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

New User


Joined: 14 Dec 2006
Posts: 6
Location: Ohio

PostPosted: Tue Dec 11, 2007 12:43 am
Reply with quote

I am posting this here to see if I may get some help on my issue.

I have an input file that is 920 bytes.

There are four(4) record types (E05, E06, E07, and E10) within the file. The record type is in pos 61,3.

Each record also has a Member id at position 323,15.

For record types E05 and E06, I want to eliminate duplicates based on the Member ID and Record Type fields only.

For record type E07, an additional Date field is in position 397,8. For this record type, I want to eliminate duplicates as the other record types with the added requirement to keep the record with the most recent Date.

Record type E10 will be eliminated with this process. This is OK.

A final sort orders the file by Member ID, Record Type and also reorganizes the record to move Member ID and Record Type to the beginning of the record.

Below are my sort cards.

Code:
//*INPUT FILE                                           
//INFIL1    DD DSN=WTSO.INPUT.FILE,
//                DISP=SHR         
//*                                                     
//*TEMP FILE                                           
//TEMPDD    DD DSN=&TEMPDD,                             
//             DISP=(NEW,PASS),                         
//             SPACE=(CYL,(100,100),RLSE)               
//*                                                     
//*OUTPUT FILE                                         
//OUTFL1    DD DSN=WTSO.OUTPUT.FILE,                 
//             DISP=(NEW,CATLG,DELETE),                 
//             DCB=(RECFM=FB,LRECL=920,BLKSIZE=0),     
//             UNIT=SYSDA,SPACE=(CYL,(100,100),RLSE),   
//             VOL=SER=                                 
//*                                                     
//TOOLIN    DD *                                       
* SELECT 'E05' TYPE RECORDS AND PUT IN TEMP FILE       
  SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST - 
     USING(SRT1)           
*                           
* SELECT 'E06' TYPE RECORDS AND PUT IN TEMP FILE       
  SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
     USING(SRT2)                                       
*
* SELECT 'E07' TYPE RECORDS AND PUT IN TEMP FILE       
  SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
     USING(SRT3)     
*                                 
* SORT TEMP FILE AND PUT IN OUTPUT FILE               
  COPY FROM(TEMPDD) TO(OUTFL1) USING(SRT4)             
/*                                                     
//SRT1CNTL DD *                                       
* WRITE MATCHING RECORDS(E05) TO TEMP FILE 1           
  SORT FIELDS=(61,3,CH,A,323,15,CH,A)                 
  OUTFIL FNAMES=TEMPDD,INCLUDE=(61,3,CH,EQ,C'E05')     
/*                                                     
//SRT2CNTL DD *                                       
* WRITE MATCHING RECORDS(E06) TO TEMP FILE 2           
  SORT FIELDS=(61,3,CH,A,323,15,CH,A)                 
  OUTFIL FNAMES=TEMPDD,INCLUDE=(61,3,CH,EQ,C'E06')     
/*                                                     
//SRT3CNTL DD *                                   
* WRITE MATCHING RECORDS(E07) TO TEMP FILE 3       
  SORT FIELDS=(61,3,CH,A,323,15,CH,A,397,8,BI,D)   
  OUTFIL FNAMES=TEMPDD,INCLUDE=(61,3,CH,EQ,C'E07')
/*                                                 
//SRT4CNTL DD *                                   
* SORT FINAL OUTPUT FILE                           
  SORT FIELDS=(323,15,CH,A,61,3,CH,A)             
  OUTREC FIELDS=(323,15,                           
                 61,3,                             
                 1,60,                             
                 64,256,                           
                 320,3,                           
                 338,256,                         
                 594,256,                         
                 850,71)                           
/*                                                 
//*                                               


For my output, I am only getting type E07 records. The output appears correct for the record type, however I need all record types in the output. I can't put my finger on where my problem is.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Dec 11, 2007 12:52 am
Reply with quote

leedtech wrote:
I can't put my finger on where my problem is.


I don't see DISP=MOD on TEMPDD. Don't you open, write, and close it several times during this one step with each SELECT statement you call?
Back to top
View user's profile Send private message
leedtech

New User


Joined: 14 Dec 2006
Posts: 6
Location: Ohio

PostPosted: Tue Dec 11, 2007 1:05 am
Reply with quote

Thank you very much for the quick reply.

Your suggestion seems to have fixed my issue.

Thank you.
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: Tue Dec 11, 2007 1:57 am
Reply with quote

Your job is not very efficient. For one thing, you should use an INCLUDE statement to keep only the records you need for the SELECT to reduce the number of records that are sorted. An INCLUDE statement removes records before sorting, whereas an INCLUDE operand of OUTFIL doesn't remove the records until after sorting.

It looks like you could replace the first two SELECT operators with one SELECT operator, e.g.

Code:

  SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST - 
     USING(SRT1)     
  SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
     USING(SRT3)     
  SORT FROM(TEMPDD) TO(OUTFL1) USING(SRT4)   
/*
//SRT1CNTL DD *
  INCLUDE COND=(61,3,SS,EQ,C'E05,E06')   
  SORT FIELDS=(61,3,CH,A,323,15,CH,A)                 
...


You may even be able to replace the first three SELECT operators with one SELECT operator, but it depends on whether sorting on the third field would make any difference for 'E05' and 'E06' - it might make a difference but I can't tell since you haven't shown your input and output records:

Code:

  SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST - 
     USING(SRT1) 
  SORT FROM(TEMPDD) TO(OUTFL1) USING(SRT4)   
/*
//SRT1CNTL DD *
  INCLUDE COND=(61,3,SS,EQ,C'E05,E06,E07')   
  SORT FIELDS=(61,3,CH,A,323,15,CH,A,397,8,BI,D)   
...


Although it's probably not likely, you may be able to eliminate the extra SORT operator as well, but again I can't tell since you haven't shown your input and output records.
Back to top
View user's profile Send private message
leedtech

New User


Joined: 14 Dec 2006
Posts: 6
Location: Ohio

PostPosted: Tue Dec 11, 2007 3:48 am
Reply with quote

Frank,

I do see where combining the first 2 sorts will make the sort more efficient.

I wasn't aware of the implications of using INCLUDE in the manner I did. I have modified the sort accordingly to put the INCLUDE before the sort.

I will also look into the impact of including the 3rd sort field with the other record types to see if this can be simplified further as per your recommendation. Each record type has a different layout and the Member Id and record type are the only common fields (for my purposes).

Thank you for your time.
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
Search our Forums:

Back to Top