IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Calculation using SUM


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Sep 02, 2007 9:26 pm
Reply with quote

Hi,

I have a input file like this:

ABC 2
ABC 3
ABC 5
PQR 2
PQR 7
PQR 2
......

I want to do a calculation based on the filed-2 sum obtained on matching key-1

ie. my output file should be like this

ABC 2/10
ABC 3/10
ABC 5/10
PQR 2/11
PQR 7/11
PQR 2/11

Thanks in advance..

Thanks
Arun
Back to top
View user's profile Send private message
CICS Guy

Senior Member


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

PostPosted: Mon Sep 03, 2007 1:31 am
Reply with quote

You are going to have to do better than this....
Quote:
I wanI want to do a calculation based on the filed-2 sum obtained on matching key-1
I think I see what you are after (as a requirement, it makes no sense), but you need to expand on your requirement....
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Sep 03, 2007 11:11 am
Reply with quote

arcvns
Here is the DFFSORT/ICETOOL solution that does what you want,
Try implementing this based on your requirement. If any concerns please get back.
Code:
//*******************************************************               
//STEP001  EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD *                                                         
ABC 2                                                                   
ABC 3                                                                   
ABC 5                                                                   
PQR 2                                                                   
PQR 7                                                                   
PQR 2                                                                   
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
/*                                                                     
//TMP1     DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA 
//BOTH     DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
 COPY FROM(IN1)  TO(TMP1) USING(CP01)                                   
 COPY FROM(IN1)  TO(TMP1) USING(CP02)                                   
 SPLICE FROM(TMP1) TO(BOTH) ON(1,3,CH) WITH(80,1) WITH(5,1)-           
             WITHALL        USING(CP03) KEEPNODUPS                     
/*                                                                     
//CP01CNTL DD   *                                                       
  OPTION COPY                                                           
  OUTFIL NODETAIL,REMOVECC,                                             
     SECTIONS=(1,3,                                                     
     TRAILER3=(1,3,2X,C'/',TOT=(5,1,ZD,EDIT=(IT)),79:C'11'))           
/*                                                                     
//CP02CNTL DD   *                                                       
  OUTREC OVERLAY=(79:C'22')                                             
/*                                                                     
//CP03CNTL DD   *                                                       
  OUTFIL FNAMES=BOTH,INCLUDE=(79,2,CH,EQ,C'12'),BUILD=(1,60)           
/*                                                                     


The o/p BOTH contains:
Code:
----+----1
ABC 2/10 
ABC 3/10 
ABC 5/10 
PQR 2/11 
PQR 7/11 
PQR 2/11 
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Sep 03, 2007 12:37 pm
Reply with quote

Hi,

Thanks for the quick response...

Quote:
I think I see what you are after (as a requirement, it makes no sense)


I m sorry...But it makes sense to our requirement....

Arun
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Sep 03, 2007 12:44 pm
Reply with quote

Hi krisprems,

I want a ratio of field2: Total sum...not just to display as 2/10. It should be 0.2,0.3,0.5 etc..instead of 2/10,3/10,....

Sorry for the inconvenience...

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

DFSORT Developer


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

PostPosted: Mon Sep 03, 2007 9:15 pm
Reply with quote

Arun,

Here's a DFSORT/ICETOOL job that will do what you asked for.

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(5,5)),UNIT=SYSDA
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.IN,VOL=REF=*.IN,DISP=(OLD,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(1,3,CH) -
 WITHALL WITH(5,1) USING(CTL2)
/*
//CTL1CNTL DD   *
  OPTION COPY
  OUTFIL FNAMES=T1,NODETAIL,REMOVECC,
     SECTIONS=(1,3,
     TRAILER3=(1,3,11:TOT=(5,1,ZD,TO=ZD,LENGTH=2)))
/*
//CTL2CNTL DD   *
  OUTFIL FNAMES=OUT,
    BUILD=(1,3,X,(5,1,ZD,MUL,+10),DIV,11,2,ZD,EDIT=(T.T),80:X)
/*


For your input example, OUT will have:

Code:

ABC 0.2   
ABC 0.3   
ABC 0.5   
PQR 0.1   
PQR 0.6   
PQR 0.1   


In the future, please try to state your "requirements" more clearly and completely in your first post. Show an example of the expected output, give the RECFM and LRECL of the input file, and give the starting position, length and format of all relevant fields. This will get you quicker answers and not force people to guess what you want.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Sep 04, 2007 1:46 am
Reply with quote

Hi Frank

Thank u so much....
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Allocated space calculation from DCOL... PL/I & Assembler 3
No new posts VSAM file Storage Calculation JCL & VSAM 3
No new posts MSU calculation for DB2 (to decide be... DB2 4
No new posts Time difference calculation COBOL Programming 8
Search our Forums:

Back to Top