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

Editing trailer record in my input file


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

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Thu Oct 04, 2007 11:30 am
Reply with quote

Hi All,

I have a requirement to eliminate duplicate records from a flat file, I know it can be done by giving SUM FIELDS = NONE in a sort job, but in my case I have a header record and a trailer record in my input file, and the trailer record consists of the number of records present in the file , pls find the sample file below

004102007 PGM1
1record1
1record2
1record3
904102007 03

The above would be my data inside my file and the trailer record as specified contains the number of records in the file, I have to remove the duplicate in my file but also modify the number of records in my trailer record accordingly, I don;t want to use a COBOL pgm for the sam e , can it be done by SORT, If so please share the sort card. Thanks in advance


Thamilzan.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 11:41 am
Reply with quote

Thamilzan,

How do you recognize Header & Trailer records? Are they going to be constant across runs (leaving record count).
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 11:42 am
Reply with quote

Also, post your file attribs along with sort key details.
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Thu Oct 04, 2007 3:22 pm
Reply with quote

Hi Murali,

The header record would be identified by '0' in the first byte and the data record would be havin '1' in the 1st byte and the trailer record would be havin '9' in the 1 st byte, the DCB parameters are 80 lrecl and 800 blk and FB format, the header record and trailer record remains constant


Thamilzan.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 4:17 pm
Reply with quote

Prav,

Code:

//STEP1     EXEC PGM=SORT             
//SYSPRINT DD SYSOUT=*               
//SYSOUT DD SYSOUT=*                 
//SORTIN DD *                         
004102007 PGM1                       
1RECORD1                             
1RECORD3                             
1RECORD1                             
1RECORD2                             
1RECORD3                             
1RECORD2                             
1RECORD4                             
904102007 07                         
/*                                   
//SORTOUT DD SYSOUT=*                 
//SYSIN DD *                         
  INCLUDE COND=(1,1,CH,EQ,C'1')       
  SORT FIELDS=(2,7,CH,A)             
  SUM FIELDS=NONE                     
  OUTFIL REMOVECC,                   
     HEADER1=(C'004102007 PGM1'),     
     TRAILER1=(C'904102007 ',COUNT=(EDIT=(TT)))         
/*                                                     


OP:
Code:
004102007 PGM1     
1RECORD1           
1RECORD2           
1RECORD3           
1RECORD4           
904102007 04       



I had assume key is between 2 to 8 columns (lenght 7). Change according to your key positions. Also, as per your quote -

Quote:
the header record and trailer record remains constant
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Oct 04, 2007 4:19 pm
Reply with quote

prav_06

Code:
904102007 03

In the trailer record, the data following the trailer indicator looks like date, is that the run date?
Quote:
I have a requirement to eliminate duplicate records from a flat file

Eliminate based on what key position? is that based on entire record ?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 4:26 pm
Reply with quote

KirsPrems,

Quote:
In the trailer record, the data following the trailer indicator looks like date, is that the run date?


Even the header has the same value. Since Parv said the HEADER and TRAILER remains constant......
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Thu Oct 04, 2007 4:43 pm
Reply with quote

Hi Murali,

Thanks a lot for the solution.


Thamilzan.
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Fri Oct 05, 2007 7:20 pm
Reply with quote

Hi,
Say if the header record is not constand and would vary for each run how the above JCL can be modified. Thanks in Advance.


Thamilzan.
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: Fri Oct 05, 2007 9:30 pm
Reply with quote

Thamilzan,

Here's a DFSORT job that will handle varying header and trailer records. It creates DFSORT Symbols for the header and trailer information and then uses those Symbols in HEADER1 and TRAILER1.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OMIT COND=(1,1,CH,EQ,C'1')   
  INREC IFOUTLEN=80,
    IFTHEN=(WHEN=(1,1,CH,EQ,C'0'),
      BUILD=(C'Hdr,''',1,20,C'''',80:X)),
    IFTHEN=(WHEN=NONE,
      BUILD=(C'Trl,''',1,10,C'''',80:X))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INCLUDE COND=(1,1,CH,EQ,C'1')
  SORT FIELDS=(2,7,CH,A)
  SUM FIELDS=NONE
  OUTFIL REMOVECC,
    HEADER1=(Hdr),
    TRAILER1=(Trl,COUNT=(EDIT=(TT)))
/*
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Tue Oct 09, 2007 6:56 pm
Reply with quote

Hi Frank,

I got the JCL but as per my requirements (Which changes Often!!!!!), I need to add 2 to my record count at my trailer record, say if there are 5 data records , the downstream PGM expects the record count as 7 (5 data recs and 1 header and 1 trailer record), could you please suggest how this can be done. Thanks in advance.

Thamilzan.
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 Oct 09, 2007 8:44 pm
Reply with quote

Just change the last line to:

Code:

  TRAILER1=(Trl,COUNT+2=(EDIT=(TT)))


COUNT+2 will add +2 to the count of data records.
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 15, 2010 11:15 pm
Reply with quote

With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct, 2010), you can now use DFSORT's new IFTRAIL function to do this more easily like this:

Code:

//NEW EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  SORT FIELDS=(1,8,CH,A)
  SUM FIELDS=NONE
  OUTFIL IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'9'),
    TRLUPD=(11:COUNT+2=(EDIT=(TT))))
/*


For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top