project QadFinancials > class BERSProcessor > method ERSProcessFinish

Description

Finish processing of ERS processor


Parameters


tERSProcessorRefoutputtemp-table
tERSProcessorLogRefoutputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BERSProcessor.ERSProcessBatch


program code (program5/bersprocessor.p)

/* =================================================================================================== */
/* Method      : ERSProcessFinish                                                                      */
/* Desc        : Finish processing of selected receipts                                                */
/* --------------------------------------------------------------------------------------------------- */
/* Params:   (O) ERSProcessorRef             Selected list of receipt lines for ERS processor          */
/*           (O) ERSProcessorLogRef          All error details raised during processing of receipts    */
/* =================================================================================================== */

assign oiReturnStatus = -98.

/* =================================================================================================== */
/* Update existing ERS log file and Pending vouchaers with errors                                      */
/* =================================================================================================== */
/* Start transaction */
<I-2 {bFcStartAndOpenInstance
     &ADD-TO-TRANSACTION = "false"
     &CLASS              = "Transaction"}>        

<M-3 run StartTransaction  (output viFcReturnSuper (oiReturnStatus)) in Transaction>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper <  0 then return.
    
/* ========================================================================================================================= */
/* Normally we would here close the communication to class Transaction but we wont do it for performance reasons as this way */ 
/* the transaction does not have to be re-open when other instances are added to the transactionthe instance to commit it.   */
/* ========================================================================================================================= */

             

/* =================================================================================================== */
/* Update existing ERS record to store finish of Processing                                            */
/* =================================================================================================== */
assign viLocalReturn = 0.

<M-16 run ERSProcessFinishERS  (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper < 0 or
   viFcReturnSuper > 0 and viLocalReturn = 0 
then assign viLocalReturn = viFcReturnSuper.

if viLocalReturn >= 0
then do:
    <M-17 run ERSProcessFinishERSLine  (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
    if viFcReturnSuper < 0 or
       viFcReturnSuper > 0 and viLocalReturn = 0 
    then assign viLocalReturn = viFcReturnSuper.
end.

/* =================================================================================================== *
 * Update those receipt in database where errors were raised -> the are excluded from ers processing   *
 * next time                                                                                           *
 * =================================================================================================== */
if viLocalReturn >= 0
then do:
    <M-18 run ERSProcessFinishPvo  (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
    if viFcReturnSuper < 0 or
       viFcReturnSuper > 0 and viLocalReturn = 0 
    then assign viLocalReturn = viFcReturnSuper.
end.

/* =================================================================================================== */
/* Complete transaction                                                                                */
/* =================================================================================================== */
<I-8 {bFcOpenInstance
     &CLASS           = "Transaction"}>

if viLocalReturn >= 0
then do:
    <M-9 run CommitTransaction
       (input  true (ilStop), 
        input  ? (ihParentInstance), 
        output vcDummy (ocInstances), 
        output viFcReturnSuper (oiReturnStatus)) in Transaction>
    if viFcReturnSuper < 0 or
       viFcReturnSuper > 0 and viLocalReturn = 0 
    then assign viLocalReturn = viFcReturnSuper.
end.
else do:
    <M-10 run AbortTransaction
       (input  ? (ihParentInstance), 
        output vcDummy (ocInstances), 
        output viFcReturnSuper (oiReturnStatus)) in Transaction>
    if viFcReturnSuper < 0 or
       viFcReturnSuper > 0 and viLocalReturn = 0 
    then assign viLocalReturn = viFcReturnSuper.
end.

<I-11 {bFcCloseAndStopInstance
     &CLASS           = "Transaction"}>
     
/* =================================================================================================== *
 * If this is simulation, just set Processing status back to true                                      *
 * =================================================================================================== */
if vlIsCreateCIAndAPMatching <> true
then do:
    for each tERSProcessorRef:
        assign tERSProcessorRef.tlIsProcessed = false.
    end.
end.

/* =================================================================================================== */
/* Stop all started queries and instances                                                              */
/* =================================================================================================== */
<M-13 run StopAllQueries  (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper < 0 or
   viFcReturnSuper > 0 and viLocalReturn = 0 
then assign viLocalReturn = viFcReturnSuper.

<M-14 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper < 0 or
   viFcReturnSuper > 0 and viLocalReturn = 0 
then assign viLocalReturn = viFcReturnSuper.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
assign oiReturnStatus = viLocalReturn.