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
 
Finding the percentage of value

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

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon Oct 13, 2008 8:15 pm    Post subject: Finding the percentage of value
Reply with quote

Hi,

Input1 file: 500, FB, Sum field: 50-55, Comp-3

Code:
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----700
AAAAAA SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ   45.5  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ  100.0  B
AAAAAA SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ   19.0  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ   41.7  B
AAAAAA SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ   23.5  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ   51.6  B
AAAAAA SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ    4.0  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ    8.8  B
BBBBBB SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ   50.0  A
BBBBBB SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ  100.0  B
BBBBBB SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ   20.0  A
BBBBBB SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ   40.0  B
BBBBBB SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ    2.5  A
BBBBBB SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ    5.0  B
BBBBBB SSSSS DDDDD FFFF VVVVV X0008 HHHHH JJJJJJ   12.0  A
BBBBBB SSSSS DDDDD FFFF VVVVV X0008 HHHHH JJJJJJ   24.0  B
CCCCCC SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ   50.0  A
CCCCCC SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ  100.0  B
CCCCCC SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ   20.0  A
CCCCCC SSSSS DDDDD FFFF VVVVV X0006 HHHHH JJJJJJ   40.0  B
CCCCCC SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ    2.5  A
CCCCCC SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ    5.0  B
CCCCCC SSSSS DDDDD FFFF VVVVV X0009 HHHHH JJJJJJ   12.0  A
CCCCCC SSSSS DDDDD FFFF VVVVV X0009 HHHHH JJJJJJ   24.0  B


File 2:

Code:
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----|----8
X0006
X0008
X0009
X0010



The record in the file are grouped based on the first 6 bytes. If its same, then the values will be written consecutively until the first 6 bytes changes.

The 31st byte has a 5 byte varible whose presence will be checked in the file2. If its present, then the value should be changed as xxxxx and then the same is written in the file1.

For example, consider the value X0006 from file1 and its also present in file2. so while writing this record, the value X0006 should be changed as XXXXX and the each such value will have 2 records A & B.

Now if there are more than one X0006 records, then all those A & B values have to be added and displayed as a single record. This condition is applicable for all the records present in file2.

Output file shoukd be:

Code:
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----700
AAAAAA SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ   45.5  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ  100.0  B
AAAAAA SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ   23.5  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ   51.6  B
AAAAAA SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   23.0  A
AAAAAA SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   50.5  B
BBBBBB SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ   50.0  A
BBBBBB SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ  100.0  B
BBBBBB SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ    2.5  A
BBBBBB SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ    5.0  B
BBBBBB SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   32.0  A
BBBBBB SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   64.0  B
CCCCCC SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ   50.0  A
CCCCCC SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ  100.0  B
CCCCCC SSSSS DDDDD FFFF VVVVV X0011 HHHHH JJJJJJ    2.5  A
CCCCCC SSSSS DDDDD FFFF VVVVV X0011 HHHHH JJJJJJ    5.0  B
CCCCCC SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   32.0  A
CCCCCC SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   64.0  B
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Oct 13, 2008 11:18 pm    Post subject: Reply to: Finding the percentage of value
Reply with quote

nelson.pandian,

The following DFSORT/ICETOOL JCL will give you the desired results



Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN1      DD DSN=YOUR 500 BYTE FILE,
//            DISP=SHR
//IN2      DD *                                               
X0006                                                         
X0008                                                         
X0009                                                         
X0010                                                         
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE) 
//T2       DD DSN=&&T2,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE) 
//OUT      DD SYSOUT=* 
//TOOLIN   DD *                                   
  COPY FROM(IN2) USING(CTL1)                       
  COPY FROM(IN1) USING(CTL2)                       
  SPLICE FROM(T1) TO(T2) ON(31,5,CH) KEEPBASE -   
  KEEPNODUPS WITHALL WITH(01,500) USING(CTL3)     
  SORT FROM(T2) USING(CTL4)                       
//CTL1CNTL DD *                                   
  OUTFIL FNAMES=T1,BUILD=(31:1,5,501:1,5)         
//CTL2CNTL DD *                                   
  OUTFIL FNAMES=T1,OVERLAY=(501:5X)
//CTL3CNTL DD *                                 
  OUTFIL FNAMES=T2,OMIT=(1,30,CH,EQ,C' '),     
  IFTHEN=(WHEN=(501,5,CH,EQ,31,5,CH),           
  OVERLAY=(31:5C'X')),IFOUTLEN=500             
//CTL4CNTL DD *                                 
  OPTION EQUALS                                 
  SORT FIELDS=(1,6,CH,A,31,5,CH,A,58,1,CH,A)   
  SUM FIELDS=(50,6,PD)                         
  OUTFIL FNAMES=OUT                             
