icConsolidCompanyCode | input | character | |
tUIConsolidPeriodXref | output | temp-table | Create records for each Source Company Period. Complete the records with the Consolidation Periods ConsolidPeriodXref. |
oiConsolidCompanyID | output | integer | |
oiReturnStatus | output | integer | Return status of the method. |
assign oiReturnStatus = -98. empty temp-table tUIConsolidPeriodXref. /*==========================================================================================*/ /* Validate input-parameters */ /*==========================================================================================*/ if (icConsolidCompanyCode = '' or icConsolidCompanyCode = ?) then do: assign vcConsPerXrefMsg = #T-10'You must enter the consolidation entity.':200(1368)T-10# oiReturnStatus = -1. <M-8 run SetMessage (input trim(vcConsPerXrefMsg) (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input ? (icRowid), input 'QADFIN-2331':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BConsolidPeriodXref> return. end. /*==========================================================================================*/ /* Verify that Consolidation Company exists and has a Consolidation Cycle Record. */ /*==========================================================================================*/ /* Find Consolidation Company */ <Q-4 run CompanyPrim (all) (Read) (NoCache) (input ?, (LookupCompanyId) input icConsolidCompanyCode, (CompanyCode) output dataset tqCompanyPrim) in BCompany > find first tqCompanyPrim where tqCompanyPrim.tcCompanyCode = icConsolidCompanyCode no-lock no-error. if not available(tqCompanyPrim) then do: assign vcConsPerXrefMsg = substitute(#T-11'The consolidation entity &1 cannot be found.':200(1369)T-11#, trim(icConsolidCompanyCode)) oiReturnStatus = -1. <M-5 run SetMessage (input trim(vcConsPerXrefMsg) (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input ? (icRowid), input 'QADFIN-2277':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BConsolidPeriodXref> return. end. assign viConsolidCompanyID = tqCompanyPrim.tiCompany_ID oiConsolidCompanyID = tqCompanyPrim.tiCompany_ID. empty temp-table tqCompanyPrim. /* Find Consolidation Cycle record */ <Q-9 assign vlFcQueryRecordsAvailable = ConsolidCycleByCompanyID (NoCache) (input viConsolidCompanyID, (CompanyId)) in BConsolidCycle > if (vlFcQueryRecordsAvailable <> true) then do: assign vcConsPerXrefMsg = substitute(#T-12'The consolidation entity &1 has no consolidation cycle.':200(1366)T-12#, trim(icConsolidCompanyCode)) oiReturnStatus = -1. <M-7 run SetMessage (input trim(vcConsPerXrefMsg) (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input ? (icRowid), input 'QADFIN-2279':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BConsolidPeriodXref> return. end. /*==========================================================================================*/ /* Create a record for each Source Company Period. */ /* Fill the consolidation period when the periods are the same */ /*==========================================================================================*/ empty temp-table tPeriodByYearPeriodConsol. <Q-14 run PeriodByYearPeriod (all) (Read) (NoCache) (input viConsolidCompanyID, (CompanyId) input ?, (PeriodYear) input ?, (PeriodPeriod) input ?, (PeriodId) output dataset tqPeriodByYearPeriod) in BPeriod > for each tqPeriodByYearPeriod: create tPeriodByYearPeriodConsol. buffer-copy tqPeriodByYearPeriod to tPeriodByYearPeriodConsol. end. empty temp-table tqPeriodByYearPeriod. <Q-1 run PeriodByYearPeriod (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (PeriodYear) input ?, (PeriodPeriod) input ?, (PeriodId) output dataset tqPeriodByYearPeriod) in BPeriod > for each tqPeriodByYearPeriod where tqPeriodByYearPeriod.tiCompany_ID = viCompanyID: create tUIConsolidPeriodXref. assign tUIConsolidPeriodXref.tiPeriodYear = tqPeriodByYearPeriod.tiPeriodYear tUIConsolidPeriodXref.tiPeriodPeriod = tqPeriodByYearPeriod.tiPeriodPeriod. if can-find(tPeriodByYearPeriodConsol where tPeriodByYearPeriodConsol.tiPeriodYear = tqPeriodByYearPeriod.tiPeriodYear and tPeriodByYearPeriodConsol.tiPeriodPeriod = tqPeriodByYearPeriod.tiPeriodPeriod and tPeriodByYearPeriodConsol.ttPeriodStartDate = tqPeriodByYearPeriod.ttPeriodStartDate and tPeriodByYearPeriodConsol.ttPeriodEndDate = tqPeriodByYearPeriod.ttPeriodEndDate) then assign tUIConsolidPeriodXref.tiConsolidPeriodYear = tqPeriodByYearPeriod.tiPeriodYear tUIConsolidPeriodXref.tiConsolidPeriodPeriod = tqPeriodByYearPeriod.tiPeriodPeriod. else assign tUIConsolidPeriodXref.tiConsolidPeriodYear = 0 tUIConsolidPeriodXref.tiConsolidPeriodPeriod = 0. end. empty temp-table tqPeriodByYearPeriod. empty temp-table tPeriodByYearPeriodConsol. /*==========================================================================================*/ /* Complete the columns in the created temp-table records */ /* with the existing data in ConsolidPeriodXref. */ /*==========================================================================================*/ <Q-2 run ConsolidPeriodXrefByPeriod (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input viConsolidCompanyID, (ConsolidCompanyID) input '':U, (ConsolidCompanyCode) input ?, (SourceYear) input ?, (SourcePeriod) input ?, (TargetYear) input ?, (TargetPeriod) output dataset tqConsolidPeriodXrefByPeriod) in BConsolidPeriodXref> for each tqConsolidPeriodXrefByPeriod where tqConsolidPeriodXrefByPeriod.tiCompany_ID = viCompanyId and tqConsolidPeriodXrefByPeriod.tiConsolidationCompany_ID = viConsolidCompanyID: find first tUIConsolidPeriodXref where tUIConsolidPeriodXref.tiPeriodYear = tqConsolidPeriodXrefByPeriod.tiPeriodYear and tUIConsolidPeriodXref.tiPeriodPeriod = tqConsolidPeriodXrefByPeriod.tiPeriodPeriod exclusive no-error. if not available(tUIConsolidPeriodXref) then do: assign vcConsPerXrefMsg = substitute(#T-13'The cross-reference record for the period &1/&2 must already exist in the temp table.':200(1388)T-13#, trim(string(tqConsolidPeriodXrefByPeriod.tiPeriodYear)), trim(string(tqConsolidPeriodXrefByPeriod.tiPeriodPeriod))) oiReturnStatus = -1. <M-3 run SetMessage (input trim(vcConsPerXrefMsg) (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'QADFIN-2276':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BConsolidPeriodXref> return. end. else do: assign tUIConsolidPeriodXref.tiConsolidPeriodYear = tqConsolidPeriodXrefByPeriod.tiConsolidPeriodYear tUIConsolidPeriodXref.tiConsolidPeriodPeriod = tqConsolidPeriodXrefByPeriod.tiConsolidPeriodPeriod. end. end. empty temp-table tqConsolidPeriodXrefByPeriod. if oiReturnStatus = -98 then oiReturnStatus = 0.
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 = "BConsolidPeriodXref". create ttContext. assign ttContext.propertyName = "methodName" ttContext.propertyValue = "ApiGetConsolidPeriods". 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/bconsolidperiodxref.apigetconsolidperiods.i.xsd", ?). vhParameter = vhInputDS:get-buffer-handle("tParameterI"). vhParameter:buffer-create(). assign vhParameter::icConsolidCompanyCode = <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.