| tApiDDocument | input | temp-table | Incomming 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 |
| tApiDDocumentInvoiceXref | input | temp-table | Table containing list of allocated invoices of the debtor document. Table schema: -------------------------------------------------------------------------------------------------------------------- Mandatory fields to have alloated invoice to Debtor document - tcDInvoiceReference Reference to debtor invoice to be allocated. Value has to comply with following format ("Year/Journal/Voucher"). - tdDDocumentInvoiceXrefAlloTC Allocated amount of debtor invoices - tdDDocumentInvoiceXrefDiscTC Applicated discount for payment - tc_ParentRowid Value of this field is used for relation towards parent record in tApiDDocument (has to be the same as tApiDDocument.tcRowId) Display fields only (all these fields are not used by this integration method, they are used on UI to display details about allocated invoice) - tcAllocAmountCrDt Indication of type of allocated amount (Debit or Credit). field - tcBusinessRelationCode - tcBusinessRelationName1 - tcCompanyCode - tcCorporateGroupCode - tcCostCentreCode - tcCurrencyCode - tcDebtorCode - tcDInvoiceBalanceCrDt - tcDInvoiceDIText - tcDInvoiceType - tcDivisionCode - tcLastModifiedUser - tcNewBalanceCrDt - tcProjectCode - tcShipperCode - tcVatBaseCrDt - tcVatCountryCode - tcVatCrDt - tdDefaultDiscountAmount - tdDefaultPaymentAmount - tdDInvoiceBalance - tdDiscountPercentage - tdNewBalance - tdVatBaseTC - tdVatTC - tiDDocument_ID - tiDDocumentInvoiceXref_ID - tiDInvoice_ID - tiDInvoicePostingId - tiLastModifiedTime - tlDiscountTaxAtPayment - tlUIFullAllocation - ttDInvoiceDate - ttDInvoiceDiscountDueDate - ttDInvoiceDueDate - ttLastModifiedDate |
| tApiDDocumentPostingLine | input | temp-table | This table is not used by this method. In fact records in corresponding database table are created automatically during submit process of debtor document. |
| icAction | input | character | Action to be done with content of temporary table - {&DAEMONACTION-SAVESTORE} Save/Create Draft - {&DAEMONACTION-SAVE} Save - {&DAEMONACTION-STORE} Create Draft - {&DAEMONACTION-VALIDATE} Validate |
| ocLstPrimKey | output | character | This 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. |
| ocLstReturn | output | character | List 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. |
| ocLstRowid | output | character | List 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. |
| oiReturnStatus | output | integer | Return status of the method. |
QadFinancials
/* =================================================================== */
/* At the moment, this method only supports creating DDocuments. */
/* It does NOT (yet) support modifying or deleting existing DDocuments */
/* =================================================================== */
/* ============================================================================================== */
/* About the vlSkipDueDateValidation data item: */
/* Normally, the due date of a document must be at least today. It cannot be in the past. */
/* However, when using the ApiStdMaintainTT method (the people from conversion will use it), */
/* it should be possible to have the due date in the past. We will use this variable to check it. */
/* */
/* * In InitInstance, it will be set to false. */
/* * In ApiStdMaintainTT, it will be set to true. */
/* ============================================================================================== */
/* Check if a DDocument record was passed */
if not can-find(first tApiDDocument)
then do:
<M-1 run SetMessage
(input trim(#T-1'No customer payment record was passed. The system is unable to continue.':250(31711)t-1#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4867':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
return.
end.
/* Check if the action that was passed is valid */
if icAction <> {&DAEMONACTION-SAVESTORE} and
icAction <> {&DAEMONACTION-SAVE} and
icAction <> {&DAEMONACTION-STORE} and
icAction <> {&DAEMONACTION-VALIDATE}
then do:
<M-3 run SetMessage (input trim(#T-3'An invalid action ($1) was passed. Valid options are: $2.':250(31713)t-3#) (icMessage),
input icAction + chr(2) + {&DAEMONACTION-SAVE-TR} + ', ':U + {&DAEMONACTION-SAVESTORE-TR} + ', ':U + {&DAEMONACTION-STORE-TR} + ' and ':U + {&DAEMONACTION-VALIDATE-TR} (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4868':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
viCount = 0
vlSkipDueDateValidationDDoc = true
vlStart1 = false.
/* Process the data */
for each tApiDDocument:
assign vcDDocumentType = <M-8 GetDDocumentTypeTranslation (input tApiDDocument.DDocumentType (icType)) in BDDocument>
viCount = viCount + 1
vlWarningsFound = false.
DDOCUMENT_BLOCK:
do:
/* Create the Document */
<M-4 run DataNew (output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstRowid = ocLstRowid + chr(4) + "*":U.
<M-5 run SetMessage
(input trim(#T-4'The system cannot create a new customer payment.':250(31714)t-4#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4869':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
leave DDOCUMENT_BLOCK.
end.
else assign vlWarningsFound = viFcReturnSuper > 0.
buffer-copy tApiDDocument
except tApiDDocument.Company_ID
tApiDDocument.DCollection_ID
tApiDDocument.DDocumentNumber
tApiDDocument.DDocument_ID
tApiDDocument.tc_ParentRowid
tApiDDocument.tc_Rowid
tApiDDocument.tc_Status
to tDDocument.
assign tApiDDocument.DDocument_ID = tDDocument.DDocument_ID
vcRowid = tDDocument.tc_Rowid
vhFcComponent = ?.
<M-6 run GetNumber
(input tDDocument.Company_ID (iiCompanyId),
input tDDocument.DDocumentYear (iiNumbrYear),
input 'D':U + tDDocument.DDocumentType (icNumbrType),
output tDDocument.DDocumentNumber (oiNumber),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
if viFcReturnSuper < 0
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstRowid = ocLstRowid + chr(4) + tDDocument.tc_Rowid.
<M-7 run SetMessage
(input trim(#T-5'The system cannot retrieve a new number for the customer payment with year $1 and type $2.':250(31715)t-5#) (icMessage),
input string(tDDocument.DDocumentYear) + chr(2) + vcDDocumentType (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tDDocument.tc_Rowid (icRowid),
input 'QadFin-4870':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
leave DDOCUMENT_BLOCK.
end.
else assign vlWarningsFound = viFcReturnSuper > 0.
/* Determine BankNumber_ID if not specified */
if tDDocument.BankNumber_ID = ? or tDDocument.BankNumber_ID = 0
then do:
if viBBankNumber2ID = 0 or viBBankNumber2ID = ?
then do:
<I-27 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BBankNumber"}>
end.
else do:
<I-28 {bFcOpenInstance
&CLASS = "BBankNumber"}>
end.
<M-26 run GetParentBankData
(input tDDocument.Company_ID (iiCompanyID),
input ? (icCreditorCode),
input tDDocument.tcDebtorCode (icDebtorCode),
input tDDocument.DDocumentType (icPaymentInstrument),
output tDDocument.BankNumber_ID (oiBankNumberID),
output tDDocument.tcDebtorBankNumber (ocBankNumber),
output vcBankNumberExtension (ocBankNumberExtension),
input ? (icOwnBankNumber),
input ? (icGLCode),
output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
if viFcReturnSuper < 0
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstRowid = ocLstRowid + chr(4) + tDDocument.tc_Rowid.
<M-23 run SetMessage
(input trim(#T-12'The system cannot determine the customer bank for the payment.':250(61007)t-12#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tDDocument.tc_Rowid (icRowid),
input 'QadFin-6238':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
leave DDOCUMENT_BLOCK.
end.
else assign vlWarningsFound = viFcReturnSuper > 0.
end. /* if tDDocument.BankNumber_ID = ? or tDDocument.BankNumber_ID = 0 */
/* Determine GL and PayFormatTypeCode based upon the BankNumber_ID - if necessary */
if tDDocument.BankNumber_ID <> ? and
tDDocument.BankNumber_ID <> 0 and
(((tDDocument.GL_ID = ? or
tDDocument.GL_ID = 0) and
(tDDocument.tcGLCode = ? or
tDDocument.tcGLCode = "":U)) OR
(tDDocument.tcPayFormatTypeCode = ? or
tDDocument.tcPayFormatTypeCode = "":U))
then do:
<Q-79 run BankNumberOwnBankGLByID (all) (Read) (Cache)
(input tDDocument.BankNumber_ID, (BankNumber_ID)
input ?, (CompanyId)
output dataset tqBankNumberOwnBankGLByID) in BBankNumber>
find first tqBankNumberOwnBankGLByID where
tqBankNumberOwnBankGLByID.tiBankNumber_ID = tDDocument.BankNumber_ID
no-lock no-error.
if available tqBankNumberOwnBankGLByID
then do :
if (tDDocument.GL_ID = ? or
tDDocument.GL_ID = 0) and
(tDDocument.tcGLCode = ? or
tDDocument.tcGLCode = "":U)
then assign tDDocument.GL_ID = tqBankNumberOwnBankGLByID.tiGL_ID
tDDocument.tcGLCode = tqBankNumberOwnBankGLByID.tcGLCode.
if tDDocument.tcPayFormatTypeCode = ? or
tDDocument.tcPayFormatTypeCode = "":U
then assign tDDocument.tcPayFormatTypeCode = tqBankNumberOwnBankGLByID.tcPayFormatTypeCode
tDDocument.tcOwnBankNumber = tqBankNumberOwnBankGLByID.tcOwnBankNumber.
end. /* if available tqBankNumberOwnBankGLByID */
end. /* if tDDocument.BankNumber_ID <> ? and */
/* Process linked invoices */
for each tApiDDocumentInvoiceXref where
tApiDDocumentInvoiceXref.tc_ParentRowid = tApiDDocument.tc_Rowid:
<M-9 run AddDetailLine (input 'DDocumentInvoiceXref':U (icTable),
input tDDocument.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstRowid = ocLstRowid + chr(4) + tDDocument.tc_Rowid.
<M-10 run SetMessage (input trim(#T-6'The system cannot create a new customer payment invoice cross-reference':250(31716)t-6#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4871':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
leave DDOCUMENT_BLOCK.
end.
else assign vlWarningsFound = viFcReturnSuper > 0.
buffer-copy tApiDDocumentInvoiceXref
except tApiDDocumentInvoiceXref.DDocument_ID
tApiDDocumentInvoiceXref.DDocumentInvoiceXref_ID
tApiDDocumentInvoiceXref.tc_ParentRowid
tApiDDocumentInvoiceXref.tc_Rowid
tApiDDocumentInvoiceXref.tc_Status
to tDDocumentInvoiceXref.
if not vlStart1
then do:
<Q-19 run DInvoiceByYearJournalVoucher (Start) in BDInvoice >
assign vlStart1 = true.
end.
if tApiDDocumentInvoiceXref.tcCompanyCode <> "":U or
tApiDDocumentInvoiceXref.tcCompanyCode <> ?
then do :
<Q-63 run CompanyByCompanyIdCode (all) (Read) (NoCache)
(input ?, (CompanyId)
input tApiDDocumentInvoiceXref.tcCompanyCode, (CompanyCode)
output dataset tqCompanyByCompanyIdCode) in BCompany>
find first tqCompanyByCompanyIdCode
where tqCompanyByCompanyIdCode.tcCompanyCode = tApiDDocumentInvoiceXref.tcCompanyCode no-error .
if available tqCompanyByCompanyIdCode
then assign viInvCompanyID = tqCompanyByCompanyIdCode.tiCompany_ID .
end.
else assign viInvCompanyID = ?.
<Q-86 run DInvoiceByYearJournalVoucher (all) (Read) (Cache)
(input viinvCompanyId, (CompanyId)
input int(entry(1, tDDocumentInvoiceXref.tcDInvoiceReference, '/':U)), (DInvoicePostingYear)
input entry(2, tDDocumentInvoiceXref.tcDInvoiceReference, '/':U), (JournalCode)
input int(entry(3, tDDocumentInvoiceXref.tcDInvoiceReference, '/':U)), (DInvoiceVoucher)
output dataset tqDInvoiceByYearJournalVoucher) in BDInvoice>
find first tqDInvoiceByYearJournalVoucher where
tqDInvoiceByYearJournalVoucher.tiCompany_ID = viinvCompanyId and
tqDInvoiceByYearJournalVoucher.tiDInvoicePostingYear = int(entry(1, tDDocumentInvoiceXref.tcDInvoiceReference, "/":U)) and
tqDInvoiceByYearJournalVoucher.tcJournalCode = entry(2, tDDocumentInvoiceXref.tcDInvoiceReference, "/":U) and
tqDInvoiceByYearJournalVoucher.tiDInvoiceVoucher = int(entry(3, tDDocumentInvoiceXref.tcDInvoiceReference, "/":U))
no-error.
if not available tqDInvoiceByYearJournalVoucher
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstRowid = ocLstRowid + chr(4) + tDDocument.tc_Rowid.
<M-12 run SetMessage
(input trim(#T-7'The customer invoice with year $1, daybook $2, and voucher $3 is not defined in the system.':250(31717)t-7#) (icMessage),
input entry(1, tDDocumentInvoiceXref.tcDInvoiceReference, '/':U) + chr(2) + entry(2, tDDocumentInvoiceXref.tcDInvoiceReference, '/':U) + chr(2) + entry(3, tDDocumentInvoiceXref.tcDInvoiceReference, '/':U) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tDDocument.tc_Rowid (icRowid),
input 'QadFin-4872':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
leave DDOCUMENT_BLOCK.
end.
else assign vlWarningsFound = viFcReturnSuper > 0.
assign tDDocumentInvoiceXref.DInvoice_ID = tqDInvoiceByYearJournalVoucher.tiDInvoice_ID
tDDocumentInvoiceXref.tcCurrencyCode = tqDInvoiceByYearJournalVoucher.tcCurrencyCode
tDDocumentInvoiceXref.tcDivisionCode = tqDInvoiceByYearJournalVoucher.tcDivisionCode
tDDocumentInvoiceXref.tcAllocAmountCrDt = if tqDInvoiceByYearJournalVoucher.tdDInvoiceOriginalCreditTC <> 0 and
tqDInvoiceByYearJournalVoucher.tdDInvoiceOriginalCreditTC <> ?
then {&CREDITDEBITABBREVIATION-DEBIT}
else {&CREDITDEBITABBREVIATION-CREDIT}
tDDocumentInvoiceXref.tcDInvoiceBalanceCrDt = if tqDInvoiceByYearJournalVoucher.tdDInvoiceOriginalCreditTC <> 0 and
tqDInvoiceByYearJournalVoucher.tdDInvoiceOriginalCreditTC <> ?
then {&CREDITDEBITABBREVIATION-CREDIT}
else {&CREDITDEBITABBREVIATION-DEBIT}.
end.
/* It stops here if only Save as Draft is needed */
if icAction = {&DAEMONACTION-STORE}
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + "0":U
ocLstRowid = ocLstRowid + chr(4) + tDDocument.tc_Rowid.
leave DDOCUMENT_BLOCK.
end.
/* Set Activity */
assign
vcActivityCode = "Create":U
vcLastRowID = tDDocument.tc_Rowid.
/* Validate the data en perform external updates */
<M-13 run ValidateBCAndAdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BDDocument>
/* Bring the record back in scope */
find tDDocument where tDDocument.tc_Rowid = vcLastRowID.
if viFcReturnSuper < 0
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstRowid = ocLstRowid + chr(4) + tDDocument.tc_Rowid.
leave DDOCUMENT_BLOCK.
end.
else assign vlWarningsFound = viFcReturnSuper > 0.
/* Save the data */
if icAction <> {&DAEMONACTION-VALIDATE}
then do:
<M-14 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0
then do:
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstRowid = ocLstRowid + chr(4) + tDDocument.tc_Rowid.
leave DDOCUMENT_BLOCK.
end.
else assign vlWarningsFound = viFcReturnSuper > 0.
end.
/* Indicate that everything went fine */
assign ocLstPrimKey = ocLstPrimKey + chr(4) + string(tApiDDocument.DDocument_ID)
ocLstReturn = ocLstReturn + chr(4) + if vlWarningsFound then "1":U else "0":U
ocLstRowid = ocLstRowid + chr(4) + vcRowid.
end.
/* Store Draft if needed */
if icAction = {&DAEMONACTION-SAVESTORE} and
substr(entry(num-entries(ocLstReturn, chr(4)), ocLstReturn, chr(4)), 1, 1, "CHARACTER":U) <> "-":U or
icAction = {&DAEMONACTION-STORE}
then do:
<M-15 run StoreState
(input string(tDDocument.DDocumentYear) + ' ':U + vcDDocumentType + ' ':U + string(tDDocument.DDocumentNumber) + ' ':U + trim(#T-8'The customer payment was created using an API method.':250(31718)t-8#) (icDescription),
input ? (icUIClass),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign entry(num-entries(ocLstReturn, chr(4)), ocLstReturn, chr(4)) = string(viFcReturnSuper).
end.
end.
/* close the Banknumber instance */
if valid-handle(vhBBankNumber2Inst)
then. /* ========================================================================================================= */
/* Normally we would here close BBankNumber but we will not do it for performance */
/* reasons as this way the Commit of the transaction does not have to re-open the instance to commit it. */
/* And in all other scenario's the instance of the class ill be closed by the de-activiate procedure of the */
/* appserver that is executed after each call to the appserver */
/* ========================================================================================================= */
/* Stop used queries */
if vlStart1
then do:
<Q-20 run DInvoiceByYearJournalVoucher (Stop) in BDInvoice >
end.
/* Check if everything went well */
assign ocLstPrimKey = substr(ocLstPrimKey, 2, -1, "CHARACTER":U)
ocLstReturn = substr(ocLstReturn , 2, -1, "CHARACTER":U)
ocLstRowid = substr(ocLstRowid , 2, -1, "CHARACTER":U).
if num-entries(ocLstPrimKey, chr(4)) <> viCount or
num-entries(ocLstReturn , chr(4)) <> viCount or
num-entries(ocLstRowid , chr(4)) <> viCount
then do:
<M-16 run SetMessage
(input trim(#T-9'Incorrect information was returned from DDocument.ApiStdMaintainTT: # records: $1, # PKs: $2, # Row IDs: $3, # RS's: $4.':250(31719)T-9#) (icMessage),
input string(viCount) + chr(2) + string(num-entries(ocLstPrimKey, chr(4))) + chr(2) + string(num-entries(ocLstRowid, chr(4))) + chr(2) + string(num-entries(ocLstReturn, chr(4))) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4873':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -3.
return.
end.
/* Finalize */
if ocLstReturn = fill("0":U + chr(4), viCount - 1) + "0":U
then assign oiReturnStatus = 0.
else
if index(ocLstReturn, "-":U) > 0
then do:
<M-17 run SetMessage (input trim(#T-10'An error occurred while running DDocument.ApiStdMaintainTT. Check other messages to see what went wrong.':250(31722)T-10#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4874':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
else do:
<M-18 run SetMessage (input trim(#T-11'A warning occurred while running DDocument.ApiStdMaintainTT. Check other messages to see what caused it.':250(31723)T-11#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4875':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = 1.
end.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 = "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/bddocument.apistdmaintaintt.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.