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 |
iiPostingYear | input | integer | PostingYear: Mandatory. accounting-year format 9999 |
iiPostingPeriod | input | integer | PostingPeriod: Mandatory. accounting-period format 99 |
oiReturnStatus | output | integer | Return status of the method. |
MAINPCDELETIONBLOCK: DO : if icCompanyCode = "" or icCompanyCode = ? then do: assign vcMessage = #T-70'The entity is a mandatory parameters for this method.':255(561770151)T-70# oiReturnStatus = -3. <M-76 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-424072':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCDELETIONBLOCK. end. /* if icCompanyCode = "":U or */ <Q-58 run CompanyByCompanyCode (all) (Read) (Cache) (input icCompanyCode, (CompanyCode) input ?, (CompanyId) output dataset tqCompanyByCompanyCode) in BCompany> find tqCompanyByCompanyCode where tqCompanyByCompanyCode.tcCompanyCode = icCompanyCode no-error. if not available tqCompanyByCompanyCode then do: assign vcMessage = trim(substitute(#T-72'The entity (&1) does not exist.':255(753022446)T-72#, icCompanyCode)) oiReturnStatus = -3. <M-62 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-816902':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCDELETIONBLOCK. end. /* if not available tqCompanyByCompanyCode */ /* =================================================================================== */ /* Call DataLoad with a free-form that looks like this: ? */ /* for each Posting where Posting.Company_ID = tqCompanyByCompanyCode.tiCompany_ID 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(tqCompanyByCompanyCode.tiCompany_ID) + " and ":U + "Posting.PostingYear = ":U + string(iiPostingYear) + " and ":U + "Posting.PostingPeriod = ":U + string(iiPostingPeriod) + " and ":U + "Posting.Journal_ID = ":U + string(tqJournalByJournalCodeWithLayer.tiJournal_ID). <M-2 run DataLoad (input '':U (icRowids), input '':U (icPkeys), input '':U (icObjectIds), input vcFreeForm (icFreeform), input true (ilKeepPrevious), output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then leave MAINPCDELETIONBLOCK. 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 oiReturnStatus = (if oiReturnStatus >= 0 then 1 else oiReturnStatus) vcMessage = trim(substitute(#T-21'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-21#, icCompanyCode,icJournalCode,iiPostingYear,iiPostingPeriod)). <M-29 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-563002':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCDELETIONBLOCK. 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-67 run DataLoadMirrorPosting (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then leave MAINPCDELETIONBLOCK. /* ================================================================================================ */ /* Set tc_status = D for al tPosting record and create a record in the output temp-table for it */ /* ================================================================================================ */ for each tPosting on error undo, throw: assign tPosting.tc_Status = "D":U. create tApiPeriodicCostingPostings. assign tApiPeriodicCostingPostings.tcCompanyCode = icCompanyCode tApiPeriodicCostingPostings.tiPostingYear = tPosting.PostingYear tApiPeriodicCostingPostings.tcJournalCode = tPosting.tcJournalCode tApiPeriodicCostingPostings.tiPostingVoucher = tPosting.PostingVoucher tApiPeriodicCostingPostings.tcPostingOriginReference = tPosting.PostingOriginReference tApiPeriodicCostingPostings.tcPostingOriginatorReference = tPosting.PostingOriginatorReference. end. /* For each tPosting */ END. /* MAINPCDELETIONBLOCK */