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

Sorting out doubles and adjusting trailer record


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

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Wed Oct 08, 2008 12:07 am
Reply with quote

A file looks like this

020081003ABB --> header record
1KLBB456TY
1KLAA787NN
1KLBB456TY
9000005 --> trailer record

The records starting with 1 are daterecords. The doubles should be sorted out and the number '000005' in the trailer record should be adjusted. So after the sort the file looks like this

020081003ABB --> header record
1KLBB456TY
1KLAA787NN
9000004 --> trailer record

How do I handle that?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Oct 08, 2008 1:12 am
Reply with quote

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                       
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD *                                 
020081003ABB             
1KLBB456TY                                       
1KLAA787NN                                       
1KLBB456TY                                       
9000005                       
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                 
  OPTION EQUALS                                 
  SORT FIELDS=(1,10,CH,A)                       
  SUM FIELDS=NONE                               
  OUTREC IFOUTLEN=80,                           
    IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,6,ZD)),   
    IFTHEN=(WHEN=(1,1,ZD,EQ,9),OVERLAY=(2:81,6))   
/*
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Wed Oct 08, 2008 1:22 am
Reply with quote

could you please explain in detail what this does?

Code:

  OUTREC IFOUTLEN=80,                           
    IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,6,ZD)),   
    IFTHEN=(WHEN=(1,1,ZD,EQ,9),OVERLAY=(2:81,6))
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 Oct 08, 2008 1:29 am
Reply with quote

Here's another way to do it with the DATASORT operator of DFSORT's ICETOOL, available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008):

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,10,CH,A)
  SUM FIELDS=NONE
  OUTFIL FNAMES=OUT,OMIT=(1,1,CH,EQ,C'9'),
    TRAILER1=(C'9',COUNT+1=(M11,LENGTH=6))
/*


For complete details on the new FINDREP function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Oct 08, 2008 1:34 am
Reply with quote

OUTREC IFOUTLEN=80, <<< preserves the original input file lrecl
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,6,ZD)), <<< writes as 6 byte seqnum at pos 81 which acts like record counter after sort has eliminated the duplicate records
IFTHEN=(WHEN=(1,1,ZD,EQ,9),OVERLAY=(2:81,6)) <<< if it is trailer record, overlay the record counter value at pos 81 on to pos 2
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 Oct 08, 2008 1:35 am
Reply with quote

Quote:
could you please explain in detail what this does?

Code:

OUTREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,6,ZD)),
IFTHEN=(WHEN=(1,1,ZD,EQ,9),OVERLAY=(2:81,6))


It adds a 6-byte sequence number after the end of each sorted/summed record ('000001', '000002', etc). The sequence number in the last record (trailer record) will be equal to the count of output records (e.g. if there's a header record, two detail records and a trailer record, the trailer record will have a sequence number of '000004'). The last sequence number = count is overlayed into the trailer ('9') record. IFOUTLEN=80 sets the length of the output records to 80.
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Wed Oct 08, 2008 1:38 am
Reply with quote

thanks for the examples and explanation
all the examples use iceman and icetool
whta possibilities they have
I am working in a bank. We are using the old DFSORT I believe
Tomorrow I will have a look, try out and let you know
thanks
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Wed Oct 08, 2008 2:20 pm
Reply with quote

it works
thanx
one more question
whta if i want to write the doubles to another file to keep them?
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 Oct 08, 2008 8:40 pm
Reply with quote

Do you mean you want the records eliminated by SUM in a different output file? Or do you mean something else? For your original example, would you just want the other output file to have the second 1KLBB456TY record, or would you want it to have something else? If something else, what?
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Thu Oct 09, 2008 3:21 am
Reply with quote

yes you are right
I want the records eliminated by SUM in a different output file. So for the original example, I want the other output file to have the second 1KLBB456TY record
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: Thu Oct 09, 2008 4:00 am
Reply with quote

Here's a DFSORT/ICETOOL job for your new requirement:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//TOOLIN DD *
SELECT FROM(IN) TO(OUT1) ON(1,1,CH) ON(1,10,CH) FIRST -
  DISCARD(OUT2) USING(CTL1)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=OUT1,OMIT=(1,1,CH,EQ,C'9'),
    TRAILER1=(C'9',COUNT+1=(M11,LENGTH=6))
/*
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Thu Oct 09, 2008 2:21 pm
Reply with quote

Frank, you are great
thanx
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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top