Percentage calculation usinig DFSORT
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: Percentage calculation usinig DFSORT Author: karthikeyanLocation: chennai PostPosted: Mon May 10, 2010 10:54 am
    —
We are having two files with one file having the count of total number of requests and the other with the counter of only the completed requests. I would like to calculate the percentage and produce a report like the one below. I would like to set the Return code as 12 for the job if the percentage didn't reach 50.
Code:


                           STATUS AS OF (DATE & TIME OF THE JOB RUN)                                                                                                        *************************************************************
     Total Number Requests sent for today : < XXXX - count from file 1>
     Total Number of Request completed    : <XXXX - count from file 2>
     Percentage of completion                        : <Percentage calculated >


I tried using the JoinKey option but I am facing with the following error

ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 05:10 ON FRI MAY
            JOINKEYS FILE=F1,FIELDS=(9,1,A)                                     
            $                                                                   
ICE005A 0 STATEMENT DEFINER ERROR                                               

I feel the DFSORT version we use might be a older one and is not accepting JOINKEYS. Any Help on this pls?

#2:  Author: kolusuLocation: San Jose PostPosted: Mon May 10, 2010 11:12 am
    —
karthikeyan,

What is the LRECL and RECFM of the input files?. What happens if the request is all empty but the complete file has records? Do you consider that it is above 50% ?

Can you copy the entire sysout from your error job as it helps us to determine the level the DFSORT you have.

#3:  Author: karthikeyanLocation: chennai PostPosted: Mon May 10, 2010 11:35 am
    —
Kolusu

Thank you for your Quick response.

The Request and complete file have only counters of the number of records. Both the files will not be empty at any time as the counter is retrieved from a Unload SQL Select Query in the previous step. The chances are both the files can have the counter as 0. LRECL=80 and RECFM=FB. Though the files are having a record length of 80 the counter will not exceed more than 6 digits.
Code:

ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 09:33 ON MON MAY
            JOINKEYS F1=REQ,FIELDS=(80,1,A)                                     
            $                                                                   
ICE005A 0 STATEMENT DEFINER ERROR                                               
            JOINKEYS F2=RES,FIELDS=(80,1,A)                                     
            $                                                                   
ICE005A 0 STATEMENT DEFINER ERROR                                               
            REFORMAT FIELDS=(F1:1,10,F2:1,10)                                   
            $                                                                   
ICE005A 0 STATEMENT DEFINER ERROR                                               
            SORT FIELDS=COPY                                                   
            OUTREC OVERLAY=(20:1,10,ZD,SUB,9,10,ZD,M11,LENGTH=10,               
                            30:(1,10,ZD,MUL,+50),DIV,+100,M11,LENGTH=10)       
            OUTFIL NULLOFL=RC12,INCLUDE=(20,10,ZD,EQ,30,10,ZD)                 
                           $                                                   
ICE007A F SYNTAX ERROR                                                         
ICE056A 0 SORTIN   NOT DEFINED                                 
ICE751I 0 C5-K90013 C6-K90013 C7-K90000 C8-K42135 E7-K24705     
ICE052I 3 END OF DFSORT

#4:  Author: kolusuLocation: San Jose PostPosted: Mon May 10, 2010 12:04 pm
    —
karthikeyan,

You canNOT set RC=12 with DFSORT. Here is a job which will give you the desired results which would set an RC of 4 if the completed requests is less than 50%. I assumed the 6 byte count starts from position 1 in both files and it is in readable format (ZD format)

Code:


//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=Your 1 recod count total req file,DISP=SHR
//         DD DSN=Your 1 recod count completed file,DISP=SHR         
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,6,X,6X'00',SEQNUM,1,ZD,80:X)),     
  IFTHEN=(WHEN=(14,1,ZD,EQ,2),OVERLAY=(8:1,6))
                       
  SORT FIELDS=(7,1,CH,A),EQUALS                                       
  SUM FIELDS=(8,4,BI,12,2,BI)                                         
  OUTREC OVERLAY=(15:X,1,6,ZD,DIV,+2,M11,LENGTH=6,X,                 
                 (8,6,ZD,MUL,+100),DIV,1,6,ZD,MUL,+100,EDIT=(TTT.TT))
                                                                     
  OUTFIL NULLOFL=RC4,INCLUDE=(8,6,CH,GE,16,6,CH),                     
  BUILD=(25:C'STATUS AS OF ',DATE1(/),C' AT ',&TIME,/,25:35C'*',//,   
         05:C'TOTAL NUMBER REQUESTS SENT FOR TODAY : ',1,6,/,         
         05:C'TOTAL NUMBER OF REQUEST COMPLETED    : ',8,6,/,         
         05:C'PERCENTAGE OF COMPLETION             : ',23,6,/,       
         80:X)                                                       
//*

#5:  Author: karthikeyanLocation: chennai PostPosted: Mon May 10, 2010 12:44 pm
    —
Kolusu

