Multiply or divide records in a file



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Multiply or divide records in a file

Postby Puffe » Fri Jun 17, 2011 11:50 am

Hi,

I have a file (lrecl=10,recfm=fb) containing several records.
What I want to achieve is to count records with the same value in position 6 and 2 long.
At the same time I want another field in the output file where you multiply the sum of counted records with 4.
Yet another field in the output file I want is to divide by 2 and rounded up.
So far I've managed to do the counted records in SYSIN-statement but not the multiply/divide-statements.

//SORTIN DD *
ABC1233ABA
ABD1233ABA
BBB2233BBA
ABD1244ABA
BBB1244BBA
CCC1244CCC

//SYSIN DD *
INREC FIELDS=(6,2,7X)
INCLUDE COND=(10,1,CH,EQ,C'A')
SORT FIELDS=(1,2,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,2,
TRAILER3=(1,2,COUNT=(EDIT=(IIIIIIT))))

This result in the file
33 3
44 2

But I want (*4) (/2)
33 3 12 2
44 2 4 1

Suggestions?

Micke
Puffe
 
Posts: 21
Joined: Mon May 02, 2011 1:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiply or divide records in a file

 

Re: Multiply or divide records in a file

Postby skolusu » Fri Jun 17, 2011 9:22 pm

Puffe,

The following DFSORT JCL will give you the desired results. You will 8 bytes of total number of records in position 3 and 10 bytes of total*4 and another 8 bytes of total/2 rounded. All of them have the leading zeroes supressed.

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
ABC1233ABA                                                       
ABD1233ABA                                                       
BBB2233BBA                                                       
ABD1244ABA                                                       
BBB1244BBA                                                       
CCC1244CCC                                                       
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  INCLUDE COND=(10,1,CH,EQ,C'A')                                 
  INREC BUILD=(6,2,7C'0',C'1')                                   
  SORT FIELDS=(1,2,CH,A)                                         
  SUM FIELDS=(3,8,ZD)
                                           
  OUTREC IFOUTLEN=28,IFTHEN=(WHEN=INIT,                         
  BUILD=(1,2,3,8,ZD,M10,LENGTH=8,+4,MUL,3,8,ZD,M10,LENGTH=10,   
         3,8,ZD,MUL,+100,DIV,+2,EDIT=(IIIIIIII.TT))),           
  IFTHEN=(WHEN=(30,2,ZD,NE,0),                                   
  OVERLAY=(21:+1,ADD,21,8,UFF,M10,LENGTH=8))                     
//*


The output from the above job is
33       3        12       2
44       2         8       1
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Multiply or divide records in a file

Postby Puffe » Mon Jun 20, 2011 10:13 am

Thanks !

A lots of new commands I've never used before. Now I've to learn a little bit more of them
Puffe
 
Posts: 21
Joined: Mon May 02, 2011 1:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiply or divide records in a file

Postby Puffe » Mon Jun 20, 2011 10:48 am

Hi again.

Is it possible for you, skolusu, to explain the sort step by step from statement OUTREC?
Puffe
 
Posts: 21
Joined: Mon May 02, 2011 1:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiply or divide records in a file

Postby Frank Yaeger » Mon Jun 20, 2011 10:40 pm

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post