Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

getting record count a sum of a field

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

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Jul 26, 2007 4:28 pm    Post subject: Adding trailer record at the end.
Reply with quote

I want to add trailer record at the end of the file after passing it thru a sort step.
input file
aaaaaaaaaaaaaaa
bbbbbbbbbbbbbbb
ggggggggggggggg
ddddddddddddddd
output shud look like
aaaaaaaaaaaaaaa
bbbbbbbbbbbbbbb
ggggggggggggggg
ddddddddddddddd
rec cnt : 4
let me know how i can do this.
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jul 26, 2007 4:42 pm    Post subject:
Reply with quote

Try this thread:
How to write record count in header??
Though the OP wanted it in the header, there is an example (by the OP) of the getting the total in the trailer.
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Jul 26, 2007 5:20 pm    Post subject: Re: Adding trailer record at the end.
Reply with quote

I didn't get a clear idea from that link. Could you please throw some more light on this issue.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Jul 26, 2007 5:31 pm    Post subject:
Reply with quote

sandy_mcs wrote:
Thank's Frank, your "smart DFSORT tricks" helped me out and i got the solution to my query
The JCL i used to get count of records present in SORTIN in to SORTOUT.


Code:

//PGM1     EXEC PGM=ICEMAN                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=SMOM.SORT3.OUT,DISP=SHR                 
//SORTOUT  DD DSN=SMOM.SORT.ICEOUT,DISP=SHR               
//SYSIN    DD *                                             
  OPTION COPY                                               
  OUTFIL NODETAIL,REMOVECC,                                 
    TRAILER1=(COUNT=(M11,LENGTH=4))                           
