project QadFinancials > class BAPMatching > method ApiGetMatchingInfoBySiteItem
Description
ApiGetMatchingInfoBySiteItem;
non-remoring but api-enabled method that returns information for a bunch of receipts based upon the parameters
Parameters
icDomainCode | input | character | |
icSite | input | character | Site of the receipt |
icPart | input | character | Item of the receipt |
itReceiptDateFrom | input | date | From receipt date |
itReceiptDateTill | input | date | Till receipt date |
tMatchingInfoBySiteItem | output | temp-table | Temp-table holding the matching-infoprmation base upon the input values |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program9/bapmatching.p)
/* ====================== */
/* Exception handling */
/* Empty the output table */
/* ====================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
empty temp-table tMatchingInfoBySiteItem.
/* ================== */
/* Start block */
/* ================== */
DOAPIGETBLOCK : DO :
/* ============== */
/* Validate input */
/* ============== */
if icDomainCode = "":U or
icDomainCode = ?
then do :
assign viLocalReturnStatus = -1
vcMsgAPMatching = trim(substitute(#T-2'The domain is mandatory as input for the api-method.':255(733750148)T-2#)) + chr(10) +
trim(substitute(#T-5'Method: &1.':255(825524949)T-5#, "ApiGetMatchingInfoBySiteItem":U)).
<M-1 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9751':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Leave DOAPIGETBLOCK.
end. /* if icDomainCode = "":U or */
if itReceiptDateFrom > itReceiptDateTill
then do :
assign viLocalReturnStatus = -1
vcMsgAPMatching = trim(substitute(#T-13'The value for the From-Receipt-Date (&1) should preceed the To-Receipt-Date (&2).':255(606063502)T-13#, itReceiptDateFrom, itReceiptDateTill)) + chr(10) +
trim(substitute(#T-14'Method: &1.':255(825524949)T-14#, "ApiGetMatchingInfoBySiteItem":U)).
<M-12 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9752':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Leave DOAPIGETBLOCK.
end. /* if itReceiptDateFrom > itReceiptDateTill */
/* ========================================================================================================================================== */
/* Call query to get the required information. Note that the output of the query is to the level of the matching-lines-taxes and the output */
/* of this method should be on the level of the matching-lines. That's why the output-table of the query holds and index on APMatchingLineID. */
/* ========================================================================================================================================== */
<Q-11 run PurchaseReceiptHistoryForAPM (all) (Read) (NoCache)
(input ?, (CompanyId)
input icDomainCode, (Domain)
input icSite, (Site)
input ?, (PartFrom)
input ?, (PartTo)
input icPart, (Part)
input ?, (SiteFrom)
input ?, (SiteTo)
input (if itReceiptDateFrom = itReceiptDateTill then ? else itReceiptDateFrom), (ReceiptDateFrom)
input (if itReceiptDateFrom = itReceiptDateTill then ? else itReceiptDateTill), (ReceiptDateTill)
input (if itReceiptDateFrom = itReceiptDateTill then itReceiptDateFrom else ?), (ReceiptDate)
output dataset tqPurchaseReceiptHistoryForAPM) in BMfgPOReceipt >
/* ============================================================= */
/* Build up the method output based upon the output of the query */
/* ============================================================= */
for each tqPurchaseReceiptHistoryForAPM
break by tqPurchaseReceiptHistoryForAPM.tiAPMatchingLn_ID :
/* =================================================================== */
/* Create an output record for every matching-line in the query-result */
/* =================================================================== */
if first-of (tqPurchaseReceiptHistoryForAPM.tiAPMatchingLn_ID)
then do:
create tMatchingInfoBySiteItem.
assign tMatchingInfoBySiteItem.tcCompanyCode = tqPurchaseReceiptHistoryForAPM.tcCompanyCode
tMatchingInfoBySiteItem.tiCInvoicePostingYear = tqPurchaseReceiptHistoryForAPM.tiCInvoicePostingYear
tMatchingInfoBySiteItem.tcJournalCode = tqPurchaseReceiptHistoryForAPM.tcJournalCode
tMatchingInfoBySiteItem.tiCInvoiceVoucher = tqPurchaseReceiptHistoryForAPM.tiCInvoiceVoucher
tMatchingInfoBySiteItem.tcCurrencyCode = tqPurchaseReceiptHistoryForAPM.tcCurrencyCode
tMatchingInfoBySiteItem.tdAPMAtchingLnMatchQty = tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnMatchQty
tMatchingInfoBySiteItem.tdAPMAtchingLnMatchUnitPrice = tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnMatchUnitPrice
tMatchingInfoBySiteItem.tdAPMatchingLnReceiptAmtTC = tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnReceiptAmtTC
tMatchingInfoBySiteItem.tdAPMatchingLnReceiptAmtLC = tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnReceiptAmtLC
tMatchingInfoBySiteItem.tcSite = tqPurchaseReceiptHistoryForAPM.tcprh_site
tMatchingInfoBySiteItem.tcPart = tqPurchaseReceiptHistoryForAPM.tcprh_part
tMatchingInfoBySiteItem.ttReceiptDate = tqPurchaseReceiptHistoryForAPM.ttprh_rcp_date
tMatchingInfoBySiteItem.tiPvoID = tqPurchaseReceiptHistoryForAPM.tiPvoID
tMatchingInfoBySiteItem.tiPvodLineID = tqPurchaseReceiptHistoryForAPM.tiPvodLineID
tMatchingInfoBySiteItem.tcPvodProject = tqPurchaseReceiptHistoryForAPM.tcpvod_project.
end. /* if first-of (tqPurchaseReceiptHistoryForMatch.tiAPMatchingLn_ID) */
/* ================================================================================== */
/* Increase the tax-data in the output temp-table for every entry in the query-result */
/* ================================================================================== */
assign tMatchingInfoBySiteItem.tdAPMatchingLnTaxAINRecTaxTC = tMatchingInfoBySiteItem.tdAPMatchingLnTaxAINRecTaxTC + (if tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxAINRecTaxTC = ? then 0 else tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxAINRecTaxTC)
tMatchingInfoBySiteItem.tdAPMatchingLnTaxAIRecTaxTC = tMatchingInfoBySiteItem.tdAPMatchingLnTaxAIRecTaxTC + (if tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxAIRecTaxTC = ? then 0 else tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxAIRecTaxTC)
tMatchingInfoBySiteItem.tdAPMatchingLnTaxARNRecTaxTC = tMatchingInfoBySiteItem.tdAPMatchingLnTaxARNRecTaxTC + (if tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxARNRecTaxTC = ? then 0 else tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxARNRecTaxTC)
tMatchingInfoBySiteItem.tdAPMatchingLnTaxARRecTaxTC = tMatchingInfoBySiteItem.tdAPMatchingLnTaxARRecTaxTC + (if tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxARRecTaxTC = ? then 0 else tqPurchaseReceiptHistoryForAPM.tdAPMatchingLnTaxARRecTaxTC).
end. /* for each tqPurchaseReceiptHistoryForAPM */
END. /* DOAPIGETBLOCK */
/* ================== */
/* 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 = "BAPMatching".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiGetMatchingInfoBySiteItem".
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/bapmatching.apigetmatchinginfobysiteitem.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icDomainCode = <parameter value>
vhParameter::icSite = <parameter value>
vhParameter::icPart = <parameter value>
vhParameter::itReceiptDateFrom = <parameter value>
vhParameter::itReceiptDateTill = <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.