Thanks a ton. It works. But I would prefer to have the status report even when the percentage is less than 50%. Only that I need that return code to be set but report to be produced at any level.

#6:  Author: kolusuLocation: San Jose PostPosted: Mon May 10, 2010 2:32 pm
    —
karthikeyan wrote:
Kolusu

Thanks a ton. It works. But I would prefer to have the status report even when the percentage is less than 50%. Only that I need that return code to be set but report to be produced at any level.

karthikeyan,

Quite simple. Use this DFSORT JCL. SORTOUT will have the report and setrc file will set the return code of 4 depending on the count.

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=Your 1 recod count total req file,DISP=SHR
//         DD DSN=Your 1 recod count completed file,DISP=SHR   
//SORTOUT  DD SYSOUT=*                                               
//SETRC    DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,6,X,6X'00',SEQNUM,1,ZD,80:X)),     
  IFTHEN=(WHEN=(14,1,ZD,EQ,2),OVERLAY=(8:1,6))                       
  SORT FIELDS=(7,1,CH,A),EQUALS                                       
  SUM FIELDS=(8,4,BI,12,2,BI)                                         
  OUTREC OVERLAY=(15:X,1,6,ZD,DIV,+2,M11,LENGTH=6,X,                 
                 (8,6,ZD,MUL,+100),DIV,1,6,ZD,MUL,+100,EDIT=(TTT.TT))
                                                                     
  OUTFIL FNAMES=SETRC,NULLOFL=RC4,INCLUDE=(8,6,CH,GE,16,6,CH)         
  OUTFIL BUILD=(25:C'STATUS AS OF ',DATE1(/),                         
                   C' AT ',&TIME,/,25:35C'*',//,                     
                05:C'TOTAL NUMBER REQUESTS SENT FOR TODAY : ',1,6,/, 
                05:C'TOTAL NUMBER OF REQUEST COMPLETED    : ',8,6,/, 
                05:C'PERCENTAGE OF COMPLETION             : ',23,6,/,
                80:X)                                                 
//* 

#7:  Author: karthikeyanLocation: chennai PostPosted: Thu May 20, 2010 10:28 am
    —
Kolusu
Thank you for helping me. The solution works perfectly fine if both the counts are of the same number of digits and not for the ones if they are different. For example if the Request no is 20000 and the Complete no is 2000 the result is showing as 100% rather than 10%. This might be because zeroes are getting padded to the right for the completed ones. Is there a way to avoid this situation. Thank you.

#8:  Author: kolusuLocation: San Jose PostPosted: Thu May 20, 2010 11:07 am
    —
karthikeyan,

huh? You mean to say that the numbers are left justified with spaces at the end? If so change the first INREC IFTHEN statement to the following

Code:
//SYSIN    DD *                                           
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,6,UFF,M11,LENGTH=6)),   
  IFTHEN=(WHEN=INIT,BUILD=(1,6,X,6X'00',SEQNUM,1,ZD,80:X)),

#9:  Author: karthikeyanLocation: chennai PostPosted: Fri Aug 20, 2010 8:12 am
    —
Kolusu

Though we are specifiying the EDIT pattern I am still getting the output percentage rounded. I am not getting the percentage with decimal values. Am I missing something?

#10:  Author: kolusuLocation: San Jose PostPosted: Fri Aug 20, 2010 10:34 am
    —
karthikeyan wrote:
Kolusu

Though we are specifiying the EDIT pattern I am still getting the output percentage rounded. I am not getting the percentage with decimal values. Am I missing something?


Yes you are missing the control cards you used and the input and output data. How are we supposed to help you without knowing what you did or change in your data?

Show us the complete sysout from the job and also the sample input and output.

#11:  Author: karthikeyanLocation: chennai PostPosted: Fri Aug 20, 2010 10:55 am
    —
Kolusu
Sorry about that. Please find the SYSOUT of the job.

The input is in two files. One has the total request count and the other the completed count. I would like the percentage to be displayed as 097.02 and not as 097.00.
Code:


                    STATUS AS OF 2010/08/20 AT 05:01:21
                        ***********************************

    TOTAL NUMBER REQUESTS SENT FOR TODAY : 057726
    TOTAL NUMBER OF REQUEST COMPLETED    : 056010
    PERCENTAGE OF COMPLETION             : 097.00

Thank you for a very Quick response.

#12:  Author: kolusuLocation: San Jose PostPosted: Fri Aug 20, 2010 11:31 am
    —
karthikeyan,

I wanted the sysout not the output. Change the following line

Code:

  OUTREC OVERLAY=(15:X,1,6,ZD,DIV,+2,M11,LENGTH=6,X,                 
                 (8,6,ZD,MUL,+100),DIV,1,6,ZD,MUL,+100,EDIT=(TTT.TT))


to

Code:

  OUTREC OVERLAY=(15:X,1,6,ZD,DIV,+2,M11,LENGTH=6,X,         
               (8,6,ZD,MUL,+10000),DIV,1,6,ZD,EDIT=(TTT.TT))



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group