MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

summarizing values in a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
avid_lrner
Beginner


Joined: 15 Apr 2005
Posts: 21
Topics: 9

PostPosted: Tue Jun 07, 2005 1:36 am    Post subject: summarizing values in a file Reply with quote

Hi,

I have a file with the following structure:
Code:

  FIELD 1               FIELD2    FIELD3
  ---------            -------   -------
  01C04C47C7000001         500       500
  01C04C47C7300001         500       500
  01C05C20C0000001         500       500
  01C05C20C0000002         500       500
  01C05C20C0000003         500       500
  01C05C21C0000001         500       500
  01C05C21C0000002         500       500
  01C05C21C0000003         500       500
  01C05C22C0000001         500       500

The requirement is as follows:

The last 5 bytes of FIELD1 denote the sequence number.

If the field has sequence number > 1, then FIELD2 and FIELD3 must be summarized.

The resulting file should be as follows:
Code:

   FIELD1              FIELD2    FIELD3
  ------------        -------   ------- 
  01C04C47C7000001       500        500
  01C04C47C7300001       500        500
  01C05C20C0000001       1500      1500
  01C05C21C0000001       1500      1500
  01C05C22C0000001       500        500


Would appreciate your inputs.

Thanks for your precious time!

regards,
avid_lrner.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jun 07, 2005 7:53 am    Post subject: Reply with quote

avid_lrner,

The following JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD  SYSOUT=*                                     
//SORTIN   DD  *                                             
01C04C47C7000001         500       500                       
01C04C47C7300001         500       500                       
01C05C20C0000001         500       500                       
01C05C20C0000002         500       500                       
01C05C20C0000003         500       500                       
01C05C21C0000001         500       500                       
01C05C21C0000002         500       500                       
01C05C21C0000003         500       500                       
01C05C22C0000001         500       500                       
//SORTOUT  DD  SYSOUT=*                                     
//SYSIN    DD  *                                             
  INREC FIELDS=(1,19,                                       
                20,9,FS,ZD,LENGTH=9,                         
                29,1,                                       
                30,9,FS,ZD,LENGTH=9,                         
                39:16,1,CHANGE=(1,C'1',C'1'),NOMATCH=(C'1'))
  SORT FIELDS=(1,11,CH,A,39,1,CH,A)
  SUM FIELDS=(20,9,30,9),FORMAT=ZD
  OUTREC FIELDS=(1,19,
                 20,9,ZD,M10,LENGTH=9,
                 29,1,
                 30,9,ZD,M10,LENGTH=9)
/*


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Jun 07, 2005 10:16 am    Post subject: Reply with quote

With DFSORT, you don't actually have to convert the values to SUM them with ZD since leading blanks are treated as leading zeros.

Here are a couple of different ways to do this with DFSORT:

Method 1 - with SUM

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
01C04C47C7000001         500       500
01C04C47C7300001         500       500
01C05C20C0000001         500       500
01C05C20C0000002         500       500
01C05C20C0000003         500       500
01C05C21C0000001         500       500
01C05C21C0000002         500       500
01C05C21C0000003         500       500
01C05C22C0000001         500       500
/*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(1,11,CH,A)
  SUM FIELDS=(20,9,ZD,30,9,ZD)
  OUTREC OVERLAY=(20:20,9,ZD,M10,LENGTH=9,
    30:30,9,ZD,M10,LENGTH=9)
/*


If you don't have the Dec, 2004 DFSORT PTF, you can use FIELDS with all of the fields instead of OVERLAY with just the fields to be changed.

Method 2 - SECTIONS

Code:

//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
01C04C47C7000001         500       500
01C04C47C7300001         500       500
01C05C20C0000001         500       500
01C05C20C0000002         500       500
01C05C20C0000003         500       500
01C05C21C0000001         500       500
01C05C21C0000002         500       500
01C05C21C0000003         500       500
01C05C22C0000001         500       500
/*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(1,11,CH,A)
  OUTFIL REMOVECC,NODETAIL,
   SECTIONS=(1,11,SKIP=0L,
     TRAILER3=(1,14,C'00001',
        20:TOT=(20,9,ZD,M10,LENGTH=9),
        30:TOT=(30,9,ZD,M10,LENGTH=9)))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
avid_lrner
Beginner


Joined: 15 Apr 2005
Posts: 21
Topics: 9

PostPosted: Thu Jun 09, 2005 2:13 am    Post subject: summarizing values in a file Reply with quote

Hey Folks,

Thank you Kolusu and Frank!!!

Your solutions worked perfectly!

Frank, we don't have the Dec, 2004 DFSORT PTF in our shop.

The second alternative worked just fine.

You guys are such Knowledge Repositories Exclamation

Look forward to learn more from the Masters!!!

thanks all for your time and patience!!!

regards,
avid_lrner.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group