project QadFinancials > class BMfgPO > method ApiPOAndPendingVoucher
API query
Description
This query procedure is used to show all PO's that match the input criteria - including the fully received ones (used on the lookup of PO in the supplier nvoice UI)
Parameters
Internal usage
unused
program code (program7/bmfgpo.p)
/* Empty output table */
empty temp-table tqApiPOAndPendingVoucher.
/* Set filter */
assign vcPurchaseOrderFilter = "":U
vcCreditorCodeFilter = "":U
vcCurrencyCodeFilter = "":U.
for each tFilter:
case tFilter.tcBusinessFieldName:
when "icdomaincode":U
then assign vcDomainCodeFilter = tFilter.tcParameterValue.
when "tpo_mstr.po_nbr":U
then assign vcPurchaseOrderFilter = tFilter.tcParameterValue.
when "tpo_mstr.po_vend":U
then assign vcCreditorCodeFilter = tFilter.tcParameterValue.
when "tpo_mstr.po_curr":U
then assign vcCurrencyCodeFilter = tFilter.tcParameterValue.
when "tBusinessRelation.BusinessRelationName1":U
then assign vcBusinessRelationName1Filter = tFilter.tcParameterValue.
when "tpo_mstr.po_ord_date":U
then do:
assign vtOrderDateFilter = date(integer(substring(tFilter.tcParameterValue,5,2,"CHARACTER":U)),integer(substring(tFilter.tcParameterValue,7,2,"CHARACTER":U)),integer(substring(tFilter.tcParameterValue,1,4, "CHARACTER":U))) no-error.
if error-status:error
then do :
assign oiReturnStatus = -3
vcMessage = trim(substitute(#T-5'Internal error: date function failed based on following string &1.':255(71310)T-5#, tFilter.tcParameterValue)).
if error-status:num-messages > 0
then assign vcMessage = vcMessage + chr(10) +
trim(substitute(#T-6'Detailed info: &1 (&2)':252(49824)T-6#,error-status:Get-Message(1),string(error-status:Get-Number(1)))).
<M-7 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-8686':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMfgPO>
return.
end.
end.
end case.
end. /* for each tFilter */
/* Do not pass a value for iiCompanyID as we want this to be based upon the domain and not just the company */
<Q-3 run PendingVoucherForSelect (all) (Read) (NoCache)
(input vcDomainCodeFilter, (DomainCode)
input vcPurchaseOrderFilter, (PurchaseOrder)
input vcCreditorCodeFilter, (CreditorCode)
input vcCurrencyCodeFilter, (CurrencyCode)
input vtOrderDateFilter, (OrderDate)
input ?, (CompanyId)
input vcBusinessRelationName1Filter, (BusinessRelationName1)
output dataset tqPendingVoucherForSelect) in BMfgPendingVoucher >
assign viFcCount1 = 0.
for each tqPendingVoucherForSelect :
create tqApiPOAndPendingVoucher.
assign viFcCount1 = viFcCount1 + 1
tqApiPOAndPendingVoucher.ti_Sequence = viFcCount1
tqApiPOAndPendingVoucher.tc_Rowid = string(viFcCount1)
tqApiPOAndPendingVoucher.tcpo_nbr = tqPendingVoucherForSelect.tcpvo_order
tqApiPOAndPendingVoucher.ttpo_ord_date = tqPendingVoucherForSelect.ttpo_ord_date
tqApiPOAndPendingVoucher.tcpo_vend = tqPendingVoucherForSelect.tcpvo_supplier
tqApiPOAndPendingVoucher.tcpo_curr = tqPendingVoucherForSelect.tcpvo_curr
tqApiPOAndPendingVoucher.tcpo_cr_terms = tqPendingVoucherForSelect.tcpo_cr_terms
tqApiPOAndPendingVoucher.tcpo_site = tqPendingVoucherForSelect.tcpo_site
tqApiPOAndPendingVoucher.tcpo_ship = tqPendingVoucherForSelect.tcpo_ship
tqApiPOAndPendingVoucher.tcpvo_internal_ref = tqPendingVoucherForSelect.tcpvo_internal_ref
tqApiPOAndPendingVoucher.tcpvo_external_ref = tqPendingVoucherForSelect.tcpvo_external_ref
tqApiPOAndPendingVoucher.tcCreditorCode = tqPendingVoucherForSelect.tcCreditorCode
tqApiPOAndPendingVoucher.tcBusinessRelationCode = tqPendingVoucherForSelect.tcBusinessRelationCode
tqApiPOAndPendingVoucher.tcBusinessRelationName1 = tqPendingVoucherForSelect.tcBusinessRelationName1.
end. /* for each */
/* Do not pass a value for iiCompanyID as we want this to be based upon the domain and not just the company */
<Q-1 run PurchaseOrderForSelect (all) (Read) (NoCache)
(input vcDomainCodeFilter, (DomainCode)
input vcPurchaseOrderFilter, (PurchaseOrder)
input vcCreditorCodeFilter, (CreditorCode)
input vcCurrencyCodeFilter, (CurrencyCode)
input vtOrderDateFilter, (OrderDate)
input ?, (CompanyId)
input vcBusinessRelationName1Filter, (BusinessRelationName1)
output dataset tqPurchaseOrderForSelect) in BMfgPO >
for each tqPurchaseOrderForSelect :
if not can-find(tqApiPOAndPendingVoucher where
tqApiPOAndPendingVoucher.tcpo_nbr = tqPurchaseOrderForSelect.tcpo_nbr)
then do:
create tqApiPOAndPendingVoucher.
assign viFcCount1 = viFcCount1 + 1
tqApiPOAndPendingVoucher.ti_Sequence = viFcCount1
tqApiPOAndPendingVoucher.tc_Rowid = string(viFcCount1)
tqApiPOAndPendingVoucher.tcpo_nbr = tqPurchaseOrderForSelect.tcpo_nbr
tqApiPOAndPendingVoucher.ttpo_ord_date = tqPurchaseOrderForSelect.ttpo_ord_date
tqApiPOAndPendingVoucher.tcpo_vend = tqPurchaseOrderForSelect.tcpo_vend
tqApiPOAndPendingVoucher.tcpo_curr = tqPurchaseOrderForSelect.tcpo_curr
tqApiPOAndPendingVoucher.tcpo_cr_terms = tqPurchaseOrderForSelect.tcpo_cr_terms
tqApiPOAndPendingVoucher.tcpo_site = tqPurchaseOrderForSelect.tcpo_site
tqApiPOAndPendingVoucher.tcpo_ship = tqPurchaseOrderForSelect.tcpo_ship
tqApiPOAndPendingVoucher.tcCreditorCode = tqPurchaseOrderForSelect.tcCreditorCode
tqApiPOAndPendingVoucher.tcBusinessRelationCode = tqPurchaseOrderForSelect.tcBusinessRelationCode
tqApiPOAndPendingVoucher.tcBusinessRelationName1 = tqPurchaseOrderForSelect.tcBusinessRelationName1.
end. /* if not can-find(tqApiPOAndPendingVoucher where */
end. /* for each */
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 = "BMfgPO".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiPOAndPendingVoucher".
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/bmfgpo.apipoandpendingvoucher.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tFilter").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
vhParameter::<field-name-2> = <field-value-2>
...
/* 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.