icDomainCode | input | character | DomainCode: Mandatory. This should be the current domain |
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 |
tApiPeriodicCostingPostings | output | temp-table | Output temp-table holding the main references on the postings that will be removed by this method. |
oiReturnStatus | output | integer | Return status of the method. |
/* =============================== */ /* Exception handling - main block */ /* Empty output table */ /* =============================== */ empty temp-table tApiPeriodicCostingPostings. MAINPCDELETIONBLOCK: DO : /* ================================================================ */ /* Replace unknown values in the input parameters and then validate */ /* the input as stated in the descriptions of the parameters itself */ /* ================================================================ */ if icDomainCode = "":U or icDomainCode = ? or icJournalCode = "":U or icJournalCode = ? or iiPostingYear = 0 or iiPostingYear = ? or iiPostingPeriod = 0 or iiPostingPeriod = ? then do : assign vcMessage = trim(substitute(#T-91'The domain (&1), daybook (&2), year (&3) and period (&4) are all mandatory parameters for the API method.':255(617355577)T-91#,icDomainCode,icJournalCode,iiPostingYear,iiPostingPeriod)) oiReturnStatus = -3. <M-96 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-24052':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCDELETIONBLOCK. end. /* if icDomainCode = "":U or */ if icDomainCode <> vcDomainCode /* 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-68'The domain (&1) passed as input to API method must be the current domain (&2).':255(13179054)T-68#,icDomainCode,vcDomainCode)) oiReturnStatus = -3. <M-2 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-341512':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCDELETIONBLOCK. end. /* if icDomainCode <> vcDomainCode */ assign vcMessage = "":U. <Q-30 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-34'The daybook (&1) passed as input to the API method cannot be found.':255(591295504)T-34#,icJournalCode)). if vcMessage = "":U and available tqJournalByJournalCodeWithLayer and tqJournalByJournalCodeWithLayer.tlJournalIsActive <> true then assign vcMessage = trim(substitute(#T-46'The daybook (&1) passed as input to the API method is not active.':255(332075615)T-46#,icJournalCode)). if vcMessage = "":U and available tqJournalByJournalCodeWithLayer and tqJournalByJournalCodeWithLayer.tcJournalTypeCode <> {&JOURNALTYPE-PERIODICCOSTING} then assign vcMessage = trim(substitute(#T-58'The daybook (&1) passed as input to the API method has daybook type &2. The daybook type must be &3.':255(227658115)T-58#,icJournalCode,tqJournalByJournalCodeWithLayer.tcJournalTypeCode,{&JOURNALTYPE-PERIODICCOSTING-TR})). if vcMessage = "":U and available tqJournalByJournalCodeWithLayer and tqJournalByJournalCodeWithLayer.tcLayerTypeCode <> {&LAYERTYPECODE-TRANSIENT} then assign vcMessage = trim(substitute(#T-21'The daybook (&1) passed as input to the API method is not defined in the transient layer.':255(825527502)T-21#,icJournalCode,tqJournalByJournalCodeWithLayer.tcLayerTypeCode,{&LAYERTYPECODE-TRANSIENT-TR})). if vcMessage <> "":U then do : assign oiReturnStatus = -3. <M-50 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-770367':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BPosting> Leave MAINPCDELETIONBLOCK. end. /* if vcMessage <> "":U */ /* ================================================================ */ /* Run a ClearData to make sure we start from scratch */ /* ================================================================ */ <M-1 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCDELETIONBLOCK. /* ====================================================================================================== */ /* Call method to delete the transient Periodic Costings postings for each company of the selected domain */ /* ====================================================================================================== */ <Q-81 run DomainsForCompanies (all) (Read) (Cache) (input ?, (DomainId) input icDomainCode, (DomainCode) input ?, (CompanyId) output dataset tqDomainsForCompanies) in BDomain> assign vlRecordsFound = false. for each tqDomainsForCompanies where tqDomainsForCompanies.tcDomainCode = icDomainCode on error undo, throw: <M-94 run MassDeletePeriodicCostingPostings (input tqDomainsForCompanies.tcCompanyCode (icCompanyCode), input icJournalCode (icJournalCode), input iiPostingYear (iiPostingYear), input iiPostingPeriod (iiPostingPeriod), output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 and viFcReturnSuper <> -4 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper <> -4 then assign vlRecordsFound = true. if viFcReturnSuper < 0 and viFcReturnSuper <> -4 then Leave MAINPCDELETIONBLOCK. end. /* for each tqDomainsForCompanies where */ /* put returnstatus to -4 if all companies returned -4 */ if vlRecordsFound = false and oiReturnStatus >= 0 then do: assign oiReturnStatus = -4. Leave MAINPCDELETIONBLOCK. end. /* if vlRecordsFound = false and oiReturnStatus >= 0 */ /* ================================================================ */ /* Call ValidateBC, AdditionalUpdates and DataSave. */ /* ================================================================ */ <M-43 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCDELETIONBLOCK. <M-4 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCDELETIONBLOCK. <M-26 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BPosting> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave MAINPCDELETIONBLOCK. END. /* MAINPCDELETIONBLOCK */
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 = "ApiMassDeletePeriodicCostingPostingsByDomain". 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.apimassdeleteperiodiccostingpostingsbydomain.i.xsd", ?). vhParameter = vhInputDS:get-buffer-handle("tParameterI"). vhParameter:buffer-create(). assign vhParameter::icDomainCode = <parameter value> vhParameter::icJournalCode = <parameter value> vhParameter::iiPostingYear = <parameter value> vhParameter::iiPostingPeriod = <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.