project QadFinancials > class BCInvoiceJournalEntry > method ApiStdMaintainTT

Description

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

With this method you create creditor invoices with his related postings.

API annotation

Validation/Defaults:
- There can only be one CInvoice loaded at a time - There can be max two Postings (invoice/matching)
- There has to be one posting to a Supplier Control Account
- Reason should correspond with the Postings (tcReasonAllocationStatus)
- Validate (and/or default) exchange rates
- Validations on invoice amounts
- Default the default bank information if not specified in input temp-tables


Parameters


t_sApiCInvoiceCIJEinputtemp-tableInput temp-table holding the creditor invoice data to be created, updated or deleted.
t_sApiCInvoiceBankCIJEinputtemp-tableInput temp-table holding the bank reocrds of the creditor invoice to be created, updated or deleted.
t_sApiCInvoiceBankPayCodeCIJEinputtemp-tableInput temp-table holding the bank payment code records of the creditor invoice to be created, updated or deleted.
t_sApiCInvoiceMovementCIJEinputtemp-tableInput temp-table holding the movement records of the creditor invoice to be created, updated or deleted.
t_sApiCInvoicePOCIJEinputtemp-tableInput temp-table holding the purchase order records of the creditor invoice to be created, updated or deleted.
t_sApiCInvoicePostingCIJEinputtemp-tableInput temp-table holding the posting records of the creditor invoice to be created, updated or deleted.
t_sApiCInvoiceVatCIJEinputtemp-tableInput temp-table holding the vat records of the creditor invoice to be created, updated or deleted.
t_sApiCInvoiceStageCIJEinputtemp-tableInput temp-table holding the stage records of the creditor invoice to be created, updated or deleted.
t_sApiPostingCIJEinputtemp-tableInput temp-table holding the posting data to be created, updated or deleted.
t_sApiPostingLineCIJEinputtemp-tableInput temp-table holding the posting line data to be created, updated or deleted.
t_sApiPostingSafCIJEinputtemp-tableInput temp-table holding the posting saf data to be created, updated or deleted.
t_sApiPostingVatCIJEinputtemp-tableInput temp-table holding the posting vat data to be created, updated or deleted.
t_sApiPostingVatDelayCIJEinputtemp-tableInput temp-table holding the posting vat delay data 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.
ocLstPrimKeyoutputcharacterChar4 separated list with the primary keys of the newly created main-table records. The fields of a primkey are separated with Char2.
E.g. 1<Char2>2002<Char2>100<Char4>1<Char2>2002<Char2>101
ocLstReturnoutputcharacterChar4 separated list with the return-status of the newly created main-table records. Zero means no errors occured.
E.g. 0<Char4>-1<Char4>-504<Char4>1<Char4>0
ocLstRowidoutputcharacterChar4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. .
E.g.
-1<Char2>aox00098001<Char2>-26
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program9/bcinvoicejournalentry.p)

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

<M-54 run ApiStdMaintainTTV01
   (input  t_sApiCInvoiceCIJE (t_sApiCInvoiceCIJE), 
    input  t_sApiCInvoiceBankCIJE (t_sApiCInvoiceBankCIJE), 
    input  t_sApiCInvoiceBankPayCodeCIJE (t_sApiCInvoiceBankPayCodeCIJE), 
    input  t_sApiCInvoiceMovementCIJE (t_sApiCInvoiceMovementCIJE), 
    input  t_sApiCInvoicePOCIJE (t_sApiCInvoicePOCIJE), 
    input  t_sApiCInvoicePostingCIJE (t_sApiCInvoicePostingCIJE), 
    input  t_sApiCInvoiceVatCIJE (t_sApiCInvoiceVatCIJE), 
    input  t_sApiCInvoiceStageCIJE (t_sApiCInvoiceStageCIJE), 
    input  t_sApiCInvoiceWHTCIJE (t_sApiCInvoiceWHTCIJE), 
    input  t_sApiPostingCIJE (t_sApiPostingCIJE), 
    input  t_sApiPostingLineCIJE (t_sApiPostingLineCIJE), 
    input  t_sApiPostingSafCIJE (t_sApiPostingSafCIJE), 
    input  t_sApiPostingVatCIJE (t_sApiPostingVatCIJE), 
    input  t_sApiPostingVatDelayCIJE (t_sApiPostingVatDelayCIJE), 
    input  icAction (icAction), 
    output ocLstPrimKey (ocLstPrimKey), 
    output ocLstReturn (ocLstReturn), 
    output ocLstRowid (ocLstRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry>

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 = "BCInvoiceJournalEntry".
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/bcinvoicejournalentry.apistdmaintaintt.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icAction = <parameter value>.

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

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

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

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

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

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

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

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

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

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

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

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

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