View previous topic :: View next topic
Author
Message
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
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
CICS Guy Senior Member Joined: 18 Jul 2007Posts: 2146 Location: At my coffee table
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
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
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
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
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
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
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
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
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
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi Frank
Thank u so much....
Back to top
Please enable JavaScript!