/*
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Tue Oct 14, 2008 12:48 am    Post subject:
Reply with quote

Hi Skolusu,

Thanks for the JCL. One more requirement using the same file.

Code:
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----500
AAAAAA SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ   45.5  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0002 HHHHH JJJJJJ  100.0  B
AAAAAA SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ   23.5  A
AAAAAA SSSSS DDDDD FFFF VVVVV X0005 HHHHH JJJJJJ   51.6  B
AAAAAA SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   23.0  A
AAAAAA SSSSS DDDDD FFFF VVVVV XXXXX HHHHH JJJJJJ   50.5  B


In this 'B' record stands for the percentage. It will have the percentage value of the previous 'A' record.

For Example: The 'A' record has '45.5' which is the total value. The next 'B' record has the '100' due to the previous 'A' record is the total. ((45.5/45.5)*100) = 100.

The Next 'A' record has the value of '19.0' Where the 'B' record value should be ((23.5/45.5)*100), that is 51.6.

In the same way, we are adding the value of 'A' records whole fields (in position 31-35) is present in file2. We need the percentage of the previous 'A' record in the record 'B'.

Example: ((23.0/45.5)*100), that is 50.5 should be present in 'B' record.

Now i have given example for 'AAAAA', In the same way we should do for 'BBBBBB' and so on till end of the file.

For more example please refer the precious output file which is posted first.

Is this possible in ICETOOL?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Oct 14, 2008 2:04 am    Post subject: Reply to: Finding the percentage of value
Reply with quote

nelson pandian,

Your requirement is quite confusing. lets take the example of just 1 key

Code:

AAAAAA  X0002   45.5  A
AAAAAA  X0002  100.0  B
AAAAAA  X0006   19.0  A
AAAAAA  X0006   41.7  B
AAAAAA  X0005   23.5  A
AAAAAA  X0005   51.6  B
AAAAAA  X0006    4.0  A
AAAAAA  X0006    8.8  B


Since x0006 has a matching key the values of A are summed up

Code:

AAAAAA  X0002     45.5   A
AAAAAA  X0005     23.5   A
AAAAAA  XXXXX     23.0   A


now tell me how do you want the B records for this 3 records

for X0002 record it is (45.5 /45.5 ) * 100 = 100.0

now for the second record (23.5/45.5) * 100 = 51.64

now for thrid record (23.0/(45.5 + 23.5)) * 100 = (23.0/69.0) * 100 = 33.33


is that how you calculate ? if not you need to come up with a detailed explanation of how you want the percentage to be calculated
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Tue Oct 14, 2008 10:50 am    Post subject:
Reply with quote

The percentage calculation for 'B' record, in first 2 records are correct.
For X0002 record it is (45.5 /45.5 ) * 100 = 100.0

For the second record (23.5/45.5) * 100 = 51.64

But these values are already present in the Input file. So just writing the records is enough.

But the 'A' record for the matching records in file 2 should be summed and written in the out file. The following 2 records should be summed up.

Code:
AAAAAA  X0006   19.0  A
AAAAAA  X0006    4.0  A


Output for these records should be a single record such as.

Code:
AAAAAA  XXXXX   23.0  A


Now the calculation for the last record will be: (23.0/45.5)* 100 = 50.5

So the last 'B' record will be

Code:
AAAAAA  XXXXX   50.5  B


So my final output file should be

Code:
AAAAAA  X0002   45.5  A
AAAAAA  X0002  100.0  B
AAAAAA  X0005   23.5  A
AAAAAA  X0005   51.6  B
AAAAAA  XXXXX   23.0  A
AAAAAA  XXXXX   50.5  B


In the same way we have to calculate for all the other set of records.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Oct 15, 2008 1:41 am    Post subject: Reply to: Finding the percentage of value
Reply with quote

nelson.pandian,

Basically you want to re-calculate the percentage on the B record only when there is match and you summed up the values and you need to consider the very first record in the Group to calculate the percentage? If so then the following DFSORT/ICETOOL JCL will give you the desired results.


Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN1      DD DSN=YOUR 500 BYTE FILE,
//            DISP=SHR
//IN2      DD *           
X0006                                                         
X0008                                                         
X0009                                                         
X0010                                                         
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&&T2,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=* 
//TOOLIN   DD *                                                     
  COPY FROM(IN2) USING(CTL1)                                         
  COPY FROM(IN1) USING(CTL2)                                         
  SPLICE FROM(T1) TO(T2) ON(31,5,CH) KEEPBASE -                     
  KEEPNODUPS WITHALL WITH(01,506) USING(CTL3)                       
  SORT FROM(T2) USING(CTL4)                                         
//CTL1CNTL DD *                                                     
  OUTFIL FNAMES=T1,BUILD=(31:1,5,507:1,5)                           
//CTL2CNTL DD *                                                     
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(512:SEQNUM,8,ZD,RESTART=(1,6))),
  IFTHEN=(WHEN=GROUP,BEGIN=(512,8,ZD,EQ,1),PUSH=(501:50,6))         
  OUTFIL FNAMES=T1,BUILD=(1,506,5X)                                 
//CTL3CNTL DD *                                                     
  OUTFIL FNAMES=T2,OMIT=(1,30,CH,EQ,C' '),                           
  IFTHEN=(WHEN=(507,5,CH,EQ,31,5,CH),OVERLAY=(31:5C'X',507:5C'9')), 
  IFTHEN=(WHEN=NONE,OVERLAY=(507:31,5))                             
//CTL4CNTL DD *                                                     
  OPTION EQUALS                                                     
  SORT FIELDS=(1,6,CH,A,507,5,CH,A,58,1,CH,A)                       
  SUM FIELDS=(50,6,PD)                                               
  OUTREC IFTHEN=(WHEN=INIT,                                         
  OVERLAY=(507:((+1000,MUL,50,6,PD),DIV,501,6,PD),PD,LENGTH=6)),     
  IFTHEN=(WHEN=GROUP,BEGIN=(58,1,CH,EQ,C'A'),RECORDS=2,             
  PUSH=(507:507,6)),                                                 
  IFTHEN=(WHEN=(58,1,CH,EQ,C'B'),OVERLAY=(50:507,6))                 
  OUTFIL FNAMES=OUT,BUILD=(1,500)                                   
/*                                                                   
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Wed Oct 15, 2008 10:41 am    Post subject:
Reply with quote

Hi Kolusu,

The error message is as follows:

Code:
            IFTHEN=(WHEN=GROUP,BEGIN=(512,8,ZD,EQ,1),PUSH=(501:50,6))
                         $                                           
ICE007A 0 SYNTAX ERROR                                               


We don't have the latest version of DFSORT/ICETOOL Features (July, 2008). The version we are using right now is Z/OS DFSORT V1R5 So i think, i cont use this JCL icon_sad.gif

Can you suggest some other way to meet my requirement?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Oct 16, 2008 12:27 am    Post subject:
Reply with quote

nelson.pandian,

It would probably require another pass. Is the B record different from the A record or can we use the A record as base and create the B record calculating the percentage?
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Thu Oct 16, 2008 12:55 am    Post subject:
Reply with quote

Hi Skolusu,

We can use record 'A' as the base and create record 'B'. There is not difference. Record 'B' will contain the percentage of record 'A'.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Oct 16, 2008 4:34 am    Post subject: Reply to: Finding the percentage of value
Reply with quote

nelson.pandian,

The following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN1      DD DSN=YOUR 500 BYTE FILE,
//            DISP=SHR
//IN2      DD *           
X0006                                                         
X0008                                                         
X0009                                                         
X0010                                                         
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&&T2,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=* 
//TOOLIN   DD *                                                   
  COPY FROM(IN2) USING(CTL1)                                       
                                                                   
  SPLICE FROM(IN1) TO(T1) ON(1,6,CH) KEEPBASE -                   
  KEEPNODUPS WITHALL WITH(01,500) USING(CTL2)                     
                                                                   
  SPLICE FROM(T1) TO(T2) ON(31,5,CH) KEEPBASE -                   
  KEEPNODUPS WITHALL WITH(01,506) USING(CTL3)                     
  SORT FROM(T2) USING(CTL4)                                       
//CTL1CNTL DD *                                                   
  OUTFIL FNAMES=T1,BUILD=(31:1,5,507:1,5)                         
//CTL2CNTL DD *                                                   
  OMIT COND=(58,1,CH,EQ,C'B')                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(501:50,6))                     
  OUTFIL FNAMES=T1,BUILD=(1,506,5X)                               
//CTL3CNTL DD *                                                   
  OUTFIL FNAMES=T2,OMIT=(1,30,CH,EQ,C' '),                         
  IFTHEN=(WHEN=(507,5,CH,EQ,31,5,CH),OVERLAY=(31:5C'X',507:5C'9')),
  IFTHEN=(WHEN=NONE,OVERLAY=(507:31,5))                           
//CTL4CNTL DD *                                                   
  OPTION EQUALS                                                   
  SORT FIELDS=(1,6,CH,A,507,5,CH,A,58,1,CH,A)                     
  SUM FIELDS=(50,6,PD)                                             
  OUTREC IFTHEN=(WHEN=INIT,                                       
  OVERLAY=(507:((+100,MUL,50,6,PD),DIV,501,6,PD),PD,LENGTH=6))     
  OUTFIL FNAMES=OUT,                                               
  BUILD=(1,500,/,1,49,507,6,56,2,C'B',59,442)                     
/*                                                                 
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 LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Finding IMS resource blocker after se... Hooman24 IMS DB/DC 1 Wed Aug 16, 2017 9:17 pm
No new posts finding delayed job/s in OPC jzhardy IBM Tools 0 Mon May 29, 2017 9:04 am
No new posts Finding unreferenced datasets without... Alan Playford JCL & VSAM 5 Tue Jul 12, 2016 9:07 pm
No new posts Finding repetead surnames in differen... blackjack202 DFSORT/ICETOOL 7 Tue Jun 07, 2016 7:42 pm

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