project QadFinancials > class BCubeDaemonProcessor > method PerformWorkItem

Description

This is the method that contains the call to the specific method in the appropriate class to perform the request.
This method should be extended on the specific daemon level.
In order to have a proper logging of the errors/warnings you get from the business method that is used for processing the work, you need to fill in tPassMessages temp-table parameter, as a copy of tFcMessages from the called business component.


Parameters


iiDaemonQueueIdinputintegerID of the daemon queue record that indicates the work that needs to be done.
olSuccessoutputlogicalWas the operation successful?
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program/bcubedaemonprocessor.p)

<ANCESTOR-CODE>

assign olSuccess      = false
       oiReturnStatus = -98. 

/* ================================================= */
/* Find the QFRWCube_ID                           */
/* ================================================= */
<Q-31 run DaemonQueueByRefID (all) (Read) (NoCache)
   (input iiDaemonQueueId, (DaemonQueueID)
    input ?, (DaemonQueueRef)
    input '', (DaemonName)
    output dataset tqDaemonQueueByRefID) in BBaseDaemonQueue>
find tqDaemonQueueByRefID where
     tqDaemonQueueByRefID.tiDaemonQueueId = iiDaemonQueueId
     no-lock no-error.
if not available tqDaemonQueueByRefID
then do:
    assign vcCubeDaemonProcessorMsg = trim(#T-6'Daemon queue record not found.':100(262)T-6#) + chr(10) +
                                         trim(substitute('DaemonQueueID = &1.':U, trim(string(iiDaemonQueueId))))
           oiReturnStatus = -3.
    <M-66 run SetMessage
       (input  vcCubeDaemonProcessorMsg (icMessage), 
        input  '':U (icArguments), 
        input  '':u (icFieldName), 
        input  string(iiDaemonQueueId) (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-571748':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCubeDaemonProcessor>       
    return.                 
end.

/* ================================================================== */
/* Checking if tqDaemonQueueByRefID.tcDaemonQueueRef has a valid value, */
/* ================================================================== */
if integer(tqDaemonQueueByRefID.tcDaemonQueueRef) = 0 or
   integer(tqDaemonQueueByRefID.tcDaemonQueueRef) = ?
then do:
     assign vcCubeDaemonProcessorMsg = trim(#T-26'Internal Cube daemon error: cannot state the QFRWCube ID based on the queue information':249(821178848)T-26#) + chr(10) +
                                         trim(substitute("Queue-information = &1.":U, trim(tqDaemonQueueByRefID.tcDaemonQueueRef))) + chr(10) + 
                                         trim(substitute("Error-details = &1.":U, trim(ERROR-STATUS:GET-MESSAGE(1))))                
           oiReturnStatus              = -3.
    <M-19 run SetMessage
       (input  vcCubeDaemonProcessorMsg (icMessage), 
        input  '':U (icArguments), 
        input  '':u (icFieldName), 
        input  string(iiDaemonQueueId) (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-884892':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCubeDaemonProcessor>       
    return. 
end.


/* ================================================================================================================= */
/* Process and delete the QFRWCube record. This is done using a Wrapper method which calls a plain progress program  */
/* ================================================================================================================= */
<M-97 run ProcessAndDeleteQFRWCubeDIRECT
   (input  integer(tqDaemonQueueByRefID.tcDaemonQueueRef) (iiFRWCube_ID), 
    output vcErrorMsg (ocErrorMsg), 
    output vcWarningMsg (ocWarningMsg), 
    output viFcReturnSuper (oiReturnStatus)) in BCubeDaemonProcessor>


/* ===============================================================================================*/
/* The processing of the Cube daemon has it own logging mechanism to keep track of errors         */
/* These are stored in FRWBuildLog                                                                */
/* So as a consequence, the ProcessAndDeleteQFRWCubeDIRECT will only return a viFcReturnSuper < 0 */
/* in very limited technical cases                                                                */
/* In case of a technical error we flag this as an error                                          */
/* In this case the Q-record is not removed and the fcDaemonQueueStatis is set to Processed-Error */
/* ===============================================================================================*/
if viFcReturnSuper < 0
then do:
    assign oiReturnStatus           = viFcReturnSuper
           olSuccess                = false.
    if vcWarningMsg <> "":U and vcWarningMsg <> ?
    then do:
        <M-42 run SetMessage
           (input  vcWarningMsg (icMessage), 
            input  '':U (icArguments), 
            input  '':u (icFieldName), 
            input  string(iiDaemonQueueId) (icFieldValue), 
            input  'W':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-548843':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCubeDaemonProcessor>
    end.
    <M-45 run SetMessage
       (input  vcErrorMsg (icMessage), 
        input  '':U (icArguments), 
        input  '':u (icFieldName), 
        input  string(iiDaemonQueueId) (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-224220':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCubeDaemonProcessor>  
    return.    
end.
else do:
     /* =================================================================================== */
     /* In all other cases, the processing of the daemon queueu is considered as successful */
     /* =================================================================================== */
     assign oiReturnStatus = 0
            olSuccess      = true.
end.