project QadFinancials > class BERSProcessor > method ERSProcessCreateBatchRequest

Description

Method that creates a batch request to run the ERS processor with a supplier set of parameters.


Parameters


ilIsCreateCIAndAPMatchinginputlogical
ilIsPrintAuditReportinputlogicalLogical parameter: should an audit report be printed?
ilIsRecalculateTaxesinputlogicalLogical parameter: should taxes be re-calculated?
icBatchCodeinputcharacterBatch Code to be used for the scheduled batch request.
icSupplierFrominputcharacterFiltering parameter: start value for the supplier codes.
icSupplierToinputcharacterFiltering parameter: end value for the supplier codes.
icSiteFrominputcharacterFiltering parameter: start value for the site codes.
icSiteToinputcharacterFiltering parameter: end value for the site codes.
icReceiverFrominputcharacterFiltering parameter: start value for the receiver numbers.
icReceiverToinputcharacterFiltering parameter: end value for the receiver numbers.
itReceiptDateFrominputdateFiltering parameter: beginning date for the receipt dates.
itReceiptDateToinputdateFiltering parameter: ending date for the receipt dates.
icLegalDocumentFrominputcharacterFiltering parameter: start value for the legal document numbers.
icLegalDocumentToinputcharacterFiltering parameter: end value for the legal document numbers.
itEffectiveIssueDateFrominputdateFiltering parameter: beginning date for the effective issue dates.
itEffectiveIssueDateToinputdateFiltering parameter: ending date for the effective issue dates.
icSearchByinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program5/bersprocessor.p)

/* =================================================================================================== */
/* Method      : ERSProcessInitBatchRequest                                                            */
/* Desc        : Create new request for batch processor to execute ERS processor                       */
/* --------------------------------------------------------------------------------------------------- */
/* Params:   (I) IsCreateCIAndAPMatching     Create supplier invoice and receiver matching             */
/*           (I) IsPrintAuditReport          Print audit report                                        */
/*           (I) IsRecalculateTaxes          Recalculate taxes if needed (for APMatchingLn)            */
/*           (I) BatchCode                   Code of batch to be executed                              */
/*           (I) SupplierFrom                Batch Filter - Supplier from                              */
/*           (I) SupplierTo                  Batch Filter - Supplier To                                */
/*           (I) SiteFrom                    Batch Filter - Site From                                  */
/*           (I) SiteTo                      Batch Filter - Site To                                    */
/*           (I) ReceiverFrom                Batch Filter - Receiver From                              */
/*           (I) ReceiverTo                  Batch Filter - Receiver To                                */
/*           (I) ReceiptDateFrom             Batch Filter - Receipt Date From                          */
/*           (I) ReceiptDateTo               Batch Filter - Receipt Date To                            */
/*           (I) LegalDocumentFrom           Batch Filter - Legal Docuemnt From                        */
/*           (I) LegalDocumentTo             Batch Filter - Legal Document To                          */
/*           (I) EffectiveIssueDateFrom      Batch Filter - Effective Issue Date From                  */
/*           (I) EffectiveIssueDateTo        Batch Filter - Effective Issue Date To                    */
/*           (I) SearchBy                    Option to define whether search by Receivers/Legaldocuments*/
/* =================================================================================================== */

assign oiReturnStatus = -98.

/* =================================================================================================== */
/* Validate parameters                                                                                 */
/* =================================================================================================== */
if icBatchCode = '':U or
   icBatchCode = ?
then do:
    assign vcMessage = #T-14'To run ERS Processor using batch processing, Batch ID has to be entered.':255(70941)T-14#.
    <M-15 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-8517':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
    assign oiReturnStatus = -1.
    return.
end.

/* =================================================================================================== */
/* if icSearchBy is not populated, just assign it based on the setting                                 */
/* =================================================================================================== */
if icSearchBy = ? or icSearchBy = ''
then do:

    <Q-57 run POAccountingControlByDomainV01 (all) (Read) (NoCache)
       (input vcDomainCode, (Domain)
        output dataset tqPOAccountingControlByDomainV01) in BMfgPOAccountingControl>
    find first tqPOAccountingControlByDomainV01 where
               tqPOAccountingControlByDomainV01.tcpoc_domain = vcDomainCode
               no-error.
    assign icSearchBy = if available tqPOAccountingControlByDomainV01 and tqPOAccountingControlByDomainV01.tlpoc_fiscal_confirm
                        then {&ERSPROCESSORINVGROUP-LEGALDOC}
                        else {&ERSPROCESSORINVGROUP-RECEIVER}.

