Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Editing trailer record in my input file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
Author Message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 139
Location: Mumbai

PostPosted: Thu Oct 04, 2007 11:30 am    Post subject: Editing trailer record in my input file
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
References
PostPosted: Thu Oct 04, 2007 11:30 am    Post subject: Re: Editing trailer record in my input file Reply with quote

murmohk1

Senior Member


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

PostPosted: Thu Oct 04, 2007 11:41 am    Post subject: Reply to: Editing trailer record
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: 1485
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 11:42 am    Post subject:
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: 139
Location: Mumbai

PostPosted: Thu Oct 04, 2007 3:22 pm    Post subject:
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: 1485
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 4:17 pm    Post subject:
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

Senior Member


Joined: 27 Nov 2006
Posts: 627
Location: India

PostPosted: Thu Oct 04, 2007 4:19 pm    Post subject:
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: 1485
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 4:26 pm    Post subject:
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: 139
Location: Mumbai

PostPosted: Thu Oct 04, 2007 4:43 pm    Post subject:
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: 139
Location: Mumbai

PostPosted: Fri Oct 05, 2007 7:20 pm    Post subject:
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 Moderator


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

PostPosted: Fri Oct 05, 2007 9:30 pm    Post subject:
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: 139
Location: Mumbai

PostPosted: Tue Oct 09, 2007 6:56 pm    Post subject:
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 Moderator


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

PostPosted: Tue Oct 09, 2007 8:44 pm    Post subject:
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
Moved: Tue Oct 09, 2007 8:46 pm by superk From DFSORT/ICETOOL to JCL
ajay_diaz
Warnings : 1

New User


Joined: 12 Sep 2005
Posts: 22

PostPosted: Wed Mar 26, 2008 10:11 am    Post subject: Count and total at a particular position in trailer record
Reply with quote

I am able to calculate the record count and sum of the input fields.
But is it possible to place the record count and sum total in a particular place in the trailer record?
e.g.
I need to add the trailer record at the end of the file. My input file is 751 byte file but i am dealing with only following few fields for the trailer record creation:
2nd byte in input contains S9(9) COMP-3
7th byte in input contains S9(3) COMP-3

I want to create a trailer record in output file such that
2nd byte contains 999999999
7th byte contains 999
10th byte contains record count in the file
14th byte contains sum of values in 2nd byte in input file
22nd byte contains sum of values in 7th byte in input.

all the above fields are packed decimal fields.

Thanks!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Mar 26, 2008 9:03 pm    Post subject:
Reply with quote

You can use c: in TRAILER1 to indicate the column in which an item should start, e.g.

Code:

  TRAILER1=(2:'99999999',10:COUNT=...,14:TOT=...,22:TOT=...)


Note that your description of what you want in which field contains overlapping values - 999999999 starting in position 2 would be in positions 2-10, but you say you want position 7 to contain 999 and position 10 to contain record count. You need to correct this.
Back to top
View user's profile Send private message
Moved: Wed Mar 26, 2008 9:06 pm by Frank Yaeger From JCL to DFSORT/ICETOOL
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1