ReadStatusFileRBA:

/* ***************************************************** *
 *  Snippet to maintain a file that contains             *
 *  the last processed RBA of a DB2 log.                 *
 *  For the actual processing the file is read           *
 *  and the saved RBA is used as START RBA for           *
 *  the current run. For the very first invocation       *
 *  the RBA to begin with is specified in the            *
 *  PROLOG and the file is created using this RBA        *
 *                                                       *
 *                                                       *
 *  Invocation in PROLOG                                 * 
 *  Statusfile = 'filename'                              *
 *  RBA        = '00000030F000'                          *
 *  rba_rc = ReadstatusFileRBA()                         *
 *                                                       *
 *  Example for file on Virtual Disk:                    *
 *  StatusFile = 'TVSMDSK:CONFIG:SCRIPTS/CURRENT.RBA.TXT'*
 *  Example for file as PDS Member                       *
 *  StatusFile = 'PRIV.PDS.CNTL(RBA)'                    *
 *  Example for file referenced by DD-statement          *
 *  StatusFile = '//DDN_PDSINPUT'                        *
 *  Invocation in EPILOG to save the last processed RBA  * 
 *                                                       * 
 *  rba_rc = WriteStatusFileRBA()                        * 
 *                                                       *
 *                                                       * 
 * ***************************************************** */
     
Call Stream StatusFile, 'C', 'OPEN READ'
IF Result <> 'READY:' THEN DO
  SAY result
  call Stream StatusFile, 'D'
  SAY result
  
  /* Ignore error "File not found" */
  
  IF INDEX(result, '0x0000532C') = 0 & INDEX(result, '0x22010002') = 0 & INDEX(result, '0x00130018')
  THEN DO
      SAY ' Unable to access RBA status file.' result
      RETURN 163
  END
END
ELSE DO
  InLine = LINEIN(StatusFile)
  IF LENGTH(InLine) = 0 THEN LEAVE
  IF INDEX(InLine, 'RBA=') > 0 THEN DO
    PARSE VALUE InLine WITH . 'RBA=' RBA
  END
  Call Stream StatusFile, 'C', 'CLOSE'
END

PM_I.DB2_Start_RBA = left(RBA,12)
SAY 'Set Start-RBA : ' PM_I.DB2_Start_RBA

RETURN 0

WriteStatusFileRBA:

Call Stream StatusFile, 'C', 'OPEN WRITE REPLACE'
IF Result <> 'READY:' THEN DO
   SAY result
   call Stream StatusFile, 'D'
   SAY result
   RETURN '12, Unable to write RBA Statusfile.' result
END
Call Lineout StatusFile, 'RBA='PM_O.DB2_End_RBA
Call Stream StatusFile, 'C', 'CLOSE'

RETURN 0