/*                                                         

Quote:
Put the "COUNT" in the "TRAILER1"?
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Jul 26, 2007 5:47 pm    Post subject:
Reply with quote

pjnithin
check this link http://ibmmainframes.com/viewtopic.php?t=23050
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Jul 26, 2007 6:40 pm    Post subject: Re: Adding trailer record at the end.
Reply with quote

can i do this in one single step????
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Jul 26, 2007 7:13 pm    Post subject: Re: Adding trailer record at the end.
Reply with quote

pjnithin wrote:
can i do this in one single step????
Looking at sandy_mcs's sample, I only see one step......
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Jul 26, 2007 7:19 pm    Post subject:
Reply with quote

pjnithin

This is how you do in a single step
Code:
//*******************************************************               
//STEP1    EXEC PGM=ICEMAN                                             
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
AAAAAAAAAAAAAAA                                                         
BBBBBBBBBBBBBBB                                                         
GGGGGGGGGGGGGGG                                                         
DDDDDDDDDDDDDDD                                                         
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
           OPTION COPY                                                 
           OUTFIL REMOVECC,                                             
           TRAILER1=(1:C'REC CNT=',10:COUNT=(M11,LENGTH=8))             
/*                                                                     

SORTOUT:
Code:
----+----1----+----2---
AAAAAAAAAAAAAAA       
BBBBBBBBBBBBBBB       
GGGGGGGGGGGGGGG       
DDDDDDDDDDDDDDD       
REC CNT= 00000004     
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Jul 26, 2007 7:51 pm    Post subject:
Reply with quote

CICS Guy
Quote:
Looking at sandy_mcs's sample, I only see one step......

The NODETAIL in
Code:
OUTFIL NODETAIL,REMOVECC,
ensures that no i/p records are copied to the o/p.
So in the o/p you see only one record which says the count of records.
Hence pjnithin thought that, this is a two step process.
But by removing the NODETAIL, in OUTFIL statement you can achieve this
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Tue Aug 07, 2007 12:32 pm    Post subject: Updating record count in trailer record
Reply with quote

Hi,
I need to update my trailer record count after excluding some records using sort.
Input:
1111111111 22222
1111111111 33333
4444444444 55555
6666666666 66666
trailr abc 00004

now the output after sort shud look like :
Output:
1111111111 22222
4444444444 55555
6666666666 66666
trailr abc 00003

'trailr abc' is not a constant value, so this cannot be hardcoded anywhere in the sort step. but i need the record count to be updated in the trailer record after sorting the input file based on (1,10) chars.
Back to top
View user's profile Send private message
IQofaGerbil

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Tue Aug 07, 2007 1:16 pm    Post subject: Re: updating record count in trailer record
Reply with quote

So are you saying that the trailer record contains unknown variable data?

eg it might be
Quote:

trailr abc 00004


but then again it might be
trailr def 00004

or maybe
trailer wxyz 00004

or 'something else'

and based on that , you want to remove any duplicates from the file prior to the trailer record and update the 'count' with the new number of records.

Is the trailer record at least always the last record in the file?

Maybe you could give some more input and output examples to explain the 'rules'.
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Tue Aug 07, 2007 1:27 pm    Post subject: Re: updating record count in trailer record
Reply with quote

sir the output file shows that the records are sorted on first 10 chars and the duplicate records are removed.
trailer will always be the last record.
again, trailr abc...this can be anything like trailk def or trailr kgh etc..
but wat i have to do is by retaining the other details in the trailer record i need to update the count in that.
So after sorting and removing the duplicates, the trailer record should become like 'trailr abc 00003' instead of 'trailr abc 00004' . Because there was one duplicate record and it has been removed. hope its clear to you now....
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Tue Aug 07, 2007 1:39 pm    Post subject:
Reply with quote

Nithin,

Same query posted by you sometime back.

http://www.ibmmainframes.com/viewtopic.php?t=23083&highlight=count
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Tue Aug 07, 2007 2:38 pm    Post subject: Re: updating record count in trailer record
Reply with quote

dear sir,
please read my requirement.
its a different question. i already have my trailer here and the count of input records. now i need to sort the detail records and retain the trailer record and also update the counter with proper count after remocing the dulicates.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 07, 2007 3:00 pm    Post subject:
Reply with quote

Here is a similar job that Frank built for another using SYMNAMES:

SIMILARITIES
  1. removing dups
  2. passing an updated count

DIFFERENCES
  1. variable length records
  2. looking for a header


with a few modifications, you can have your fixed length trailer update
Code:


//S1    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SORTIN DD DSN=...  input file (VB)                             
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)       
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)     
//SYSIN    DD    *                                               
  SORT FIELDS=(5,13,CH,A)                                       
  SUM FIELDS=NONE                                               
  OUTFIL FNAMES=T1                                               
  OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,VTOF,                     
    BUILD=(80X),                                                 
    TRAILER1=('NEWCT,''',COUNT-1=(M11,LENGTH=4),C'''')           
/*
//S2    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                           
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)                             
//SORTOUT DD DSN=... output file (VB)                             
//SYSIN    DD    *                                               
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=(5,1,CH,EQ,C'A'),                           
    OVERLAY=(63:NEWCT))                                         
/*
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Sep 20, 2007 4:07 pm    Post subject: getting record count a sum of a field
Reply with quote

I have a input file like this.

adc a 10.00
abc a 20.00
dfg b 30.00

My output file shud be like
adc a 10.00
abc a 20.00
dfg b 30.00
t cnt:3 tot=60.00

The last five digits is a character field of 5 digits. I need to take the sum of these fields and also the count of the number of records and create a trailer record as given below.

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

Senior Member


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

PostPosted: Thu Sep 20, 2007 4:28 pm    Post subject:
Reply with quote

Nithin,

Sort card for you req:
Code:

 //SYSIN DD *                                       
   SORT FIELDS=COPY                                 
   OUTFIL REMOVECC,                                 
   TRAILER1=(C'T CNT:',COUNT=(EDIT=(TTTT)),         
            C'TOTAL=',TOT=(7,5,SFF,EDIT=(TT.TT)))   
/*


OP with your IP:

Code:
ADC A 10.00               
ABC A 20.00               
DFG B 30.00               
T CNT:0003TOTAL=60.00     


Note: Change the trailer1 part according to your req.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Sep 20, 2007 4:36 pm    Post subject: Reply to: getting record count a sum of a field
Reply with quote

Use the below code

Code:

//SYSIN       DD *                                           
  SORT FIELDS=(1,3,CH,A)                                     
  OUTFIL REMOVECC,NODETAIL,                                   
  TRAILER1=('INPUT COUNT: ',COUNT=(M11,LENGTH=8),'  TOTAL:', 
            TOT=(7,5,SFF,EDIT=(TT.TT)))                       
/*                                                           
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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 1 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us