Description
Method to run the ERS processor from within the Batch processor.
Parameters
icParam | input | character | Input parameter character string: all the values required to run the ERS Processor are stored in this string using the '|' character as the delimiting value. |
tERSProcessorLogRef | output | temp-table | |
tERSProcessorRef | output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bersprocessor.p)
/* =================================================================================================== */
/* Method : ERSProcessBatch */
/* Desc : Run ERS Processor from Batch processor. Input parameters are passed as pipe separated */
/* strings */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (I) Params List of parameters */
/* =================================================================================================== */
assign oiReturnStatus = -98
viLocalReturn = 0.
/* =================================================================================================== */
/* Normalize input parameters */
/* =================================================================================================== */
if icParam = '':U then assign icParam = ?.
/* =================================================================================================== */
/* Validate input parameters */
/* =================================================================================================== */
if icParam = ?
then do:
assign vcMessage = #T-1'You have not entered all the mandatory values.':255(63250)t-1#
vcContext = 'icParam=&1':U
vcContext = replace(vcContext, '|':U, chr(2))
vcContext = substitute(vcContext, icParam).
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8508':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
assign oiReturnStatus = -1.
return.
end.
/* =================================================================================================== */
/* Extract values of parameters */
/* =================================================================================================== */
assign vlIsCreateCIAndAPMatching = logical(entry(1, icParam, '|':U))
vlIsPrintAuditReport = logical(entry(2, icParam, '|':U))
vlIsRecalculateTaxes = logical(entry(3, icParam, '|':U))
vcSupplierFrom = entry(4, icParam, '|':U)
vcSupplierTo = entry(5, icParam, '|':U)
vcSiteFrom = entry(6, icParam, '|':U)
vcSiteTo = entry(7, icParam, '|':U)
vcReceiverFrom = entry(8, icParam, '|':U)
vcReceiverTo = entry(9, icParam, '|':U)
vcParamItem = entry(10, icParam, '|':U)
vcGroupBy = entry(16, icParam, '|':U)
vcLegalDocumentFrom = entry(12, icParam, '|':U)
vcLegalDocumentTo = entry(13, icParam, '|':U)
vcEffectiveIssueDateFrom = entry(14, icParam, '|':U)
vcEffectiveIssueDateTo = entry(15, icParam, '|':U)
vtReceiptDateFrom = (if vcParamItem = '?':U then ? else date(vcParamItem))
vcParamItem = entry(11, icParam, '|':U)
vtReceiptDateTo = (if vcParamItem = '?':U then ? else date(vcParamItem))
vtEffectiveIssueDateFrom = (if vcEffectiveIssueDateFrom = '?':U then ? else date(vcEffectiveIssueDateFrom))
vtEffectiveIssueDateTo = (if vcEffectiveIssueDateTo = '?':U then ? else date(vcEffectiveIssueDateTo)).
/* =================================================================================================== */
/* Set the vcGroupBy correctly */
/* =================================================================================================== */
if vcGroupBy = ? or vcGroupBy = ''
then do:
<Q-90 run POAccountingControlByDomainV01 (all) (Read) (NoCache)
(input vcDomainCode, (Domain)
output dataset tqPOAccountingControlByDomainV01) in BMfgPOAccountingControl>
find first tqPOAccountingControlByDomainV01 where
tqPOAccountingControlByDomainV01.tcpoc_domain = vcDomainCode
no-error.
assign vcGroupBy = if available tqPOAccountingControlByDomainV01 and tqPOAccountingControlByDomainV01.tlpoc_fiscal_confirm
then {&ERSPROCESSORINVGROUP-LEGALDOC}
else {&ERSPROCESSORINVGROUP-RECEIVER}.
end. /* if vcGroupBy = ? or vcGroupBy = '' */
/* =================================================================================================== */
/* Get receipts which fits input parameters */
/* =================================================================================================== */
empty temp-table tERSProcessorRef.
empty temp-table tERSProcessorLogRef.
<M-12 run GetERSPendingVouchers
(input vcGroupBy (icSearchBy),
input vcSupplierFrom (icSupplierFrom),
input vcSupplierTo (icSupplierTo),
input vcLegalDocumentFrom (icLegalDocumentFrom),
input vcLegalDocumentTo (icLegalDocumentTo),
input vcSiteFrom (icSiteFrom),
input vcSiteTo (icSiteTo),
input vcReceiverFrom (icReceiverFrom),
input vcReceiverTo (icReceiverTo),
input vtReceiptDateFrom (itReceiptDateFrom),
input vtReceiptDateTo (itReceiptDateTo),
input vtEffectiveIssueDateFrom (itEffIssueDateFrom),
input vtEffectiveIssueDateTo (itEffIssueDateTo),
output tERSProcessorRef (tERSProcessorRef),
output tERSProcessorLogRef (tERSProcessorLogRef),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Is there any record to be processed? */
/* =================================================================================================== */
if not can-find(first tERSProcessorRef where
tERSProcessorRef.tlIsSelected = true and
tERSProcessorRef.tlIsProcessed = false and
(tERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_READY_0} or
tERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_READY_1} or
tERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_ERROR}) and
tERSProcessorRef.tiERSOpt <> 0 and
tERSProcessorRef.tiERSOpt <> 1)
then do:
assign vcMessage = #T-65'No waiting receipts processed by ERS Processor':255(432039891)T-65#.
<M-16 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-692964':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
assign oiReturnStatus = 1.
return.
end.
/* =================================================================================================== */
/* Does processing execution */
/* =================================================================================================== */
<M-45 run ERSProcessInit
(input vcGroupBy (icGroupBy),
input vlIsCreateCIAndAPMatching (ilIsCreateCIAndAPMatching),
input vlIsPrintAuditReport (ilIsPrintAuditReport),
input vlIsRecalculateTaxes (ilIsRecalculateTaxes),
input tERSProcessorRef (t_sERSProcessorRef),
output viDummy (ocBatchNumber),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
do while true:
<M-5 run ERSProcess
(output viDummy (oiNumberOfProcessedRecords),
output vlIsEndOfFile (olIsEndOfFile),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave.
if vlIsEndOfFile
then leave.
end.
<M-6 run ERSProcessFinish
(output tERSProcessorRef (tERSProcessorRef),
output tERSProcessorLogRef (tERSProcessorLogRef),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper < 0 or
viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
/* ====================================================================== */
/* Overtake the result of the execution */
/* ====================================================================== */
for each tERSProcessorLogRef:
create tFcMessages.
buffer-copy tERSProcessorLogRef to tFcMessages.
end.
if can-find (first tERSProcessorLogRef where
tERSProcessorLogRef.tcFcType = "E":U or
tERSProcessorLogRef.tcFcType = "S":U)
then assign viLocalReturn = -1.
else if can-find (first tERSProcessorLogRef where
tERSProcessorLogRef.tcFcType = "W":U) and
viLocalReturn = 0
then assign viLocalReturn = 1.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
assign oiReturnStatus = viLocalReturn.