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
 
Merge files having count in the trailer..

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

New User


Joined: 10 Jan 2006
Posts: 65
Location: chennai

PostPosted: Tue Feb 21, 2006 4:27 pm    Post subject: Merge files having count in the trailer..
Reply with quote

Hi,

I have 2 input files. Each file has a Trailer record at the end, which cariies the total number of records in that file. I need to merge these files in to a single file, but the out file should carry the total number of records in the trailer. How to do it using SORT?

Thanks,
Sreejith
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: Tue Feb 21, 2006 8:23 pm    Post subject:
Reply with quote

You need to supply more information on what you're trying to do.

Please show an example of the records in each input file and the output records you expect. What is the RECFM and LRECL of each input file? Is there anything that identifies the trailer record other then it being the last record? How are you "merging" the input file records (e.g. by a key)? Do you need information from the original trailer records in the new trailer record or can you create it from scratch?
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Wed Feb 22, 2006 10:40 am    Post subject:
Reply with quote

Hi,

If you want some thing like the total number of records from both
the input file to be in your final output file excluding the trailer record
in the output file. Copy by omiting the trailer records and try the below job
Code:
//STEP0100 EXEC PGM=ICETOOL             
//TOOLMSG  DD  SYSOUT=*                 
//DFSMSG   DD  SYSOUT=*                 
//FILEIN   DD  *                       
 111111111111111111111111111           
 111111111111111111111111111           
