Description
This procedure is used to retrieve analysis information of a mirroringGL record with specified unposted transaction information.
Parameters
| icdracct | input | character | Debit Account |
| iccracct | input | character | credit account |
| icdrsub | input | character | debit sub-account |
| iccrsub | input | character | This query returns the key fields per domain for the mirroring daybook Id and Mirroring daybook code. |
| icdrcc | input | character | debit cost center |
| iccrcc | input | character | credit cost center |
| icdrprj | input | character | debit project |
| iccrprj | input | character | credit project |
| icDomainCode | input | character | |
| icCompanyCode | input | character | |
| tApiMirroringGL | output | temp-table | containing the desired record |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program9/bmirroringgl.p)
/*******************************************************************************
This procedure is used to retrieve analysis information of a mirroringGL record
with specified unposted transaction information.
*******************************************************************************/
assign
oiReturnStatus = -98
viLocalStatus = 0.
/* if both of the two accounts */
if icdracct <> ? and
icdracct <>'' and
iccracct <> ? and
iccracct <> ''
then do:
/* Initialize the matching type */
assign vcMatchingType = "":U.
/* try to retrieve mirroringGL record, using debit account as source 2 and
credit account as source 1 */
<Q-2 run MirroringGLBySourceGL (all) (Read) (NoCache)
(input ?, (CompanyId)
input iccracct, (Source1GLCode)
input icdracct, (Source2GLCode)
input icCompanyCode, (CompanyCode)
input icDomainCode, (DomainCode)
output dataset tqMirroringGLBySourceGL) in BMirroringGL >
find first tqMirroringGLBySourceGL where
(tqMirroringGLBySourceGL.tcSource2CostCentreCode = icdrcc or
tqMirroringGLBySourceGL.tcSource2CostCentreCode = '' or
tqMirroringGLBySourceGL.tcSource2CostCentreCode = ? ) and
(tqMirroringGLBySourceGL.tcSource1CostCentreCode = iccrcc or
tqMirroringGLBySourceGL.tcSource1CostCentreCode = '' or
tqMirroringGLBySourceGL.tcSource1CostCentreCode = ? ) and
(tqMirroringGLBySourceGL.tcSource2DivisionCode = icdrsub or
tqMirroringGLBySourceGL.tcSource2DivisionCode = '' or
tqMirroringGLBySourceGL.tcSource2DivisionCode = ? ) and
(tqMirroringGLBySourceGL.tcSource1DivisionCode = iccrsub or
tqMirroringGLBySourceGL.tcSource1DivisionCode = '' or
tqMirroringGLBySourceGL.tcSource1DivisionCode = ? ) and
(tqMirroringGLBySourceGL.tcSource2ProjectCode = icdrprj or
tqMirroringGLBySourceGL.tcSource2ProjectCode = '' or
tqMirroringGLBySourceGL.tcSource2ProjectCode = ? ) and
(tqMirroringGLBySourceGL.tcSource1ProjectCode = iccrprj or
tqMirroringGLBySourceGL.tcSource1ProjectCode = '' or
tqMirroringGLBySourceGL.tcSource1ProjectCode = ? )
no-error.
if available tqMirroringGLBySourceGL
then do:
/* The Matching Tyoe is Reverse, Debit Account = Source Account 2 and Credit Account = Source Account 1 */
assign vcMatchingType = "Reverse".
create tApiMirroringGL.
<M-3 run BufferCopy
(input buffer tqMirroringGLBySourceGL:handle (ihFrom),
input buffer tApiMirroringGL:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BMirroringGL>
if viFcReturnSuper < 0 or
(viFcReturnSuper <> 0 and
viLocalStatus = 0)
then assign viLocalStatus = viFcReturnSuper.
end. /* if availabe tqMirroringGLBySourceGL */
/* otherwise, try the other way around */
else do:
<Q-4 run MirroringGLBySourceGL (all) (Read) (NoCache)
(input ?, (CompanyId)
input icdracct, (Source1GLCode)
input iccracct, (Source2GLCode)
input icCompanyCode, (CompanyCode)
input icDomainCode, (DomainCode)
output dataset tqMirroringGLBySourceGL) in BMirroringGL >
find first tqMirroringGLBySourceGL where
(tqMirroringGLBySourceGL.tcSource1CostCentreCode = icdrcc or
tqMirroringGLBySourceGL.tcSource1CostCentreCode = '' or
tqMirroringGLBySourceGL.tcSource1CostCentreCode = ? ) and
(tqMirroringGLBySourceGL.tcSource2CostCentreCode = iccrcc or
tqMirroringGLBySourceGL.tcSource2CostCentreCode = '' or
tqMirroringGLBySourceGL.tcSource2CostCentreCode = ? ) and
(tqMirroringGLBySourceGL.tcSource1DivisionCode = icdrsub or
tqMirroringGLBySourceGL.tcSource1DivisionCode = '' or
tqMirroringGLBySourceGL.tcSource1DivisionCode = ? ) and
(tqMirroringGLBySourceGL.tcSource2DivisionCode = iccrsub or
tqMirroringGLBySourceGL.tcSource2DivisionCode = '' or
tqMirroringGLBySourceGL.tcSource2DivisionCode = ? ) and
(tqMirroringGLBySourceGL.tcSource1ProjectCode = icdrprj or
tqMirroringGLBySourceGL.tcSource1ProjectCode = '' or
tqMirroringGLBySourceGL.tcSource1ProjectCode = ? ) and
(tqMirroringGLBySourceGL.tcSource2ProjectCode = iccrprj or
tqMirroringGLBySourceGL.tcSource2ProjectCode = '' or
tqMirroringGLBySourceGL.tcSource2ProjectCode = ? )
no-error.
if available tqMirroringGLBySourceGL
then do:
/* The Matching Tyoe is Normal, Debit Account = Source Account 1 and Credit Account = Source Account 2 */
assign vcMatchingType = "Normal".
create tApiMirroringGL.
<M-5 run BufferCopy
(input buffer tqMirroringGLBySourceGL:handle (ihFrom),
input buffer tApiMirroringGL:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BMirroringGL>
if viFcReturnSuper < 0 or
(viFcReturnSuper <> 0 and
viLocalStatus = 0)
then assign viLocalStatus = viFcReturnSuper.
end. /* if available tqMirroringGLBySourceGL */
end. /* else do */
end. /* if icdracct <> ? */
/* zjc: defect 10249 - 0229 begin */
/* This part of code is used to fetch analysis fields for mirror accounts if necessary. */
if available tApiMirroringGL
then do:
/* Initialize loval variables */
assign
vlMirror1IsCostCentreAccount = false
vlMirror2IsCostCentreAccount = false
vlMirror1IsDivisionAccount = false
vlMirror2IsDivisionAccount = false
vlMirror1IsProjectAccount = false
vlMirror2IsProjectAccount = false
vcMirror1AnalysisLimitation = "":U
vcMirror2AnalysisLimitation = "":U.
/* MIRROR ACCOUNT 1 */
<Q-6 run GLById (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror1GL_ID, (GLId)
output dataset tqGLById) in BGL >
for first tqGLById:
assign
vlMirror1IsCostCentreAccount = tqGLById.tlGLIsCostCentreAccount
vlMirror1IsDivisionAccount = tqGLById.tlGLIsDivisionAccount
vlMirror1IsProjectAccount = tqGLById.tlGLIsProjectAccount
vcMirror1AnalysisLimitation = tqGLById.tcGLAnalysisLimitation.
end. /* for first tqGLById: */
/* Get sub-account(division) information */
if vlMirror1IsDivisionAccount
then do:
if tApiMirroringGL.tcMirror1DivisionCode <> "":U and tApiMirroringGL.tcMirror1DivisionCode <> ?
then do:
/* Do nothing here, just use this value */
end.
/* Use source account's sub-account as the mirror one */
else if (vcMatchingType = "Normal" and icdrsub <> "":U and icdrsub <> ?) or
(vcMatchingType = "Reverse" and iccrsub <> "":U and iccrsub <> ?)
then
assign tApiMirroringGL.tcMirror1DivisionCode = (if vcMatchingType = "Normal" then icdrsub else iccrsub).
/* Get sub-account value from the GL account definition */
else do:
<Q-8 run GLByIDForDivisionInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror1GL_ID, (GLID)
input ?, (GLCode)
output dataset tqGLByIDForDivisionInfo) in BGL >
for first tqGLByIDForDivisionInfo:
tApiMirroringGL.tcMirror1DivisionCode = tqGLByIDForDivisionInfo.tcDivisionCode.
end.
end.
end. /* if vlMirror1IsDivisionAccount */
/* Get Cost Centre information */
if vlMirror1IsCostCentreAccount
then do:
if tApiMirroringGL.tcMirror1CostCentreCode <> "":U and tApiMirroringGL.tcMirror1CostCentreCode <> ?
then do:
/* Do nothing here, just use this value */
end.
else if (vcMatchingType = "Normal" and icdrcc <> "":U and icdrcc <> ?) or
(vcMatchingType = "Reverse" and iccrcc <> "":U and iccrcc <> ?)
then do:
assign tApiMirroringGL.tcMirror1CostCentreCode = (if vcMatchingType = "Normal" then icdrcc else iccrcc).
end.
else do:
<Q-10 run GLByIDForCostCentreInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror1GL_ID, (GLID)
input ?, (GLCode)
output dataset tqGLByIDForCostCentreInfo) in BGL >
for first tqGLByIDForCostCentreInfo:
tApiMirroringGL.tcMirror1CostCentreCode = tqGLByIDForCostCentreInfo.tcCostCentreCode.
end.
end.
end. /* if vlMirror1IsCostCentreAccount */
/* Get Project information */
if vlMirror1IsProjectAccount
then do:
if tApiMirroringGL.tcMirror1ProjectCode <> "":U and tApiMirroringGL.tcMirror1ProjectCode <> ?
then do:
/* Do nothing here, just use this value */
end.
else if (vcMatchingType = "Normal" and icdrprj <> "":U and icdrprj <> ?) or
(vcMatchingType = "Reverse" and iccrprj <> "":U and iccrprj <> ?)
then
assign tApiMirroringGL.tcMirror1ProjectCode = (if vcMatchingType = "Normal" then icdrprj else iccrprj).
else do:
<Q-11 run GLByIDForProjectInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror1GL_ID, (GLID)
input ?, (GLCode)
output dataset tqGLByIDForProjectInfo) in BGL >
for first tqGLByIdForProjectInfo:
tApiMirroringGL.tcMirror1ProjectCode = tqGLByIdForProjectInfo.tcProjectCode.
end.
end.
end. /* if vlMirror1IsProjectAccount */
/* MIRROR ACCOUNT 2 */
<Q-7 run GLById (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror2GL_ID, (GLId)
output dataset tqGLById) in BGL >
for first tqGLById:
assign
vlMirror2IsCostCentreAccount = tqGLById.tlGLIsCostCentreAccount
vlMirror2IsDivisionAccount = tqGLById.tlGLIsDivisionAccount
vlMirror2IsProjectAccount = tqGLById.tlGLIsProjectAccount
vcMirror2AnalysisLimitation = tqGLById.tcGLAnalysisLimitation.
end. /* for first tqGLById: */
/* Get sub-account(division) information */
if vlMirror2IsDivisionAccount then do:
if tApiMirroringGL.tcMirror2DivisionCode <> "":U and tApiMirroringGL.tcMirror2DivisionCode <> ?
then do:
/* Do nothing here, just use this value */
end.
/* Use source account's sub-account as the mirror one */
else if (vcMatchingType = "Normal" and iccrsub <> "":U and iccrsub <> ?) or
(vcMatchingType = "Reverse" and icdrsub <> "":U and icdrsub <> ?)
then
assign tApiMirroringGL.tcMirror2DivisionCode = (if vcMatchingType = "Normal" then iccrsub else icdrsub).
/* Get sub-account value from the GL account definition */
else do:
<Q-9 run GLByIDForDivisionInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror2GL_ID, (GLID)
input ?, (GLCode)
output dataset tqGLByIDForDivisionInfo) in BGL >
for first tqGLByIDForDivisionInfo:
tApiMirroringGL.tcMirror2DivisionCode = tqGLByIDForDivisionInfo.tcDivisionCode.
end.
end.
end. /* if vlMirror1IsDivisionAccount */
/* Get Cost Centre information */
if vlMirror2IsCostCentreAccount
then do:
if tApiMirroringGL.tcMirror2CostCentreCode <> "":U and tApiMirroringGL.tcMirror2CostCentreCode <> ?
then do:
/* Do nothing here, just use this value */
end.
else if (vcMatchingType = "Normal" and iccrcc <> "":U and iccrcc <> ?) or
(vcMatchingType = "Reverse" and icdrcc <> "":U and icdrcc <> ?)
then
assign tApiMirroringGL.tcMirror2CostCentreCode = (if vcMatchingType = "Normal" then iccrcc else icdrcc).
else do:
<Q-12 run GLByIDForCostCentreInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror2GL_ID, (GLID)
input ?, (GLCode)
output dataset tqGLByIDForCostCentreInfo) in BGL >
for first tqGLByIDForCostCentreInfo:
tApiMirroringGL.tcMirror2CostCentreCode = tqGLByIDForCostCentreInfo.tcCostCentreCode.
end.
end.
end. /* if vlMirror2IsCostCentreAccount */
/* Get Project information */
if vlMirror2IsProjectAccount
then do:
if tApiMirroringGL.tcMirror2ProjectCode <> "":U and tApiMirroringGL.tcMirror2ProjectCode <> ?
then do:
/* Do nothing here, just use this value */
end.
else if (vcMatchingType = "Normal" and iccrprj <> "":U and iccrprj <> ?) or
(vcMatchingType = "Reverse" and icdrprj <> "":U and icdrprj <> ?)
then
assign tApiMirroringGL.tcMirror2ProjectCode = (if vcMatchingType = "Normal" then iccrprj else icdrprj).
else do:
<Q-13 run GLByIDForProjectInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tApiMirroringGL.Mirror2GL_ID, (GLID)
input ?, (GLCode)
output dataset tqGLByIDForProjectInfo) in BGL >
for first tqGLByIdForProjectInfo:
tApiMirroringGL.tcMirror2ProjectCode = tqGLByIdForProjectInfo.tcProjectCode.
end.
end.
end. /* if vlMirror2IsProjectAccount */
end. /* if available tApiMirroringGL */
/* zjc: defect 10249 - 0229 end */
assign oiReturnStatus = viLocalStatus.
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 = "BMirroringGL".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiRetrieveMirroringGL".
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/bmirroringgl.apiretrievemirroringgl.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icdracct = <parameter value>
vhParameter::iccracct = <parameter value>
vhParameter::icdrsub = <parameter value>
vhParameter::iccrsub = <parameter value>
vhParameter::icdrcc = <parameter value>
vhParameter::iccrcc = <parameter value>
vhParameter::icdrprj = <parameter value>
vhParameter::iccrprj = <parameter value>
vhParameter::icDomainCode = <parameter value>
vhParameter::icCompanyCode = <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.