Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sorting out doubles and adjusting trailer record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sorting out doubles and adjusting trailer record
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    Post subject: Reply to: Sorting out doubles and adjusting trailer record
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    Post subject: Reply to: Sorting out doubles and adjusting trailer record
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 Moderator


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

PostPosted: Wed Oct 08, 2008 1:29 am    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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    Post subject:
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 Moderator


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

PostPosted: Wed Oct 08, 2008 1:35 am    Post subject:
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    Post subject:
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    Post subject: Reply to: Sorting out doubles and adjusting trailer record
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 Moderator


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

PostPosted: Wed Oct 08, 2008 8:40 pm    Post subject:
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    Post subject: Reply to: Sorting out doubles and adjusting trailer record
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 Moderator


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

PostPosted: Thu Oct 09, 2008 4:00 am    Post subject:
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    Post subject:
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    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 Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Sorting on text - but in non-alphabet... Roy Ware SYNCSORT 5 Wed Aug 23, 2017 9:15 pm
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us