Search code examples
mainframedfsort

How to compare two totals from different datasets


We have three different file one is like that

File A

000001000
000002000
000003000 
000004000 

File B (After Summing of all Records in file A)

000010000

File C

     Total : - 10000

I have to compare the value in the File C and File B and if the value matches successfully I have to set the desired Return Code RC.

The starting position of the word "Total" is five.


Solution

  • I also find the solution of the problem using the JOINKEY.

    The code is given below.

    //STEP1  EXEC PGM=SORT,PARM=’NULLOUT=RC4′                     
    //SORTJNF1 DD DSN=FILEB                                   
    //SORTJNF2 DD DSN=FILEC                                   
    //SORTOUT  DD SYSOUT=*                           
    //SYSOUT   DD SYSOUT=*                           
    //SYSIN    DD *                                   
     JOINKEYS FILE=F1,FIELDS=(1,9,A) 
     JOINKEYS FILE=F2,FIELDS=(5,9,a) 
     REFORMAT FIELDS=(F1:1,80)                 
     OPTION COPY     
    /*              
    

    When the Match is success full it will return the RC=0 And

    When Match is not success full it will return the RC=4 as it is supplied using the PARM.

    Basically it search for the record in the output file (sortout) if Match successful the jcl sort utility will copy the record from fileB into the Output file(in spool) and if the unsuccessful match then the output file is empty and the with the help of PARM=’NULLOUT=RC4′ it return the RC=4.