ANOTHER IT CO

List Jobs Using a Hash Table

program searchhash
*
***********************************************************
* Copyright 2001 Another IT Co, Chuck Smith
*
* Permission to use this software is conditional upon you
* agreeing to the disclaimer and license terms.  By installing
* or using the software you consent to be bound by and become
* party to this agreement.
* 
* Chuck Smith ("developer") hereby grants you ("user") a 
* non-exclusive personal license to use this software subject 
* to the following disclaimer, terms and conditions:
* 
* user agrees not to distribute, reproduce, transmit or
* transfer, in whole or in part, the software or its
* documentation without express written permission
* from the developer.
* 
* DISCLAIMER: This software is provided on an "as-is"
* basis without warranty of any kind.
* 
* Developer specifically disclaims any other warranty,
* express or implied, including any warrent of 
* merchantability or fitness for a particular purpose.
* In no event shall developer be liable for any 
* consequential, indirect, special or incidental damages,
* even if developer has been advised by user of the 
* possibility of such potential loss or damage.  User 
* agrees to hold developer harmless from and against any
* and all claims, losses, liabilities and expenses.
***********************************************************
*
true = 1
false = 0
*
prompt ''
bop:
crt 'Enter the name of the hash file to find: ':
input findhashfile
if trim(findhashfile) = '' then goto eop:
findhashfile = upcase(trim(findhashfile))
*
open '','DS_JOBS' to DSJOBS then
  *
  clearselect 2
  * select DSJOBS
  execute 'SELECT DS_JOBS BY NAME NO.PAGE TO 2'
  *
  eof = false
  loop
    readnext onejob from 2 else eof = true
  until eof = true
    *
    * crt 'Processing job: ':trim(onejob)
    read onejobrec from DSJOBS,onejob then
      *
      onejobnumber = onejobrec<5>
      * crt space(2):'Processing job number: ':onejobnumber
      jobfile = 'DS_JOB':onejobnumber
      *
      open '',jobfile to DSJOB then
        *
        gosub processhash:
        *
        close DSJOB
      end else
        * crt 'Unable to open ':jobfile:' for job ':onejob:'.'
        * crt
      end
      *
    end else
      * crt 'Can not read DS_JOBS record for ':onejob:'.'
      * crt
    end
    *
  repeat
  *
  close DSJOBS
end else
  crt 'Unable to open DS_JOBS.'
  goto eop:
end
*
eop:
crt 'Done.'
stop
*************************************************************
processhash:


  tablemap = ''
  * tablemap<1> ==> job name
  * tablemap<2,n> = stage name
  * tablemap<3,n> = hashed file name
  * tablemap<4,n,m> = column name
  * tablemap<5,n> = link name


  tablemap<1> = onejob
  stagenumber = 0
  columnnumber = 0


  clearselect
  select DSJOB


  eof0 = false
  loop
    readnext objid else eof0 = true
  until eof0 = true
    *
    read object from DSJOB,objid then
     *
     if trim(object<2>) = 'CHashedFileStage' then
       *
       stagename = object<3>
       *
       inputlinks = trim(object<6>)
       numberofinputlinks = dcount(inputlinks,'|')
       outputlinks = trim(object<7>)
       numberofoutputlinks = dcount(outputlinks,'|')
       if numberofoutputlinks > 0 then
          gosub outputlinkroutine:
       end
       if numberofinputlinks > 0 and numberofoutputlinks = 0 then
          gosub inputlinkroutine:
       end
     end
     *
    end else
      crt 'Can not read object id: ':objid:'.'
    end
    *
  repeat


  gosub searchtablemap:


  return


*************************************************************
outputlinkroutine:


       outputlinks = trim(object<7>)
       numberofoutputlinks = dcount(outputlinks,'|')
       for k = 1 to numberofoutputlinks
         stagenumber += 1
         tablemap<2,stagenumber> = stagename
         outputlink = trim(field(outputlinks,'|',k))
         if trim(outputlink) = '' then
           tablemap<2,stagenumber> = stagename:' has no output link.'
           * crt 'Stage ':stagename:' has a null output link.'
         end else
           read outputlinkobject from DSJOB,outputlink then
             tablemap<5,stagenumber> = trim(outputlinkobject<3>)
             hashfilename = outputlinkobject<6>
             tablemap<3,stagenumber> = hashfilename
             numberofcolumns = field(outputlinkobject<13,1>,'/',2)
             for i = 1 to numberofcolumns
               tablemap<4,stagenumber,i> = outputlinkobject<14,i>
             next i
           end else
             crt 'Can not read output link object ':outputlink:'.'
           end
         end
       next k
  return



*************************************************************
inputlinkroutine:


       inputlinks = trim(object<6>)
       numberofinputlinks = dcount(inputlinks,'|')
       for p = 1 to numberofinputlinks
         stagenumber += 1
         tablemap<2,stagenumber> = stagename
         inputlink = trim(field(inputlinks,'|',p))
         if trim(inputlink) = '' then
           tablemap<2,stagenumber> = stagename:' has no input link.'
           * crt 'Stage ':stagename:' has a null output link.'
         end else
           read inputlinkobject from DSJOB,inputlink then
             tablemap<5,stagenumber> = trim(inputlinkobject<3>)
             hashfilename = inputlinkobject<6>
            * crt 'Hash file name: ':hashfilename
             tablemap<3,stagenumber> = hashfilename
             translinks = trim(inputlinkobject<5>)
             numberoftranslinks = dcount(translinks, '|')
            *  crt 'Trans links: ':translinks
            *  crt 'No of trans link: ':numberoftranslinks
             *
             *
             for m = 1 to numberoftranslinks
               translink = trim(field(translinks,'|',m))
               read translinkobject from DSJOB,translink then
                 transoutputlinks = trim(translinkobject<7>)
                 numberoftransoutputlinks = dcount(transoutputlinks, '|')
            *     crt 'Trans output link: ':transoutputlinks
            *     crt 'No of trans output link: ':numberoftransoutputlinks
                 for n = 1 to numberoftransoutputlinks
                    transoutputlink = trim(field(transoutputlinks,'|',n))
                    read transoutputlinkobj from DSJOB,transoutputlink then 
                    numberofcolumns = field(transoutputlinkobj<13,1>,'/',2)
            *        crt 'Number of columns: ':numberofcolumns
                    for i = 1 to numberofcolumns
                      tablemap<4,stagenumber,i> = transoutputlinkobj<14,i>
                    next i
                    end else
                      crt 'Can not read transoutputlink: ':transoutputlink:'.'
                    end
                 next n
               end else
                 crt 'Can not read translink: ':translink:'.'
               end
             next m
           end else
              crt 'Can not read inputlink: ':inputlink:'.'
           end
         end
       next p
  return

*************************************************************
searchtablemap:


  found = false


  for i = 1 to stagenumber
   if upcase(trim(tablemap<3,i>)) = findhashfile then
     found = true
   end
  next i


  if found = true then
    crt 'Job: ':trim(tablemap<1>)
  end


  return

*************************************************************
end

Copyright 2016 Another IT Co