project QadFinancials > class BBankNumber > method ApiGetBankNumberSections
Description
Retrieves the individual bank account number sections for each bank account number
Parameters
icBankAccountNumber | input | character | |
icBankAccountFormat | input | character | |
iiBankAccountNumberId | input | integer | |
tBankNumberSection | output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bbanknumber.p)
/* ==================================================================================== */
/* Method: ApiGetBankNumberSections */
/* Desc: This method retrieves bank number sections for bank account format, and */
/* if bank number is passed, this number splits to sections */
/* Params: icBankAccountNumber number of bank account */
/* icBankAccountFormat code of bank account format (is mandatory) */
/* iiBankAccountId ID of bank account (not mandatory) */
/* otBankNumberSections temporary table contains bank number sections */
/* of bank account format. Values are populated by */
/* splitted bank account number. */
/* ==================================================================================== */
assign oiReturnStatus = -98.
/* Clear the temp table */
empty temp-table tBankNumberSection.
/* Normalize input paramters */
if icBankAccountNumber = "":U then assign icBankAccountNumber = ?.
if icBankAccountFormat = "":U then assign icBankAccountFormat = ?.
if iiBankAccountNumberId = 0 then assign iiBankAccountNumberId = ?.
/* Validate input paramters */
if icBankAccountFormat = ?
then do:
assign oiReturnStatus = 0.
return.
end.
/* Get sections of bank account format */
<Q-4 run BankAccountFormatSectionByFrmt (all) (Read) (NoCache)
(input ?, (BankAccountFormatId)
input icBankAccountFormat, (BankAccountFormatCode)
output dataset tqBankAccountFormatSectionByFrmt) in BBankAccountFormat >
for each tqBankAccountFormatSectionByFrmt
by tqBankAccountFormatSectionByFrmt.tiBankAccFormatSectSequence:
create tBankNumberSection.
assign tBankNumberSection.tiBankNumber_ID = iiBankAccountNumberId
tBankNumberSection.tc_Rowid = tqBankAccountFormatSectionByFrmt.tc_rowid
tBankNumberSection.tiBankAccFormatSectSequence = tqBankAccountFormatSectionByFrmt.tiBankAccFormatSectSequence
tBankNumberSection.tcBankAccFormatSectLabel = tqBankAccountFormatSectionByFrmt.tcBankAccFormatSectLabel
tBankNumberSection.tiBankAccFormatSectLength = tqBankAccountFormatSectionByFrmt.tiBankAccFormatSectLength
tBankNumberSection.tlBankAccFormatSectIsMandat = tqBankAccountFormatSectionByFrmt.tlBankAccFormatSectIsMandat
tBankNumberSection.tlBankAccFormatSectIsLdZero = tqBankAccountFormatSectionByFrmt.tlBankAccFormatSectIsLdZero
tBankNumberSection.tcBankAccFormatSectDelimiter = tqBankAccountFormatSectionByFrmt.tcBankAccFormatSectDelimiter.
end.
/* Split bank account format to individual sections */
if icBankAccountNumber <> ?
then do:
/* The bank account number that is input might contain separators */
/* Remove these separators (blank,.,-,/) before splitting up the */
/* values for the different sections */
assign icBankAccountNumber = replace(icBankAccountNumber,".":U,"":U)
icBankAccountNumber = replace(icBankAccountNumber,"-":U,"":U)
icBankAccountNumber = replace(icBankAccountNumber," ":U,"":U)
icBankAccountNumber = replace(icBankAccountNumber,"/":U,"":U).
assign viStartPos = 1.
for each tBankNumberSection:
assign tBankNumberSection.tcSectionValue = substring(icBankAccountNumber,
viStartPos,
tBankNumberSection.tiBankAccFormatSectLength,
"CHARACTER")
viStartPos = viStartPos + tBankNumberSection.tiBankAccFormatSectLength.
end.
end.
/* Return */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.
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 = "BBankNumber".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiGetBankNumberSections".
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/bbanknumber.apigetbanknumbersections.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icBankAccountNumber = <parameter value>
vhParameter::icBankAccountFormat = <parameter value>
vhParameter::iiBankAccountNumberId = <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.