project QadFinancials > class BCInvoice > method ApiStdMaintainTT

Description

This method can create new instances or update existing instances based on the content of the input temp-table. The action that is passed as a parameter will define if the records are saved, saved as draft or just validated.

If the creditor invoice can be found (based on his logical key : Company ID, posting year, journal code, voucher), the existing creditor invoice will be updated. If not, a new creditor invoice will be created.

API annotation

Here are some notes taxes when creating a Supplier Invoice.

* Initial invoices can either be marked as taxable, either as non-taxable. But if they are marked as taxable, then the tax-information will always be just the default one (the tax-info in CinvoiceVat passed in by the caller is simply ignored).

* The taxes can only be passed in by the caller (and thus stored and used by the Fin-application) in case the caller passes in the SI-posting as well. In all other cases the actual taxes will just be the default ones.

* If the taxes are passed in by the caller then it is required that all tax-data is properly filled in by the caller including the TaxTransactionType, TaxUsage, TaxEnvironment, TaxClass, TaxType, the required accounts/sub-accounts and the base- and tax-amount.


Parameters


tApiCInvoiceinputtemp-tableInput temp-table holding the creditor invoice data to be created, updated or deleted.
tApiCInvoiceBankinputtemp-tableInput temp-table holding the bank records linked to the creditor invoice to be created, updated or deleted.
tApiCInvoiceBankPayCodeinputtemp-tableInput temp-table holding the bank-pay-code records linked to the creditor invoice to be created, updated or deleted.
tApiCInvoiceMovementinputtemp-tableInput temp-table holding the Movement records linked to the creditor invoice to be created, updated or deleted.
tApiCInvoicePOinputtemp-tableInput temp-table holding the Purchase Order records linked to the creditor invoice to be created, updated or deleted.
tApiCInvoicePostinginputtemp-tableInput temp-table holding the posting records linked to the creditor invoice to be created, updated or deleted.
tApiCInvoiceVatinputtemp-tableInput temp-table holding the vat records linked to the creditor invoice to be created, updated or deleted.
tApiCInvoiceStageinputtemp-tableInput temp-table holding the stage records linked to the creditor invoice to be created, updated or deleted.
icActioninputcharacterThis parameter defines what should happen with the input data : -SAVE: Save the data if there were no errors, -SAVESTORE : Save the data if there were no errors. If there were errors, save as draft. -STORE : Save the data as draft -VALIDATE : Validate the input data, but do no save the data.
ocLstPrimKeyoutputcharacterCharacter 4 separated list with the primary keys of the newly created main-table records. The fields of the primary key are separated with Character 2.
ocLstReturnoutputcharacterChar 4 separated list with the return status of the newly created main-table records. Zero means not errors occurred.
ocLstRowidoutputcharacterChar 4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program9/bcinvoice.p)

/* ===================================*/
/* Call the new version of the method */
/* ===================================*/
empty temp-table tApiCInvoiceWHT.

<M-95 run ApiStdMaintainTTV01
   (input  tApiCInvoice (tApiCInvoice), 
    input  tApiCInvoiceBank (tApiCInvoiceBank), 
    input  tApiCInvoiceBankPayCode (tApiCInvoiceBankPayCode), 
    input  tApiCInvoiceMovement (tApiCInvoiceMovement), 
    input  tApiCInvoicePO (tApiCInvoicePO), 
    input  tApiCInvoicePosting (tApiCInvoicePosting), 
    input  tApiCInvoiceVat (tApiCInvoiceVat), 
    input  tApiCInvoiceStage (tApiCInvoiceStage), 
    input  tApiCInvoiceWHT (tApiCInvoiceWHT), 
    input  icAction (icAction), 
    output ocLstPrimKey (ocLstPrimKey), 
    output ocLstReturn (ocLstReturn), 
    output ocLstRowid (ocLstRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>

if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.


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 = "BCInvoice".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiStdMaintainTT".
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/bcinvoice.apistdmaintaintt.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icAction = <parameter value>.

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoice").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoiceBank").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoiceBankPayCode").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoiceMovement").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoicePO").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoicePosting").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoiceVat").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiCInvoiceStage").
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.