project QadFinancials > class BDDocument > method ApiStdMaintainTTWithoutAddUpd

Description

This general method can be used for creation of debtor documents (currently this method does not support neither modification nor deletion of existing debtor documents). But this method never does other financial updates (like generation of posting or updated of allocated invoices).
Usage of this methods needs to be done after carefull consideration.

Creation of debtor documents is done in separate transactions (one debtor document by one). List of succesfully created documents is stored in returning list.

Instead of creation of debtor documents, user has also option to execute just validation of incomming data or to store this debtor document in draft status.


Parameters


tApiDDocumentinputtemp-tableIncomming termporary table containing all data needed for creation of debtor documents.

Table schema:

List of fields used by this integration method
tcBusinessRelationCode Code of debtor's business relation
tcBusinessRelationName Name of debtor's business relation
tcCreationUsrLogin Login of user who created debtor document (automatically assigned by system during save)
tcCurrencyCode Code of debtor document's currency
tcCustomCombo0 Custom defined field
tcCustomCombo1 Custom defined field
tcCustomCombo2 Custom defined field
tcCustomCombo3 Custom defined field
tcCustomCombo4 Custom defined field
tcCustomCombo5 Custom defined field
tcCustomCombo6 Custom defined field
tcCustomCombo7 Custom defined field
tcCustomCombo8 Custom defined field
tcCustomCombo9 Custom defined field
tcCustomLong0 Custom defined field
tcCustomLong1 Custom defined field
tcCustomNote Custom defined field
tcCustomShort0 Custom defined field
tcCustomShort1 Custom defined field
tcCustomShort2 Custom defined field
tcCustomShort3 Custom defined field
tcCustomShort4 Custom defined field
tcCustomShort5 Custom defined field
tcCustomShort6 Custom defined field
tcCustomShort7 Custom defined field
tcCustomShort8 Custom defined field
tcCustomShort9 Custom defined field
tcDDocumentIncassoSelectCode Incasso selection code of debtor document
tcDDocumentReference Reference of debtor document
tcDDocumentStatus Status of debtor document
- Initial
- Accepted
- Portfolio
- For collection
- Disconto
- Bounced
- Paid
- Paid conditionally
tcDDocumentSubType Indication of way, debtor document was created
- Automatic
- Manual
tcDDocumentType Type of debtor document
- Check
- Direct debit
- Draft
- Promissory note
tcDebtorBankNumber Debtor's bank number
tcDebtorCode Code of debtor
tcGLCode G/L code linked to company's bank number
tcLastModifiedUser Login of the user, who did modification of the record last time (automatically assigned by system during save)
tcOwnBankNumber Company's bank number debtor document is payed from
tcPayFormatTypeCode Payment format used for payment
tcPaymentLevelPayCode
tcPostingRowId Row ID of created posting (internally used)
tdCustomDecimal0 Custom defined field
tdCustomDecimal1 Custom defined field
tdCustomDecimal2 Custom defined field
tdCustomDecimal3 Custom defined field
tdCustomDecimal4 Custom defined field
tdDDocumentExchangeRate Exchange rate
tdDDocumentOriginalCreditBC Original credit amount
tdDDocumentOriginalCreditCC Original credit amount of debtor document in consolidation currency
tdDDocumentOriginalCreditLC Original credit amount of debtor document in local currency
tdDDocumentOriginalCreditTC Original credit amount of debtor document in transactional currency
tdDDocumentOriginalDebitBC Original debit amount of debtor document
tdDDocumentOriginalDebitCC Original debit amount of debtor document in consolidation currency
tdDDocumentOriginalDebitLC Original debit amount of debtor document in local currency
tdDDocumentOriginalDebitTC Original debit amount of debtor document in trasactional currency
tdDDocumentRateScale Exchange rate scale
tiBankNumber_ID ID of debtor's bank number
tiCreationUsr_ID ID of user who created debtor document
tiCurrency_ID ID of currency of debtor document
tiCustomInteger0 Custom defined field
tiCustomInteger1 Custom defined field
tiCustomInteger2 Custom defined field
tiCustomInteger3 Custom defined field
tiCustomInteger4 Custom defined field
tiDDocumentCreationTime Creation time of debtor document
tiDDocumentTimesPrinted Number of times document have been printed
tiDDocumentValueDays
tiDDocumentYear Year of debtor document
tiDebtor_ID ID of debtor
tiDPaySel_ID ID of payment selection this document is part of
tiGL_ID ID of G/L account linked to company bank number
tiLastModifiedTime Last modified time of the debtor document (automatically assined during save)
tlDDocumentIsOpen Is debtor document open?
tlInvoicesLinked Are there any lineked invoices?
ttCustomDate0 Custom defined field
ttCustomDate1 Custom defined field
ttCustomDate2 Custom defined field
ttCustomDate3 Custom defined field
ttCustomDate4 Custom defined field
ttDDocumentClosingDate Closing date of debtor document (was payed or voided)
ttDDocumentCreationDate Creation date of debtor document
ttDDocumentDueDate Due date of debtor document
ttDDocumentLastPrintDate Last date document was printed
ttLastModifiedDate Last modification date of debtor document (automatically assigned during save)
ttPostingDate Posting date of debtor document

