icCompanyCode | input | character | CompanyCode: Mandatory. This should be the current company |
icJournalCode | input | character | JornalCode: Mandatory. The type of this journal should be Periodic-costing and it should be in a management or official layer |
iiPostingYear | input | integer | PostingYear: Mandatory. accounting-year format 9999 |
iiPostingPeriod | input | integer | PostingPeriod: Mandatory. accounting-period format 99 |
ilOnlyReverseUnreversedOnes | input | logical | OnlyReverseUnreversedOnes: Pass true in case you only want to reverse postings that have not yet been reversed or that are no reversals of other postings. Pass false in case you just want to reverse all postings matching the filter regardless their reversal-properties |
ilReversalByCorrection | input | logical | ReversalByCorrection; Pass true in case debit of the reversal posting should be the credit of the reversed posting (and vice versa) Pass true in case debit and credit of the reversal posting should be the same as the debit and credit of the reversed posting but multiplied by -1 |
tApiPeriodicCostingPostings | output | temp-table | Output temp-table holding the main references on the postings that are reversed by this method. |
oiReturnStatus | output | integer | Return status of the method. |
/* =============================== */ /* Exception handling - main block */ /* Empty output table */ /* =============================== */ empty temp-table tApiPeriodicCostingPostings. assign oiReturnStatus = -98 viLocalReturnStatus = 0. MAINPCREVERSALBLOCK: DO : /* ================================================================ */ /* Replace unknown values in the input parameters and then validate */ /* the input as stated in the descriptions of the parameters itself */ /* ================================================================ */ if icCompanyCode = "":U or icCompanyCode = ? or icJournalCode = "":U or icJournalCode = ? or iiPostingYear = 0 or iiPostingYear = ? or iiPostingPeriod = 0 or iiPostingPeriod = ? then do : assign vcMessage = trim(substitute(#T-33'The entity (&1), daybook (&2), year (&3) and period (&4) are all mandatory parameters for the API method.':255(73479107)T-33#,icCompanyCode,icJournalCode,iiPostingYear,iiPostingPeriod)) viLocalReturnStatus = -3. <M-23 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-9777':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCREVERSALBLOCK. end. /* if icCompanyCode = "":U or */ if ilOnlyReverseUnreversedOnes = ? or ilReversalByCorrection = ? then do : assign vcMessage = trim(substitute(#T-37'The indication if reversed-postings should be handled or not (&1) and the indication if the reversal should be a correction or not (&2) are mandatory parameters for the API method.':255(733748697)T-37#,ilOnlyReverseUnreversedOnes, ilReversalByCorrection)) viLocalReturnStatus = -3. <M-36 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-9779':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCREVERSALBLOCK. end. /* if ilOnlyReverseUnreversedOnes = ? or */ if icCompanyCode <> vcCompanyCode /* removing this check would alos mean you have to check the complete method on using viCompanyID and vcCompanyCode */ then do : assign vcMessage = trim(substitute(#T-34'The entity (&1) passed as input to API method must be the current entity (&2).':255(413971746)T-34#,icCompanyCode,vcCompanyCode)) viLocalReturnStatus = -3. <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-9775':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCREVERSALBLOCK. end. /* if icCompanyCode <> vcCompanyCode */ assign vcMessage = "":U. <Q-20 run JournalByJournalCodeWithLayer (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input icJournalCode, (JournalCode) output dataset tqJournalByJournalCodeWithLayer) in BJournal > Find first tqJournalByJournalCodeWithLayer where tqJournalByJournalCodeWithLayer.tcJournalCode = icJournalCode no-lock no-error. if not available tqJournalByJournalCodeWithLayer then assign vcMessage = trim(substitute(#T-29'The daybook (&1) passed as input to the API method cannot be found.':255(591295504)T-29#,icJournalCode)). if vcMessage = "":U and available tqJournalByJournalCodeWithLayer and tqJournalByJournalCodeWithLayer.tlJournalIsActive <> true then assign vcMessage = trim(substitute(#T-30'The daybook (&1) passed as input to the API method is not active.':255(332075615)T-30#,icJournalCode)). if vcMessage = "":U and available tqJournalByJournalCodeWithLayer and tqJournalByJournalCodeWithLayer.tcJournalTypeCode <> {&JOURNALTYPE-PERIODICCOSTING} then assign vcMessage = trim(substitute(#T-31'The daybook (&1) passed as input to the API method has daybook type &2. The daybook type must be &3.':255(227658115)T-31#,icJournalCode,tqJournalByJournalCodeWithLayer.tcJournalTypeCode,{&JOURNALTYPE-PERIODICCOSTING-TR})). if vcMessage = "":U and available tqJournalByJournalCodeWithLayer and tqJournalByJournalCodeWithLayer.tcLayerTypeCode <> {&LAYERTYPECODE-OFFICIAL} and tqJournalByJournalCodeWithLayer.tcLayerTypeCode <> {&LAYERTYPECODE-MANAGEMENT} then assign vcMessage = trim(substitute(#T-32'The daybook (&1) passed as input to the API method is not defined in the official or management layer.':255(413970555)T-32#,icJournalCode,tqJournalByJournalCodeWithLayer.tcLayerTypeCode,{&LAYERTYPECODE-TRANSIENT-TR})). if vcMessage <> "":U then do : assign viLocalReturnStatus = -3. <M-21 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-9776':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCREVERSALBLOCK. end. /* if vcMessage <> "":U */ /* ================================================================ */ /* Run a ClearData to make sure we start from scratch */ /* ================================================================ */ <M-22 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCREVERSALBLOCK. /* ================================================================ */ /* Call DataLoad with a free-form that looks like this: ? */ /* for each Posting where Posting.Company_ID = viCompanyID and */ /* Posting.PostingYear = iiPostingYear and */ /* Posting.PostingPeriod = iiPostingPeriod and */ /* Posting.Journal_ID = viJournalCode */ /* Note the journal can be found in tqJournalByJournalCodeWithLayer */ /* If no postings were loaded then just raise a warning and leave */ /* ================================================================ */ assign vcFreeForm = "For each Posting where ":U + "Posting.Company_ID = ":U + string(viCompanyID) + " and ":U + "Posting.PostingYear = ":U + string(iiPostingYear) + " and ":U + "Posting.PostingPeriod = ":U + string(iiPostingPeriod) + " and ":U + "Posting.Journal_ID = ":U + string(tqJournalByJournalCodeWithLayer.tiJournal_ID). /* =============================================================================== */ /* In case ilOnlyReverseUnreversedOnes=true the extend the condition to make sure */ /* we don't load the postings that are a just a reversal of another posting. */ /* Note that we will still load the postings that have already been reversed: they */ /* need to be taken out by another condition later on the method as we can't check */ /* in a posting itself whether it has already been reversed or not */ /* =============================================================================== */ if ilOnlyReverseUnreversedOnes = true then assign vcFreeForm = vcFreeForm + " and Posting.PostingIsReversing = false ":U + " and (Posting.PostingOriginatorReference = '':U or Posting.PostingOriginatorReference = ?)":U. <M-24 run DataLoad (input '':U (icRowids), input '':U (icPkeys), input '':U (icObjectIds), input vcFreeForm (icFreeform), input false (ilKeepPrevious), output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 and viFcReturnSuper <> -4 /* -4 means no data was read and in this case this is captured in this method itself */ then assign viLocalReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 and viFcReturnSuper <> -4 /* -4 means no data was read and in this case this is captured in this method itself */ then Leave MAINPCREVERSALBLOCK. If not can-find (first tPosting) /* This cover return -4 from DataLoad-method */ then do : /* Here we raise a warning but we still leave the block as there is no any more actions to take */ assign viLocalReturnStatus = +1 vcMessage = trim(substitute(#T-35'No postings were found that matched entity (&1), daybook (&2), year (&3), and period (&4). No postings were deleted, and no further action can be taken.':255(733738028)T-35#, icCompanyCode,icJournalCode,iiPostingYear,iiPostingPeriod)). <M-25 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-9778':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCREVERSALBLOCK. end. /* If not can-find (first tPosting) */ /* =============================================================================== */ /* Load also counter part of mirroring posting, which was created as part of the */ /* Periodic costing with activated Mirroring accounting */ /* =============================================================================== */ <M-12 run DataLoadMirrorPosting (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then leave MAINPCREVERSALBLOCK. /* =============================================================================== */ /* In case ilOnlyReverseUnreversedOnes=true then we didn't load the postings that */ /* are a just a reversal of another posting. */ /* However; we now need to take out the postings that have already been reversed: */ /* they need to be taken here as we couldn't skip them to be loaded as a posting */ /* itself doesn't hold an indication whether it has already been reversed or not. */ /* Go through all loaded postings and remove the ones that are alreadey reversed. */ /* Raise warning and leave in case there are no postings left anymore */ /* =============================================================================== */ if ilOnlyReverseUnreversedOnes = true then do : /* Start a query that is used repetitively in the loop below */ <Q-43 run PostingByReverseOriginatorRef (Start) in BPosting > for each tPosting: /* Get the PostingOriginatorReference to look for in other postings */ assign vcPostingOriginatorReference = trim(string(tPosting.PostingYear)) + "/":U + trim(string(tPosting.tcJournalCode)) + "/":U + trim(string(tPosting.PostingVoucher,"999999999":U)). /* Look into the db for another posting with such PostingOriginatorReference - if found then delete the current tposting as we don't need it anymore in this method */ /* No need to look into our business-instance as we did not loaded any postngs with PostingOriginatorReference filled */ <Q-40 run PostingByReverseOriginatorRef (all) (Read) (NoCache) (input tPosting.Company_ID, (CompanyId) input vcPostingOriginatorReference, (PostingOriginatorReference) input ?, (PostingIsReplacement) input true, (PostingIsReversing) input tPosting.tc_Rowid, (SkipRowid) output dataset tqPostingByReverseOriginatorRef) in BPosting > if can-find (first tqPostingByReverseOriginatorRef where tqPostingByReverseOriginatorRef.tiCompany_ID = tPosting.Company_ID and tqPostingByReverseOriginatorRef.tlPostingIsReversing = true and tqPostingByReverseOriginatorRef.tcPostingOriginatorReference = vcPostingOriginatorReference) then do : /* Delete all detail lines of the posting before deleting the posting */ for each tPostingLine where tPostingLine.Posting_ID = tPosting.Posting_ID: delete tPostingLine. end. /* for each tPostingLine where */ for each tPostingSaf where tPostingSaf.Posting_ID = tPosting.Posting_ID: delete tPostingSaf. end. /* for each tPostingSaf where */ for each tPostingVat where tPostingVat.Posting_ID = tPosting.Posting_ID: delete tPostingVat. end. /* for each tPostingVat where */ for each tPostingWHT where tPostingWHT.Posting_ID = tPosting.Posting_ID: delete tPostingWHT. end. /* for each tPostingWHT where */ for each tPostingVatDelay where tPostingVatDelay.Posting_ID = tPosting.Posting_ID: delete tPostingVatDelay. end. /* for each tPostingVatDelay where */ delete tPosting. next. end. /* if can-find */ end. /* for each tPosting */ /* Stop a query that is used repetitively in the loop above*/ <Q-44 run PostingByReverseOriginatorRef (Stop) in BPosting > If not can-find (first tPosting) then do : /* Here we raise a warning but we still leave the block as there is no any more actions to take */ assign viLocalReturnStatus = +1 vcMessage = trim(substitute(#T-47'No postings were found that matched entity (&1), daybook (&2), year (&3), and period (&4). No postings were deleted, and no further action can be taken.':255(733738028)T-47#, icCompanyCode,icJournalCode,iiPostingYear,iiPostingPeriod)). <M-46 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-9781':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCREVERSALBLOCK. end. /* If not can-find (first tPosting) */ end. /* if ilOnlyReverseUnreversedOnes = true */ /* ================================================================================ */ /* All records of all db-instances that we now still have in our business-instance */ /* will get tc_status = N and they will get a new value for their _ID-field */ /* The result of this single call is that all these postings will just be like new */ /* ones but with the values of the existing ones and the 'loaded ones' are gone */ /* ================================================================================ */ <M-38 run SetNewStatus (output viFcReturnSuper (oiReturnStatus)) in BPosting> /* ===================================================================================================== */ /* Start&Open BNumber (AddToTrx=false) as in a loop below we will be calling BNumber repetively and this */ /* is more performing then using vhFcComponent=?. BNumber will be closed and stopped after the loop */ /* ===================================================================================================== */ if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ? then do : <I-92 {bFcStartAndOpenInstance &ADD-TO-TRANSACTION = "false" &CLASS = "BNumber"}> end. /* if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ? */ /* ================================================================================================================================ */ /* Start a block to make sure we leave this block in case some error occurs in the loop as we then still need to Close&Stop BNumber */ /* ================================================================================================================================ */ assign viInnerBlockReturnStatus = 0. POSTINGNUMBERBLOCK : DO : /* ===================================================== */ /* Go through all tPostings - they are now marked as new */ /* and they are just the ones that need to be reversed */ /* ===================================================== */ for each tPosting : /* ===================================================================== */ /* Create a record in the output temp-table holding the reversed posting */ /* ===================================================================== */ create tApiPeriodicCostingPostings. assign tApiPeriodicCostingPostings.tcCompanyCode = vcCompanyCode /* all loaded postings were in the current company so this is okay */ tApiPeriodicCostingPostings.tiPostingYear = tPosting.PostingYear tApiPeriodicCostingPostings.tcJournalCode = tPosting.tcJournalCode tApiPeriodicCostingPostings.tiPostingVoucher = tPosting.PostingVoucher tApiPeriodicCostingPostings.tcPostingOriginReference = tPosting.PostingOriginReference tApiPeriodicCostingPostings.tcPostingOriginatorReference = tPosting.PostingOriginatorReference. /* ========================================================================== */ /* Fill in the PostingOriginatorReference - needs to be done before we get a */ /* new voucher for the posting and after the creation of the output record- , */ /* mark the posting as a reversing one and indicate the type of reversal */ /* ========================================================================== */ assign tPosting.PostingOriginatorReference = trim(string(tPosting.PostingYear)) + "/":U + trim(string(tPosting.tcJournalCode)) + "/":U + trim(string(tPosting.PostingVoucher,"999999999":U)) tPosting.PostingIsReversing = true tPosting.PostingIsReversingBySign = ilReversalByCorrection. /* ======================================================================== */ /* Get a new voucher for the posting and store it at once in PostingVoucher */ /* ======================================================================== */ assign vhFcComponent = ?. <M-45 run GetNumber (input tPosting.Company_ID (iiCompanyId), input tPosting.PostingYear (iiNumbrYear), input tPosting.tcJournalCode (icNumbrType), output tPosting.PostingVoucher (oiNumber), input viFcCurrentInstanceId (iiInstanceId), input vcFcComponentName (icClassName), output viFcReturnSuper (oiReturnStatus)) in BNumber> if viFcReturnSuper <> 0 then assign viInnerBlockReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave POSTINGNUMBERBLOCK. if not can-find (tCommitNumber where tCommitNumber.tcNumberType = {&COMMITNUMBERTYPE-POSTINGVOUCHER} and tCommitNumber.tcPostingRowID = tPosting.tc_Rowid) then do : create tCommitNumber. assign tCommitNumber.tcNumberType = {&COMMITNUMBERTYPE-POSTINGVOUCHER} tCommitNumber.tcPostingRowID = tPosting.tc_Rowid. end. /* ========================================================================== */ /* Reverse the amounts of posting and set the resundant ID's in the subtables */ /* ========================================================================== */ for each tPostingLine where tPostingLine.tc_ParentRowid = tPosting.tc_Rowid: assign tPostingLine.Posting_ID = tPosting.Posting_ID tPostingLine.tlSkipCOAValForPeriodCosting = true. if tPosting.PostingIsReversingBySign = true then assign tPostingLine.PostingLineCreditLC = - tPostingLine.PostingLineCreditLC tPostingLine.PostingLineDebitLC = - tPostingLine.PostingLineDebitLC tPostingLine.PostingLineCreditTC = - tPostingLine.PostingLineCreditTC tPostingLine.PostingLineDebitTC = - tPostingLine.PostingLineDebitTC tPostingLine.PostingLineCreditCC = - tPostingLine.PostingLineCreditCC tPostingLine.PostingLineDebitCC = - tPostingLine.PostingLineDebitCC tPostingLine.PostingLineCreditPC = - tPostingLine.PostingLineCreditPC tPostingLine.PostingLineDebitPC = - tPostingLine.PostingLineDebitPC. else assign vdTempValue = tPostingLine.PostingLineCreditLC tPostingLine.PostingLineCreditLC = tPostingLine.PostingLineDebitLC tPostingLine.PostingLineDebitLC = vdTempValue vdTempValue = tPostingLine.PostingLineCreditTC tPostingLine.PostingLineCreditTC = tPostingLine.PostingLineDebitTC tPostingLine.PostingLineDebitTC = vdTempValue vdTempValue = tPostingLine.PostingLineCreditCC tPostingLine.PostingLineCreditCC = tPostingLine.PostingLineDebitCC tPostingLine.PostingLineDebitCC = vdTempValue vdTempValue = tPostingLine.PostingLineCreditPC tPostingLine.PostingLineCreditPC = tPostingLine.PostingLineDebitPC tPostingLine.PostingLineDebitPC = vdTempValue. for each tPostingVat where tPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid: assign tPostingVat.Posting_ID = tPostingLine.Posting_ID tPostingVat.PostingLine_ID = tPostingLine.PostingLine_ID. if tPosting.PostingIsReversingBySign = true then assign tPostingVat.PostingVatBaseCreditLC = - tPostingVat.PostingVatBaseCreditLC tPostingVat.PostingVatBaseDebitLC = - tPostingVat.PostingVatBaseDebitLC tPostingVat.PostingVatBaseCreditTC = - tPostingVat.PostingVatBaseCreditTC tPostingVat.PostingVatBaseDebitTC = - tPostingVat.PostingVatBaseDebitTC tPostingVat.PostingVatBaseCreditCC = - tPostingVat.PostingVatBaseCreditCC tPostingVat.PostingVatBaseDebitCC = - tPostingVat.PostingVatBaseDebitCC tPostingVat.PostingVatTaxCreditLC = - tPostingVat.PostingVatTaxCreditLC tPostingVat.PostingVatTaxDebitLC = - tPostingVat.PostingVatTaxDebitLC tPostingVat.PostingVatTaxCreditTC = - tPostingVat.PostingVatTaxCreditTC tPostingVat.PostingVatTaxDebitTC = - tPostingVat.PostingVatTaxDebitTC tPostingVat.PostingVatTaxCreditCC = - tPostingVat.PostingVatTaxCreditCC tPostingVat.PostingVatTaxDebitCC = - tPostingVat.PostingVatTaxDebitCC. else assign vdTempValue = tPostingVat.PostingVatBaseCreditLC tPostingVat.PostingVatBaseCreditLC = tPostingVat.PostingVatBaseDebitLC tPostingVat.PostingVatBaseDebitLC = vdTempValue vdTempValue = tPostingVat.PostingVatBaseCreditTC tPostingVat.PostingVatBaseCreditTC = tPostingVat.PostingVatBaseDebitTC tPostingVat.PostingVatBaseDebitTC = vdTempValue vdTempValue = tPostingVat.PostingVatBaseCreditCC tPostingVat.PostingVatBaseCreditCC = tPostingVat.PostingVatBaseDebitCC tPostingVat.PostingVatBaseDebitCC = vdTempValue vdTempValue = tPostingVat.PostingVatTaxCreditLC tPostingVat.PostingVatTaxCreditLC = tPostingVat.PostingVatTaxDebitLC tPostingVat.PostingVatTaxDebitLC = vdTempValue vdTempValue = tPostingVat.PostingVatTaxCreditTC tPostingVat.PostingVatTaxCreditTC = tPostingVat.PostingVatTaxDebitTC tPostingVat.PostingVatTaxDebitTC = vdTempValue vdTempValue = tPostingVat.PostingVatTaxCreditCC tPostingVat.PostingVatTaxCreditCC = tPostingVat.PostingVatTaxDebitCC tPostingVat.PostingVatTaxDebitCC = vdTempValue. end. /* for each tPostingVat where*/ for each tPostingSaf where tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid: assign tPostingSaf.PostingLine_ID = tPostingLine.PostingLine_ID tPostingSaf.Posting_ID = tPostingLine.Posting_ID. end. /* for each tPostingSaf where */ for each tPostingVatDelay where tPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid: assign tPostingVatDelay.Posting_ID = tPostingLine.Posting_ID tPostingVatDelay.PostingLine_ID = tPostingLine.PostingLine_ID. if tPosting.PostingIsReversingBySign = true then assign tPostingVatDelay.PostingVatDelayBaseCredLC = - tPostingVatDelay.PostingVatDelayBaseCredLC tPostingVatDelay.PostingVatDelayBaseDebLC = - tPostingVatDelay.PostingVatDelayBaseDebLC tPostingVatDelay.PostingVatDelayBaseCredTC = - tPostingVatDelay.PostingVatDelayBaseCredTC tPostingVatDelay.PostingVatDelayBaseDebTC = - tPostingVatDelay.PostingVatDelayBaseDebTC tPostingVatDelay.PostingVatDelayBaseCredCC = - tPostingVatDelay.PostingVatDelayBaseCredCC tPostingVatDelay.PostingVatDelayBaseDebCC = - tPostingVatDelay.PostingVatDelayBaseDebCC. else assign vdTempValue = tPostingVatDelay.PostingVatDelayBaseCredLC tPostingVatDelay.PostingVatDelayBaseCredLC = tPostingVatDelay.PostingVatDelayBaseDebLC tPostingVatDelay.PostingVatDelayBaseDebLC = vdTempValue vdTempValue = tPostingVatDelay.PostingVatDelayBaseCredTC tPostingVatDelay.PostingVatDelayBaseCredTC = tPostingVatDelay.PostingVatDelayBaseDebTC tPostingVatDelay.PostingVatDelayBaseDebTC = vdTempValue vdTempValue = tPostingVatDelay.PostingVatDelayBaseCredCC tPostingVatDelay.PostingVatDelayBaseCredCC = tPostingVatDelay.PostingVatDelayBaseDebCC tPostingVatDelay.PostingVatDelayBaseDebCC = vdTempValue. end. /* for each tPostingVatDelay where*/ end. /* for each tPostingLine where */ end. /* For each tPosting */ END. /* POSTINGNUMBERBLOCK */ /* ========================================================================================== */ /* Close&Stop BNumber that is started with a different transaction before the previous loop */ /* ========================================================================================== */ if viBNumberFromBPostingID <> 0 and viBNumberFromBPostingID <> ? then do : <I-18 {bFcCloseAndStopInstance &CLASS = "BNumber"}> end. /* if viBNumberFromBPostingID <> 0 and viBNumberFromBPostingID <> ? */ /* ============================================== */ /* Capture errors from within the previous block */ /* ============================================== */ if viInnerBlockReturnStatus <> 0 then assign viLocalReturnStatus = viInnerBlockReturnStatus. if viInnerBlockReturnStatus < 0 then Leave MAINPCREVERSALBLOCK. /* ================================================================ */ /* Call ValidateBC, AdditionalUpdates and DataSave. */ /* ================================================================ */ <M-26 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCREVERSALBLOCK. <M-27 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCREVERSALBLOCK. <M-28 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCREVERSALBLOCK. /* =============================== */ /* Exception handling - main block */ /* =============================== */ END. /* MAINPCREVERSALBLOCK */ assign oiReturnStatus = viLocalReturnStatus.
define temp-table ttContext no-undo field propertyQualifier as character field propertyName as character field propertyValue as character index entityContext is primary unique propertyQualifier propertyName index propertyQualifier propertyQualifier. define dataset dsContext for ttContext. define variable vhContextDS as handle no-undo. define variable vhExceptionDS as handle no-undo. define variable vhServer as handle no-undo. define variable vhInputDS as handle no-undo. define variable vhInputOutputDS as handle no-undo. define variable vhOutputDS as handle no-undo. define variable vhParameter as handle no-undo. /* Create context */ create ttContext. assign ttContext.propertyName = "programName" ttContext.propertyValue = "BPosting". create ttContext. assign ttContext.propertyName = "methodName" ttContext.propertyValue = "ApiMassReversePeriodicCostingPostings". create ttContext. assign ttContext.propertyName = "applicationId" ttContext.propertyValue = "fin". create ttContext. assign ttContext.propertyName = "entity" ttContext.propertyValue = "1000". create ttContext. assign ttContext.propertyName = "userName" ttContext.propertyValue = "mfg". create ttContext. assign ttContext.propertyName = "password" ttContext.propertyValue = "". /* Create input dataset */ create dataset vhInputDS. vhInputDS:read-xmlschema("file", "xml/bposting.apimassreverseperiodiccostingpostings.i.xsd", ?). vhParameter = vhInputDS:get-buffer-handle("tParameterI"). vhParameter:buffer-create(). assign vhParameter::icCompanyCode = <parameter value> vhParameter::icJournalCode = <parameter value> vhParameter::iiPostingYear = <parameter value> vhParameter::iiPostingPeriod = <parameter value> vhParameter::ilOnlyReverseUnreversedOnes = <parameter value> vhParameter::ilReversalByCorrection = <parameter value>. /* Connect the AppServer */ create server vhServer. vhServer:connect("-URL <appserver-url>"). if not vhServer:connected() then do: message "Could not connect AppServer" view-as alert-box error title "Error". return. end. /* Run */ assign vhContextDS = dataset dsContext:handle. run program/rpcrequestservice.p on vhServer (input-output dataset-handle vhContextDS by-reference, output dataset-handle vhExceptionDS, input dataset-handle vhInputDS by-reference, input-output dataset-handle vhInputOutputDS by-reference, output dataset-handle vhOutputDS). /* Handle output however you want, in this example, we dump it to xml */ if valid-handle(vhExceptionDS) then vhExceptionDS:write-xml("file", "Exceptions.xml", true). if valid-handle(vhOutputDS) then vhOutputDS:write-xml("file", "Output.xml", true). /* Cleanup */ vhServer:disconnect(). assign vhServer = ?. if valid-handle(vhInputDS) then delete object vhInputDS. if valid-handle(vhOutputDS) then delete object vhOutputDS. if valid-handle(vhExceptionDS) then delete object vhExceptionDS.