Description
This method return the Currency and Balance of the GL Account
Parameters
| iiGL_ID | input | integer | GL ID |
| icGLCode | input | character | |
| ocBankNumber | output | character | BankNumber |
| ocBankCurrencyCode | output | character | BankCurrencyCode |
| odBankBalanceBC | output | decimal | BankBalanceBC |
| oiBankNumber_ID | output | integer | BankNumber_ID |
| oiNumberOfDecimals | output | integer | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bpaymentselection.p)
/* get GL_ID if it isn't passed as an input parameter */
if iiGL_ID = ? or
iiGL_ID = 0
then do:
if icGLCode = "":U or
icGLCode = ?
then do:
<M-4 run SetMessage (input 'There was no GL passed to this method.':U (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-454':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
<Q-2 run GLPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input icGLCode, (GLCode)
input ?, (GLId)
output dataset tqGLPrim) in BGL >
find first tqGLPrim no-error.
if not available tqGLPrim
then do:
<M-3 run SetMessage (input '$1 is not a valid GL code':U (icMessage),
input icGLCode (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-453':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
else assign iiGL_ID = tqGLPrim.tiGL_ID.
end.
/* XS PWI 02/10/2007 not needed anymore, is now retrieved in calculate01 based on bankpayformat_id
/* get bank number */
assign vcBANKNUMBERTYPE_GL = {&BANKNUMBERPARENTTYPE-GL}.
<Q-1 run BankNumberByParentID (all) (Read) (NoCache)
(input iiGL_ID, (ParentObjectId)
input vcBANKNUMBERTYPE_GL, (BankNumberParentType)
input ?, (BankNumberIsDefault)
input viCompanyId, (CompanyId)
output dataset tqBankNumberByParentID) in BBankNumber >
/*JBA extra conditions added plus a new search 'mechanism' implemented
first try to find a default bank account
if no default bank account exists take the fist one*/
find first tqBankNumberByParentID where
tqBankNumberByParentID.tiParentObject_ID = iiGL_ID and
tqBankNumberByParentID.tiCompany_ID = viCompanyID and
tqBankNumberByParentID.tlBankNumberIsDefault = true no-error.
if not available tqBankNumberByParentID
then find first tqBankNumberByParentID where
tqBankNumberByParentID.tiParentObject_ID = iiGL_ID and
tqBankNumberByParentID.tiCompany_ID = viCompanyID no-error.
if available tqBankNumberByParentID
then assign ocBankNumber = if tqBankNumberByParentID.tcBankNumberFormatted <> ? and
tqBankNumberByParentID.tcBankNumberFormatted <> "":U
then tqBankNumberByParentID.tcBankNumberFormatted
else tqBankNumberByParentID.tcBankNumber
oiBankNumber_ID = tqBankNumberByParentID.tiBankNumber_ID.
XE */
/* get the currency of the account */
<Q-6 run GLForCurrency (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiGL_ID, (GLId)
input ?, (GLCode)
output dataset tqGLForCurrency) in BGL >
find first tqGLForCurrency no-error.
if not available tqGLForCurrency
then do:
<M-7 run SetMessage (input 'Invalid GL ID ($1) was passed to this procedure.':U (icMessage),
input string(iiGL_ID) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-462':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
if tqGLForCurrency.tlGLIsLocalCurrency
then assign ocBankCurrencyCode = vcCompanyLC
oiNumberOfDecimals = viCompanyLCDec.
else assign ocBankCurrencyCode = tqGLForCurrency.tcCurrencyCode
oiNumberOfDecimals = tqGLForCurrency.tiCurrencyNumberOfDecimals.
/* get account balance */
assign vhFcComponent = ?.
<M-5 run ApiGetAccountBalance (input 9999 (iiAccYear),
input 99 (iiAccPeriod),
input iiGL_ID (iiGL_ID),
input '':U (icGLCode),
input viCompanyId (iiCompanyID),
input '':U (icCompanyCode),
output vdBalanceLC (odBalanceLC),
output vdBalanceCC (odBalanceCC),
output vdBalanceTC (odBalanceTC),
output viFcReturnSuper (oiReturnStatus)) in BGL>
if tqGLForCurrency.tlGLIsLocalCurrency
then assign odBankBalanceBC = vdBalanceLC.
else assign odBankBalanceBC = vdBalanceTC.
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 = "BPaymentSelection".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiBankNumberInfo".
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/bpaymentselection.apibanknumberinfo.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiGL_ID = <parameter value>
vhParameter::icGLCode = <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.