List of fields not used by this integration method
tiCompany_ID ID of company where debtor document was/is created
tiDCollection_ID ID of collection this debtor document is part of
tiDDocumentNumber Number of debtor document
tiDDocument_ID ID of debtor document
tApiDDocumentInvoiceXrefinputtemp-tableTable containing list of allocated invoices of the debtor document.

Table schema:
- tcAllocAmountCrDt
- tcBusinessRelationCode
- tcBusinessRelationName1
- tcCompanyCode
- tcCorporateGroupCode
- tcCostCentreCode
- tcCurrencyCode
- tcDebtorCode
- tcDInvoiceBalanceCrDt
- tcDInvoiceDIText
- tcDInvoiceReference
- tcDInvoiceType
- tcDivisionCode
- tcLastModifiedUser
- tcNewBalanceCrDt
- tcProjectCode
- tcShipperCode
- tcVatBaseCrDt
- tcVatCountryCode
- tcVatCrDt
- tdDDocumentInvoiceXrefAlloTC
- tdDDocumentInvoiceXrefDiscTC
- tdDefaultDiscountAmount
- tdDefaultPaymentAmount
- tdDInvoiceBalance
- tdDiscountPercentage
- tdNewBalance
- tdVatBaseTC
- tdVatTC
- tiDDocument_ID
- tiDDocumentInvoiceXref_ID
- tiDInvoice_ID
- tiDInvoicePostingId
- tiLastModifiedTime
- tlDiscountTaxAtPayment
- tlUIFullAllocation
- ttDInvoiceDate
- ttDInvoiceDiscountDueDate
- ttDInvoiceDueDate
- ttLastModifiedDate
tApiDDocumentPostingLineinputtemp-tableThis table is not used by this method. In fact records in corresponding database table are created automatically during submit process of debtor document.
icActioninputcharacterAction to be done with content of temporary table
- {&DAEMONACTION-SAVESTORE} Save as Draft/Submit
- {&DAEMONACTION-SAVE} Save as Draft
- {&DAEMONACTION-STORE} Submit
- {&DAEMONACTION-VALIDATE} Validate
ocLstPrimKeyoutputcharacterThis chr(4) separated list contains DDocument_IDs created during processing of records in input temporary table. Items of list are linked to the same list item in ocLstReturn and ocLstRowid lists.
ocLstReturnoutputcharacterList of return statuses populated during processing of imcomming records. List if chr(4) separated. Items of list are linked to the same list item in ocLstPrimKey and ocLstRowid lists.
ocLstRowidoutputcharacterList of RowIds of created debtor document records. List is chr(4) separated. Items of list are linked to the same list item in ocLstPrimKey and ocLstReturn lists.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program9/bddocument.p)

/* ====================================================================================================== */
/* This method allows to create DDocuments without any of the postings or updates to the linked invoices. */
/* Also, no collections will be made, so it's not allowed to pass documents with status INCASSO or        */
/* DISCONTO.                                                                                              */
/* ====================================================================================================== */

/* ====================================================================================================== */
/* About the vlSkipAdditionalUpdates data item:                                                           */
/* When using the ApiStdMaintainTTWithoutAddUpd method to create documents (the people from conversion    */
/* will use it), it should be possible to create just the documents with its invoice links, but without   */
/* any other updates to the linked invoices or the postings... We will use this variable to check it.     */
/*                                                                                                        */
/* * In InitInstance, it will be set to false.                                                            */
/* * In ApiStdMaintainTT, it will be set to true.                                                         */
/* ====================================================================================================== */

/* Remove the documents with status INCASSO or DISCONTO */
for each tApiDDocument where
         tApiDDocument.DDocumentStatus = {&DOCUMENTSTATUS-DISCONT} or
         tApiDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INCASSO}:
    delete tApiDDocument.
end.

/* Check if a DDocument record was passed */
if not can-find(first tApiDDocument)
then do:
     <M-2 run SetMessage
          (input  trim(#T-2'No customer payment record was passed. The system is unable to continue.':250(31711)t-2#) (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QadFin-5421':U (icFcMsgNumber), 
           input  '':U (icFcExplanation), 
           input  '':U (icFcIdentification), 
           input  '':U (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDDocument>
                     
    assign oiReturnStatus = -1.
    return.
end.

/* Initialize */
assign oiReturnStatus              = -98
       vlSkipAdditionalUpdatesDDoc = true.
       
/* Process the data using the standard Api method */
<M-3 run ApiStdMaintainTT (input  tApiDDocument (tApiDDocument), 
                           input  tApiDDocumentInvoiceXref (tApiDDocumentInvoiceXref), 
                           input  tApiDDocumentPostingLine (tApiDDocumentPostingLine), 
                           input  icAction (icAction), 
                           output ocLstPrimKey (ocLstPrimKey), 
                           output ocLstReturn (ocLstReturn), 
                           output ocLstRowid (ocLstRowid), 
                           output viFcReturnSuper (oiReturnStatus)) in BDDocument>

if viFcReturnSuper < 0 or
   oiReturnStatus  = -98
then assign oiReturnStatus = viFcReturnSuper.


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

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

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

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