project QadFinancials > class BPosting > method GetDataForOpPosting
Description
This method is used to retrieve information required by the Operational Posting Program
Parameters
Internal usage
unused
program code (program9/bposting.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* =================== */
/* Clear output tables */
/* =================== */
empty temp-table tApiDomainInfo.
empty temp-table tApiDomainPropertyInfo.
empty temp-table tApiAccountInfo.
empty temp-table tApiPostingDataIsWithSaf.
/* ========================================= */
/* Get the domain-data of the current domain */
/* ========================================= */
<Q-8 run DomainForOperartionalInfo (all) (Read) (NoCache)
(input viDomainID, (DomainID)
input ?, (DomainCode)
output dataset tqDomainForOperartionalInfo) in BDomain >
find first tqDomainForOperartionalInfo where
tqDomainForOperartionalInfo.tiDomain_ID = viDomainID
no-lock no-error.
if not available tqDomainForOperartionalInfo
then do :
assign vcMessage = trim(substitute(#T-9'The system cannot find the current domain based upon its ID (&1). Domain code: &2.':255(69243)T-9#,viDomainID,vcDomainCode))
oiReturnStatus = -3.
<M-10 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-7978':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Return.
end. /* if not available tqDomainForOperartionalInfo */
create tApiDomainInfo.
create tApiDomainPropertyInfo.
assign tApiDomainInfo.Domain_ID = tqDomainForOperartionalInfo.tiDomain_ID
tApiDomainInfo.DomainCode = tqDomainForOperartionalInfo.tcDomainCode
tApiDomainInfo.DomainDatabase = tqDomainForOperartionalInfo.tcDomainDatabase
tApiDomainInfo.DomainIsActive = tqDomainForOperartionalInfo.tlDomainIsActive
tApiDomainInfo.DomainType = tqDomainForOperartionalInfo.tcDomainType
tApiDomainInfo.tc_Rowid = tqDomainForOperartionalInfo.tc_rowid
tApiDomainPropertyInfo.Currency_ID = tqDomainForOperartionalInfo.tiCurrency_ID
tApiDomainPropertyInfo.Domain_ID = tqDomainForOperartionalInfo.tiDomain_ID
tApiDomainPropertyInfo.DomainProperty_ID = tqDomainForOperartionalInfo.tiDomainProperty_ID
tApiDomainPropertyInfo.DomainPropertyIsMaskCC = tqDomainForOperartionalInfo.tlDomainPropertyIsMaskCC
tApiDomainPropertyInfo.DomainPropertyIsMaskDiv = tqDomainForOperartionalInfo.tlDomainPropertyIsMaskDiv
tApiDomainPropertyInfo.DomainPropertyIsMaskProj = tqDomainForOperartionalInfo.tlDomainPropertyIsMaskProj
tApiDomainPropertyInfo.DomainPropertyIsStatutory = tqDomainForOperartionalInfo.tlDomainPropertyIsStatutory
tApiDomainPropertyInfo.StatutoryCurrency_ID = tqDomainForOperartionalInfo.tiStatutoryCurrency_ID
tApiDomainPropertyInfo.tc_Rowid = tqDomainForOperartionalInfo.tc_rowid.
<Q-23 run CurrencyById (all) (Read) (NoCache)
(input tqDomainForOperartionalInfo.tiCurrency_ID, (CurrencyId)
output dataset tqCurrencyById) in BCurrency >
find tqCurrencyById where
tqCurrencyById.tiCurrency_ID = tqDomainForOperartionalInfo.tiCurrency_ID
no-lock no-error.
if not available tqCurrencyById
then do:
assign vcMessage = trim(#T-24'Domain currency codecould not be found':255(733713201)T-24#)
oiReturnStatus = -3.
<M-25 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-9766':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
return.
end. /* if not available tqCurrencyById */
else do:
assign tApiDomainPropertyInfo.tcCurrencyCode = tqCurrencyById.tcCurrencyCode.
end. /* if available tqCurrencyById */
if tApiDomainPropertyInfo.DomainPropertyIsStatutory = true
then do:
<Q-19 run CurrencyById (all) (Read) (NoCache)
(input tqDomainForOperartionalInfo.tiStatutoryCurrency_ID, (CurrencyId)
output dataset tqCurrencyById) in BCurrency >
find tqCurrencyById where
tqCurrencyById.tiCurrency_ID = tqDomainForOperartionalInfo.tiStatutoryCurrency_ID
no-lock no-error.
if not available tqCurrencyById
then do:
assign vcMessage = trim(#T-21'The statutory currency for the domain could not be found':255(733714119)T-21#)
oiReturnStatus = -3.
<M-22 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-9463':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
return.
end. /* if not available tqCurrencyById */
else do:
assign tApiDomainPropertyInfo.tcStatutoryCurrencyCode = tqCurrencyById.tcCurrencyCode.
end. /* else tqCurrencyById is available */
end. /* if tApiDomainPropertyInfo.DomainPropertyIsStatutory = true */
else do:
assign tApiDomainPropertyInfo.tcStatutoryCurrencyCode = tApiDomainPropertyInfo.tcCurrencyCode.
end. /* NOT if tApiDomainPropertyInfo.DomainPropertyIsStatutory = true */
/* ======================================================= */
/* Get the consolidation/management currency of the system */
/* ======================================================= */
<Q-3 run SystemPropertyByAll (all) (Read) (NoCache) (output dataset tqSystemPropertyByAll) in BSystemProperty >
Find first tqSystemPropertyByAll
no-lock no-error.
if not available tqSystemPropertyByAll
then do :
assign vcMessage = trim(substitute(#T-12'The system cannot find the system definition of Financials.':255(69244)T-12#))
oiReturnStatus = -3.
<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-7980':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Return.
end. /* if not available tqSystemPropertyByAll */
assign ocSysPropertyCurrencyCode = tqSystemPropertyByAll.tcCurrencyCode.
/* ================================================================================================= */
/* Get the list of GLs of the current domain together with their analysis details. We just pass the */
/* current-company_id as input for the query as all GLs of all companies of a domain are the same */
/* ================================================================================================= */
<Q-14 run GLAnalysisInfoForOperationals (all) (Read) (NoCache)
(input viCompanyID, (CompanyID)
output dataset tqGLAnalysisInfoForOperationals) in BGL >
for each tqGLAnalysisInfoForOperationals
no-lock:
create tApiAccountInfo.
assign tApiAccountInfo.tcDomainCode = vcDomainCode
tApiAccountInfo.tcGLCode = tqGLAnalysisInfoForOperationals.tcGLCode
tApiAccountInfo.tlGLIsCostCentreAccount = tqGLAnalysisInfoForOperationals.tlGLIsCostCentreAccount
tApiAccountInfo.tlGLIsDivisionAccount = tqGLAnalysisInfoForOperationals.tlGLIsDivisionAccount
tApiAccountInfo.tlGLIsProjectAccount = tqGLAnalysisInfoForOperationals.tlGLIsProjectAccount
tApiAccountInfo.tcGLAnalysisLimitation = tqGLAnalysisInfoForOperationals.tcGLAnalysisLimitation.
/* ======================================= */
/* Populate the tApiPOstingDataIsWithSaf */
/* temp-table. */
/* ======================================= */
/* GLs */
if tqGLAnalysisInfoForOPerationals.tlGLIsSafAccount = true
then do:
create tApiPostingDataIsWithSaf.
assign tApiPostingDataIsWithSaf.tcCode = tqGLAnalysisInfoForOperationals.tcGLCode
tApiPostingDataIsWithSaf.tcSharedSetType = {&SHAREDSETTYPE-GL}.
end. /* if tqGLAnalysisInfoForOPerationals.tlGLIsSafAccount = true */
end. /* tqGLAnalysisInfoForOperationals */
/* ======================================= */
/* Populate the tApiPOstingDataIsWithSaf */
/* temp-table. */
/* ======================================= */
/* Projects */
<Q-6 run ProjectByWithSAF (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input '':U, (ProjectCode)
input true, (ProjectIsWithSAF)
output dataset tqProjectByWithSAF) in BProject >
for each tqProjectByWithSAF where
tqProjectByWithSAF.tlProjectIsWithSaf = true:
create tApiPostingDataIsWithSaf.
assign tApiPostingDataIsWithSaf.tcCode = tqProjectByWithSAF.tcProjectCode
tApiPostingDataIsWithSaf.tcSharedSetType = {&SHAREDSETTYPE-PROJECT}.
end. /* for each tqProjectByWithSAF */
/* Cost Centres */
<Q-17 run CostCentreByCompanyAndActive (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input true, (CostCentreIsActive)
output dataset tqCostCentreByCompanyAndActive) in BCostCentre >
for each tqCostCentreByCompanyAndActive where
tqCostCentreByCompanyAndActive.tlCostCentreIsWithSaf = true
no-lock:
create tApiPostingDataIsWithSaf.
assign tApiPostingDataIsWithSaf.tcCode = tqCostCentreByCompanyAndActive.tccostCentreCode
tApiPostingDataIsWithSaf.tcSharedSetType = {&SHAREDSETTYPE-COSTCENTRE}.
end. /* For each tqCostCentreByCompanyAnd Active */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
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 = "GetDataForOpPosting".
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 = "".
/* 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.