end. /* if icSearchBy = ? or icSearchBy = '' */

/* =================================================================================================== */
/* Create list of parameters which will be used for ERS processor from Batch processor                 */
/* =================================================================================================== */
if ilIsCreateCIAndAPMatching = ? then assign ilIsCreateCIAndAPMatching = false.
if ilIsPrintAuditReport      = ? then assign ilIsPrintAuditReport      = false.
if ilIsRecalculateTaxes      = ? then assign ilIsRecalculateTaxes      = false.
if icSupplierFrom            = ? then assign icSupplierFrom            = '':U.
if icSupplierTo              = ? then assign icSupplierTo              = '':U.
if icSiteFrom                = ? then assign icSiteFrom                = '':U.
if icSiteTo                  = ? then assign icSiteTo                  = '':U.
if icReceiverFrom            = ? then assign icReceiverFrom            = '':U.
if icReceiverTo              = ? then assign icReceiverTo              = '':U.

assign vcParams = string(ilIsCreateCIAndAPMatching)                                                  + "|":U +    /* index 1 */
                  string(ilIsPrintAuditReport)                                                       + "|":U +    /* index 2 */
                  string(ilIsRecalculateTaxes)                                                       + "|":U +    /* index 3 */
                  icSupplierFrom                                                                     + "|":U +    /* index 4 */
                  icSupplierTo                                                                       + "|":U +    /* index 5 */
                  icSiteFrom                                                                         + "|":U +    /* index 6 */
                  icSiteTo                                                                           + "|":U +    /* index 7 */
                  icReceiverFrom                                                                     + "|":U +    /* index 8 */
                  icReceiverTo                                                                       + "|":U +    /* index 9 */ 
                  (if itReceiptDateFrom = ? then '?':U else string(itReceiptDateFrom))               + "|":U +    /* index 10 */
                  (if itReceiptDateTo   = ? then '?':U else string(itReceiptDateTo))                 + "|":U +    /* index 11 */
                  icLegalDocumentFrom                                                                + "|":U +    /* index 12 */
                  icLegalDocumentTo                                                                  + "|":U +    /* index 13 */ 
                  (if itEffectiveIssueDateFrom = ? then '?':U else string(itEffectiveIssueDateFrom)) + "|":U +    /* index 14 */
                  (if itEffectiveIssueDateTo   = ? then '?':U else string(itEffectiveIssueDateTo))   + "|":U +    /* index 15 */
                  (if icSearchBy = ? then '?':U else string(icSearchBy)).                                         /* index 16 */
                  


/* =================================================================================================== */
/* Create new batch processor request                                                                  */
/* =================================================================================================== */
/* 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.   */
/* ========================================================================================================================= */

             
/* Open instance of BERS component */        
assign viLocalReturn = 0.
BATCHDETAILBlock:
do:
    <I-5 {bFcStartAndOpenInstance
         &ADD-TO-TRANSACTION = "true"
         &CLASS              = "BMfgBatchControlDetail"}>        
                 
    <M-12 run AddBatchControlDetail
       (input  icBatchCode (icBatchCode), 
        input  'urn:cbf:BERSProcessor.Process':U (icExec), 
        input  ? (icDestination), 
        input  vcParams (icParams), 
        output viFcReturnSuper (oiReturnStatus)) in BMfgBatchControlDetail>
    if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
    if viFcReturnSuper <  0 then leave BATCHDETAILBlock.

    <M-13 run ValidateBCAndAdditionalUpdates  (output viFcReturnSuper (oiReturnStatus)) in BMfgBatchControlDetail>
    if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
    if viFcReturnSuper <  0 then leave BATCHDETAILBlock.
end. /* of BATCHDETAILBlock */

/* 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 then assign oiReturnStatus = viFcReturnSuper.
end.
else do:
    <M-10 run AbortTransaction
       (input  ? (ihParentInstance), 
        output vcDummy (ocInstances), 
        output viFcReturnSuper (oiReturnStatus)) in Transaction>
    if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
end.

<I-11 {bFcCloseAndStopInstance
     &CLASS           = "Transaction"}>
     
if viLocalReturn < 0
then assign oiReturnStatus = viLocalReturn.
else if viLocalReturn > 0 and oiReturnStatus = -98
     then assign oiReturnStatus = viLocalReturn.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.