/*                                     
//         DD  *                       
 111111111111111111111111111           
 111111111111111111111111111           
/*                                     
//OUT      DD DSN=FILE.OUTPUT,DISP=MOD 
//OUT1     DD DSN=&&TEMP,DISP=MOD       
//TOOLIN DD *                           
  COPY FROM(FILEIN) TO(OUT1) USING(CPY1)
  COPY FROM(FILEIN) TO(OUT)             
  COPY FROM(OUT1) TO(OUT)               
/*                                     
//CPY1CNTL DD *                         
   OUTFIL FNAMES=OUT1,NODETAIL,REMOVECC,
    TRAILER1=(COUNT)                     
/*                                       
//*                                     
//                                       


output

Code:
 111111111111111111111111111
 111111111111111111111111111
 111111111111111111111111111
 111111111111111111111111111
    4                       


Regards,
Back to top
View user's profile Send private message
itssreehere
Warnings : 1

New User


Joined: 10 Jan 2006
Posts: 65
Location: chennai

PostPosted: Sat Feb 25, 2006 11:18 am    Post subject:
Reply with quote

Let me explain my requirement in detail with the following example,

File1.
------
name1 address1 ......12345....
name2 address2 ......67474....
.......
namen addressn ......25345....
.............................. total .......>trailer record having the sum of all the amounts in each record.Only way to identify the trailer is, it will be the last record in the file.


I have 4 similar files.


Now i have to merge all thse 4 files in to a single file(no need to sort), Which will have only one trailer and one amount field which will be the sum of amounts in each of the 4 trailer records.

Can we do it using sort? If yes will it work on DFSORT and SYNC SORT?
Or i have to write a program for merging?

Thanks,
Sreejith
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: Sat Feb 25, 2006 9:29 pm    Post subject:
Reply with quote

You still haven't supplied enough information for me to give you a complete solution.

Again, do you need information from the original trailer records in the new trailer record, or can you create the new trailer record from scratch? If you need information from the original trailer records in the new trailer record, which original trailer record and what information? Or do you just need the sum in the new trailer record without any other information?

What is the starting position, length and format of the key you're merging on? What is the starting position, length and format of the sum in the trailer record?

What is the RECFM and LRECL of each input file?

Quote:
If yes will it work on DFSORT and SYNC SORT?


Which one do you have?
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Mon Feb 27, 2006 12:48 pm    Post subject:
Reply with quote

Hi,

Give at least one record from each file and the RECFM and LRECL of the file it will be help ful.. now from what u have mentioned i have assumed u have four files and got a field sum of which u want to put into aother file

If that is the case here is the JCL



Code:
//STEP0100 EXEC PGM=ICETOOL             
//TOOLMSG  DD SYSOUT=*                   
//DFSMSG   DD SYSOUT=*                   
//FILEIN1   DD *                         
FILE01 1 230                             
FILE01 1 230                             
FILE01 1 230                             
/*                                       
//          DD *                         
FILE02 2 236                             
FILE02 2 236                             
FILE02 2 236                             
/*                                       
//OUT   DD SYSOUT=*                     
//TOOLIN DD *                           
  COPY FROM(FILEIN1) TO(OUT) USING(CNT1)
//OUT   DD SYSOUT=*                     
//CNT1CNTL  DD *                         
   OPTION COPY                           
   OUTFIL FNAMES=OUT,REMOVECC,NODETAIL, 
   TRAILER1=(C'TOTAL VALUE  :  ',TOT=(10,3,FS,EDIT=(TTTTTTTTT))) 
/*                                                               
//SYSOUT DD SYSOUT=*                                             
//                                                               


OUTPUT will be
Code:
TOTAL VALUE  :  000001398


If not pls provide the details..

Regards,
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: Mon Feb 27, 2006 9:40 pm    Post subject:
Reply with quote

fixdoubts,

You've missed an essential part of the requirement, which is to remove the last (total) record from each file. There's nothing to identify this last record in each file except that it is the last record in each file.

You've created a new trailer record from scatch, but you haven't removed the old trailer records. You've also assumed that the new trailer record doesn't have to contain any information from the old trailer record, which is an assumption I'm trying to get Sreejith to verify or refute.
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Tue Feb 28, 2006 3:32 pm    Post subject:
Reply with quote

Yeah,

I assumed shreejit wants the count of a field in each file and want that in the final trailer count.

That was an assumption and i have mentioned it also.

If its useful for Sreejit, that would be very fine

Regards,
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: Tue Feb 28, 2006 9:34 pm    Post subject:
Reply with quote

fixdoubts,

Read through the posts again. It's pretty clear that each file has a trailer record as the last record. Only one trailer record is supposed to appear in the output, so the other trailer records must be removed. Anyway, it appears sjreejith has lost interest.
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Mon Mar 27, 2006 10:12 pm    Post subject:
Reply with quote

Hi Frank,

I've a similar requirement...Let me know if it is possible to do in one single step -

Infile -

Code:
000000000000000000header record
aaaaaa111111111111 rec1
aaaaaa222222222222 rec2
bbbbbb333333333333 rec3
ccccccccccccccccccccc rec4
999999999999999999trailer record   <date1 > <date2 > <count>


In the input file, I've a header, few detail records and a trailer record. The trailer record is identified by 9s in the first 18 position. It will have other details like dates, totals and record count (Including header and trailer).

The problem here is that, in the trailer the record count is incorrect (Due to some previous sort steps). All I want to do is SORT this input file and create an output file with the same detail but with the correct record count in the trailer.

Record count will be always in position 102 (8 chars).
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: Tue Mar 28, 2006 1:14 am    Post subject:
Reply with quote

Is the "correct record count" the count of the detail records, or the count of the detail + header + trailer records? That is, in your example above, is the "correct record count" 4 or 6?

Also, what is the RECFM and LRECL of the input file?
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Tue Mar 28, 2006 3:46 am    Post subject:
Reply with quote

The correct record count is header+detail+trailer.
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Tue Mar 28, 2006 3:47 am    Post subject:
Reply with quote

All the files used are of length 12240 (FB).
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Tue Mar 28, 2006 4:05 am    Post subject:
Reply with quote

I believe I got the SORT card for this Frank...

Code:
//OUT DD DSN=F1149A0.DUPEXTCT.OUTPUT12,                         
//      DISP=(MOD,CATLG,DELETE),                               
//      SPACE=(CYL,(10,5),RLSE),                               
//      DCB=(,LRECL=12240,BLKSIZE=0)                           
//*                                                             
//TOOLIN DD *                                                   
 COPY FROM(MASTER) USING(CTL1)                                 
 COPY FROM(MASTER) USING(CTL2)                                 
 SPLICE FROM(CONCAT) TO(TEMP3) ON(1,18,CH) WITHALL WITH(110,9) 
 COPY FROM(MASTER) USING(CTL3)                                 
 COPY FROM(TEMP3) USING(CTL4)                                   
//CTL1CNTL DD *                                                 
  OUTFIL FNAMES=TEMP1,INCLUDE=(1,18,CH,EQ,C'999999999999999999')
//CTL2CNTL DD *                                                 
  OUTFIL FNAMES=TEMP2,REMOVECC,                                 
     TRAILER1=(1,110,COUNT),NODETAIL                           
//CTL3CNTL DD *                                                 
  OUTFIL FNAMES=OUT,OMIT=(1,18,CH,EQ,C'999999999999999999'),   
   OUTREC=(1,12240)                                             
//CTL4CNTL DD *                     
  OUTFIL FNAMES=OUT,OUTREC=(1,12240)
//*


Master is my input file's DD Name and OUT is my final output file.

But the problem is the count is appearing as ' 15' whereas, I want it as '00000015' or '15 '. I used the Edit sub parameter, but received the following error -

Code:
 CTL2CNTL :                                         
   OUTFIL FNAMES=TEMP2,REMOVECC,                     
      TRAILER1=(1,110,COUNT=(M11)),NODETAIL         
                           *                         
 WER428I  CALLER-PROVIDED IDENTIFIER IS "0002"       
 WER268A  OUTFIL STATEMENT  : SYNTAX ERROR
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
           


What should be wrong???
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: Tue Mar 28, 2006 7:00 am    Post subject:
Reply with quote

Ramya,

The following DFSORT job would do what you want:

Code:

//S1 EXEC  PGM=ICEMAN
//SYSOUT   DD  SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
* Create DFSORT Symbol for count as:
* CT,'cccccccc'
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(C'CT,''',COUNT=(M11,LENGTH=8),C'''',80:X)
/*
//S2 EXEC  PGM=ICEMAN
//SYSOUT   DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
* Use CT to overlay original count in trailer record.
  INREC IFTHEN=(WHEN=(1,18,CH,EQ,C'999999999999999999'),
    OVERLAY=(102:CT))
/*


However, the WER messages indicate you're using Syncsort, not DFSORT.

I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am

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