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
 
Calculation using SUM

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

Moderator


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

PostPosted: Sun Sep 02, 2007 9:26 pm    Post subject: Calculation using SUM
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: 2150
Location: At my coffee table

PostPosted: Mon Sep 03, 2007 1:31 am    Post subject:
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    Post subject:
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: 2285
Location: @my desk

PostPosted: Mon Sep 03, 2007 12:37 pm    Post subject:
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: 2285
Location: @my desk

PostPosted: Mon Sep 03, 2007 12:44 pm    Post subject:
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 Moderator


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

PostPosted: Mon Sep 03, 2007 9:15 pm    Post subject:
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: 2285
Location: @my desk

PostPosted: Tue Sep 04, 2007 1:46 am    Post subject:
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    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 MSU calculation for DB2 (to decide be... SRICOBSAS DB2 4 Wed Mar 23, 2016 6:07 pm
No new posts Time difference calculation Ramsee COBOL Programming 8 Wed Dec 10, 2014 3:15 pm
No new posts Date calculation thru SORT card. bshkris SYNCSORT 3 Tue Jul 08, 2014 1:56 pm
No new posts &MAXSIZE parameter value calculat... vini m JCL & VSAM 12 Thu Feb 20, 2014 5:02 pm
No new posts Percentage Calculation in SYNCSORT mistah kurtz SYNCSORT 11 Wed Nov 20, 2013 7:47 pm

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