bcCompanyCode | input-output | character | Company wherefor you want to do the rebuild (Optional) |
bcCreditorCode | input-output | character | Supplier wherefor you want to do the rebuild (Optional) - note that in case icCompanyCode was filled, the supplier shoudl exist for that company. |
bcCurrencyCode | input-output | character | Currency wherefor you want to do the rebuild (Optional) |
biFromPeriodYear | input-output | integer | Period-year from where you want to do the rebuild (Optional) - note that in case icCompanyCode was filled, the period should exist for that company. |
biFromPeriodPeriod | input-output | integer | Period-period from where you want to do the rebuild (Optional) Note that in case icCompanyCode was filled, the period should exist for that company. Note that this paramater can only be filled in case period-year was also filled |
oiResolvedCompanyID | output | integer | ResolvedCompanyID: Company-ID in case the CompanyCode is filled and it points to a valid company |
oiResolvedCreditorID | output | integer | CreditorID: only filled in case the icCompanyCode and icCreditorCode is filled |
oiResolvedCurrencyID | output | integer | ResolvedCurrencyID: CurrencyID only filled in case icCurrencyCode is filled |
oiReturnStatus | output | integer | Return status of the method. |
/* ================== */ /* Exception handling */ /* ================== */ assign oiReturnStatus = -98 viLocalReturnStatus = 0. /* ========================================================================================= */ /* Input parameter validations: */ /* - Company and currency should exist when filled */ /* - Supplier wherefor you want to do the rebuild (Optional) */ /* (note that in case icCompanyCode was filled, the supplier shoudl exist for that company) */ /* - Period-year from where you want to do the rebuild (Optional) */ /* (note that in case icCompanyCode was filled, the period should exist for that company) */ /* - Period-period from where you want to do the rebuild (Optional) */ /* (note that in case icCompanyCode was filled, the period should exist for that company) */ /* (note that this paramater can only be filled in case period-year was also filled) */ /* ========================================================================================= */ if bcCompanyCode = ? then assign bcCompanyCode = "":U. if bcCreditorCode = ? then assign bcCreditorCode = "":U. if bcCurrencyCode = ? then assign bcCurrencyCode = "":U. if biFromPeriodYear = ? then assign biFromPeriodYear = 0. if biFromPeriodPeriod = ? then assign biFromPeriodPeriod = 0. /* ======= */ /* Company */ /* ======= */ if bcCompanyCode <> "":U then do : <Q-2 run CompanyPrim (all) (Read) (NoCache) (input ?, (LookupCompanyId) input bcCompanyCode, (CompanyCode) output dataset tqCompanyPrim) in BCompany > Find tqCompanyPrim no-error. if not available tqCompanyPrim then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-3'The specified entity code (&1) is not defined in the system.':255(65582)T-3#,bcCompanyCode)). <M-4 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-7193':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCreditorBalance> end. /* if not available tqCompanyPrim */ else assign oiResolvedCompanyID = tqCompanyPrim.tiCompany_ID. end. /* if icCompanyCode <> "":U */ /* ========= */ /* Creditor */ /* ========= */ if bcCreditorCode <> "":U then do : assign vcMessage = "":U. if bcCompanyCode <> "":U and available tqCompanyPrim then do : <Q-9 run CreditorPrim (all) (Read) (NoCache) (input tqCompanyPrim.tiCompany_ID, (CompanyId) input ?, (CreditorId) input bcCreditorCode, (CreditorCode) output dataset tqCreditorPrim) in BCreditor > Find tqCreditorPrim no-error. /* no First-option as it should be unique */ if not available tqCreditorPrim then assign vcMessage = trim(substitute(#T-11'Invalid input: the combination of the supplier (&1) and the entity code (&2) cannot be found.':255(65587)T-11#,trim(bcCreditorCode),trim(bcCompanyCode))). else assign oiResolvedCreditorID = tqCreditorPrim.tiCreditor_ID. end. /* if bcCompanyCode <> "":U and */ else do : <Q-10 run CreditorPrim (all) (Read) (NoCache) (input ?, (CompanyId) input ?, (CreditorId) input bcCreditorCode, (CreditorCode) output dataset tqCreditorPrim) in BCreditor > Find first tqCreditorPrim no-error. /* First-option as it should not be unique */ if not available tqCreditorPrim then assign vcMessage = trim(substitute(#T-12'The specified supplier (&1) is not defined in the system.':255(65580)T-12#,trim(bcCreditorCode))). else do: find tqCreditorPrim no-error. /*no First-option as it should be unique*/ if available tqCreditorPrim then oiResolvedCreditorID = tqCreditorPrim.tiCreditor_ID. end. /*ELSE IF NOT AVAILABLE tqCreditorPrim*/ end. /* Not if bcCompanyCode <> "":U and */ if vcMessage <> "":U then do : assign viLocalReturnStatus = -1. <M-13 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-7196':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCreditorBalance> end. /* if vcMessage <> "":U */ end. /* if bcCreditorCode <> "":U */ /* ========= */ /* Currency */ /* ========= */ assign oiResolvedCurrencyID = 0. if bcCurrencyCode <> '':U then do : <Q-8 run CurrencyPrim (all) (Read) (NoCache) (input bcCurrencyCode, (CurrencyCode) input ?, (Currency_ID) output dataset tqCurrencyPrim) in BCurrency > Find tqCurrencyPrim where tqCurrencyPrim.tcCurrencyCode = bcCurrencyCode no-error. if not available tqCurrencyPrim then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-7'The specified currency code $1 is not defined in the system or is invalid.':100(3844)T-7#,bcCurrencyCode)). <M-6 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-7194':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCreditorBalance> end. /* if not available tqCompanyPrim */ else assign oiResolvedCurrencyID = tqCurrencyPrim.tiCurrency_ID. end. /* ============= */ /* Year - Period */ /* ============= */ if biFromPeriodPeriod <> 0 and biFromPeriodYear = 0 then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-16'You can only specify a GL period (&1) if the GL calendar year is also specified.':255(65583)T-16#,trim(string(biFromPeriodPeriod)))). <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-7197':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCreditorBalance> end. /* if biFromPeriodPeriod <> 0 and */ else do : if biFromPeriodYear <> 0 then do : assign vcMessage = "":U. if bcCompanyCode <> "":U and available tqCompanyPrim then do : <Q-22 run PeriodPrim (all) (Read) (NoCache) (input tqCompanyPrim.tiCompany_ID, (CompanyId) input ?, (PeriodId) input biFromPeriodYear, (PeriodYear) input biFromPeriodPeriod, (PeriodPeriod) output dataset tqPeriodPrim) in BPeriod > if biFromPeriodPeriod = 0 then do : Find first tqPeriodPrim no-error. if not available tqPeriodPrim then assign vcMessage = trim(substitute(#T-24'The specified combination of the year (&1) and the entity code (&2) is not defined in the system.':255(65589)T-24#,trim(string(biFromPeriodYear)),trim(bcCompanyCode))). end. /* if biFromPeriodPeriod = 0 */ else do : Find tqPeriodPrim no-error. /* no First-option as it should be unique */ if not available tqPeriodPrim then assign vcMessage = trim(substitute(#T-20'The combination of the year period (&1-&2) and the entity code (&3) is not defined in the system. ':255(65586)T-20#,trim(string(biFromPeriodYear)),trim(string(biFromPeriodPeriod)),trim(bcCompanyCode))). end. /* Not if biFromPeriodPeriod = 0 */ end. /* if bcCompanyCode <> "":U and */ else do : <Q-25 run PeriodPrim (all) (Read) (NoCache) (input ?, (CompanyId) input ?, (PeriodId) input biFromPeriodYear, (PeriodYear) input biFromPeriodPeriod, (PeriodPeriod) output dataset tqPeriodPrim) in BPeriod > Find first tqPeriodPrim no-error. if not available tqPeriodPrim then do : if biFromPeriodPeriod = 0 then assign vcMessage = trim(substitute(#T-26'The specified GL calendar year (&1) is not defined in the system.':255(65590)T-26#,trim(string(biFromPeriodYear)))). else assign vcMessage = trim(substitute(#T-28'The specified combination of the year and GL period (&1-&2) is not defined in the system.':255(65591)T-28#,trim(string(biFromPeriodYear)),trim(string(biFromPeriodPeriod)))). end. /* Not if biFromPeriodPeriod = 0 */ end. /* Not if bcCompanyCode <> "":U and */ if vcMessage <> "":U then do : assign viLocalReturnStatus = -1. <M-19 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-7198':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCreditorBalance> end. /* if vcMessage <> "":U */ end. /* if biFromPeriodYear <> 0 */ end. /* Not if biFromPeriodPeriod <> 0 and */ /* ================================================================= */ /* Raise an error in case there still are QCinvoiceMovement records */ /* Raise an error in case the daemon is running */ /* ================================================================= */ <Q-35 assign vlFcQueryRecordsAvailable = QCInvoiceMovementByAllFrgnKeys (NoCache) (input oiResolvedCompanyID, (CompanyId) input ?, (CostCentre_ID) input oiResolvedCreditorID, (Creditor_ID) input oiResolvedCurrencyID, (Currency_ID) input ?, (Division_ID) input ?, (GL_ID) input ?, (Journal_ID) input ?, (Period_ID) input ?, (Project_ID)) in BQCInvoiceMovement > if vlFcQueryRecordsAvailable <> false then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-31'Cannot start the rebuild. There are current queue records waiting to be processed by the daemon or queue records of incorrectly processed daemon requests.':255(65594)T-31#)). <M-30 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-7200':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCreditorBalance> end. /* if vlFcQueryRecordsAvailable <> false */ <Q-32 assign vlFcQueryRecordsAvailable = DaemonInfoLimited (NoCache) (input ?, (DaemonId) input {&BALANCEDAEMON}, (DaemonName) input ?, (DaemonStatus) input {&DAEMONSTATUS-INACTIVE}, (DaemonStatusDiffersFrom)) in BBaseDaemon > if vlFcQueryRecordsAvailable <> false then do : assign viLocalReturnStatus = -1 vcMessage = trim(substitute(#T-34'Cannot start the rebuild because the Balance daemon is still running. Stop the Balance daemon.':255(69264)T-34#)). <M-33 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-7202':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCreditorBalance> end. /* if vlFcQueryRecordsAvailable <> false */ /* ================== */ /* Exception handling */ /* ================== */ assign oiReturnStatus = viLocalReturnStatus.