Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Arun Raj

Moderator

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

 Posted: Sun Sep 02, 2007 9:26 pm    Post subject: Calculation using SUM 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

CICS Guy

Senior Member

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

Posted: Mon Sep 03, 2007 1:31 am    Post subject:

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....
krisprems

Active Member

Joined: 27 Nov 2006
Posts: 649
Location: India

Posted: Mon Sep 03, 2007 11:11 am    Post subject:

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
Arun Raj

Moderator

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

Posted: Mon Sep 03, 2007 12:37 pm    Post subject:

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
Arun Raj

Moderator

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

 Posted: Mon Sep 03, 2007 12:44 pm    Post subject: 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
Frank Yaeger

DFSORT Moderator

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

Posted: Mon Sep 03, 2007 9:15 pm    Post subject:

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.
Arun Raj

Moderator

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

 Posted: Tue Sep 04, 2007 1:46 am    Post subject: Hi Frank Thank u so much....
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics MSU calculation for DB2 (to decide be... SRICOBSAS DB2 4 Wed Mar 23, 2016 6:07 pm Time difference calculation Ramsee COBOL Programming 8 Wed Dec 10, 2014 3:15 pm Date calculation thru SORT card. bshkris SYNCSORT 3 Tue Jul 08, 2014 1:56 pm &MAXSIZE parameter value calculat... vini m JCL & VSAM 12 Thu Feb 20, 2014 5:02 pm Percentage Calculation in SYNCSORT mistah kurtz SYNCSORT 11 Wed Nov 20, 2013 7:47 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us