t_sApiCInvoiceCIJE | input | temp-table | Input temp-table holding the creditor invoice data to be created, updated or deleted. |
t_sApiCInvoiceBankCIJE | input | temp-table | Input temp-table holding the bank reocrds of the creditor invoice to be created, updated or deleted. |
t_sApiCInvoiceBankPayCodeCIJE | input | temp-table | Input temp-table holding the bank payment code records of the creditor invoice to be created, updated or deleted. |
t_sApiCInvoiceMovementCIJE | input | temp-table | Input temp-table holding the movement records of the creditor invoice to be created, updated or deleted. |
t_sApiCInvoicePOCIJE | input | temp-table | Input temp-table holding the purchase order records of the creditor invoice to be created, updated or deleted. |
t_sApiCInvoicePostingCIJE | input | temp-table | Input temp-table holding the posting records of the creditor invoice to be created, updated or deleted. |
t_sApiCInvoiceVatCIJE | input | temp-table | Input temp-table holding the vat records of the creditor invoice to be created, updated or deleted. |
t_sApiCInvoiceStageCIJE | input | temp-table | Input temp-table holding the stage records of the creditor invoice to be created, updated or deleted. |
t_sApiCInvoiceWHTCIJE | input | temp-table | Input temp-table holding the wht records of the creditor invoice to be created, updated or deleted. |
t_sApiPostingCIJE | input | temp-table | Input temp-table holding the posting data to be created, updated or deleted. |
t_sApiPostingLineCIJE | input | temp-table | Input temp-table holding the posting line data to be created, updated or deleted. |
t_sApiPostingSafCIJE | input | temp-table | Input temp-table holding the posting saf data to be created, updated or deleted. |
t_sApiPostingVatCIJE | input | temp-table | Input temp-table holding the posting vat data to be created, updated or deleted. |
t_sApiPostingVatDelayCIJE | input | temp-table | Input temp-table holding the posting vat delay data to be created, updated or deleted. |
icAction | input | character | This 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. |
ocLstPrimKey | output | character | Char4 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 |
ocLstReturn | output | character | Char4 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 |
ocLstRowid | output | character | Char4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. . E.g. -1<Char2>aox00098001<Char2>-26 |
oiReturnStatus | output | integer | Return status of the method. |
/* =============================== */ /* Set Default Return + Initialise */ /* =============================== */ assign oiReturnStatus = -98 ocLstReturn = "":U ocLstPrimKey = "":U ocLstRowid = "":U. /* ============================================================== */ /* Call method that can extend the tApi-tables with some defaults */ /* ============================================================== */ <M-38 run ApiStdMaintainTTInitialDefaulting (output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> if viFcReturnSuper <> 0 then do: assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. end. /* if viFcReturnSuper <> 0 */ /* =============================== */ /* Validate the action */ /* =============================== */ if icAction = ? or icAction = "":U then assign icAction = {&DAEMONACTION-SAVE}. if icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE} then do: assign vcMsgApi = trim(substitute(#T-50'An invoice/journal entry integration error occurred. The specified action (&1) must be in this list: &2':255(336130326)T-50#,trim(icAction),"{&DAEMONACTION-SAVE},{&DAEMONACTION-VALIDATE}":U)) oiReturnStatus = -1. <M-6 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-2457':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> return. end. /* if icAction */ /* ===================================================================== */ /* Parameter Validation: */ /* - There can only be one CInvoice loaded at a time */ /* - There can be max two Postings */ /* - There can be just one CInvoice */ /* - Reason should correspond with the Postings (ReasonAllocationStatus) */ /* - default banking records */ /* ===================================================================== */ <M-66 run ApiStdMaintainTTValidationsAndDef (output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> if viFcReturnSuper <> 0 then do: assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. end. /* if viFcReturnSuper <> 0 */ /* ======================== */ /* Start / Open Transaction */ /* ======================== */ assign vlStartTransactionFromCIJE = false. if viTransactionId = 0 or viTransactionId = ? then do : <I-16 {bFcStartAndOpenInstance &ADD-TO-TRANSACTION = "true" &CLASS = "Transaction"}> assign vlStartTransactionFromCIJE = true. end. /* if viTransactionId = 0 or viTransactionId = ? */ else do: <I-17 {bFcOpenInstance &CLASS = "Transaction"}> end. /* Not if viTransactionId = 0 or viTransactionId = ? */ /* ====================== */ /* Start TransactionBlock */ /* ====================== */ BLOCKTRANSACTIONBLOCK : DO : /* ======================================================================= */ /* Check if we have an active transaction / start one if not yet available */ /* ======================================================================= */ <M-18 run StartTransaction (output viFcReturnSuper (oiReturnStatus)) in Transaction> if viFcReturnSuper <> 0 then do: assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then do : assign vcMsgApi = trim(#T-68'A Invoice/journal entry integration error occurred. The transaction not correctly started.':255(1259)T-68#). <M-67 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3300':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> <I-69 {bFcCloseInstance &CLASS = "Transaction"}> Leave BLOCKTRANSACTIONBLOCK. end. /* if viBlockReturnStatus < 0 */ end. /* if viFcReturnSuper <> 0 */ /* ========================================================================================================================= */ /* Normally we would here close the communication to class Transaction but we wont do it for performance reasons as this way */ /* the transaction does not have to be re-open when other instances are added to the transactionthe instance to commit it. */ /* ========================================================================================================================= */ /* ============================ */ /* start and open journal entry */ /* ============================ */ <I-21 {bFcStartAndOpenInstance &ADD-TO-TRANSACTION = "true" &CLASS = "BJournalEntry"}> assign vlBJournalEntryStarted = true. /* =============================================================================================== */ /* run ApiStdMaintainMulti in BJounalEntry: Both the CI-posting and the MF-posting will be created */ /* Note: keep BJOurnalEntry open during the BLOCK */ /* =============================================================================================== */ <M-61 run ApiStdMaintainMultiTT (input t_sApiPostingCIJE (tApiPosting), input t_sApiPostingLineCIJE (tApiPostingLine), input t_sApiPostingSafCIJE (tApiPostingSaf), input t_sApiPostingVatCIJE (tApiPostingVat), input t_sApiPostingVatDelayCIJE (tApiPostingVatDelay), input icAction (icAction), output vcLstPrimKey (ocLstPrimKey), output vcLstReturn (ocLstReturn), output vcLstRowId (ocLstRowid), output viFcReturnSuper (oiReturnStatus)) in BJournalEntry> if viFcReturnSuper <> 0 then do: assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then do : assign vcMsgApi = trim(substitute(#T-86'An error (&1) occurred while saving the postings for the new supplier invoices. See other messages for further details.':255(14414)T-86#,string(viFcReturnSuper))). <M-85 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3310':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> Leave BLOCKTRANSACTIONBLOCK. end. /* if viBlockReturnStatus < 0 */ end. /* if viFcReturnSuper <> 0 */ /* =============================== */ /* Hold the return-details already */ /* =============================== */ assign ocLstPrimKey = vcLstPrimKey ocLstReturn = vcLstReturn ocLstRowId = vcLstRowId. /* =========================================================== */ /* Write the posting-id in the tApiCInvoicePostingCIJE records */ /* =========================================================== */ <M-100 run ApiStdMaintainTTSub (input ocLstPrimKey (icLstPrimKey), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> if viFcReturnSuper <> 0 then do: assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then Leave BLOCKTRANSACTIONBLOCK. end. /* if viFcReturnSuper <> 0 */ /* ============================ */ /* start and open CI */ /* ============================ */ <I-80 {bFcStartAndOpenInstance &ADD-TO-TRANSACTION = "true" &CLASS = "BCInvoice"}> assign vlBCInvoiceStarted = true. /* =============================================================================================== */ /* run ApiStdMaintainTT in BCInvoice: name is instance of CI, value is instance of CIJE */ /* Note: keep BCInvoice open during the BLOCK */ /* Hold the return-details (in case of errors: before leaving the BLOCKTRANSACTIONBLOCK */ /* =============================================================================================== */ <M-43 run SetPublicData (input 'viBJournalEntryCIID':U (icDataList), input viBJournalEntryCIJEID (icValueList), output viFcReturnSuper (oiReturnStatus)) in BCInvoice> <M-26 run ApiStdMaintainTTV01 (input t_sApiCInvoiceCIJE (tApiCInvoice), input t_sApiCInvoiceBankCIJE (tApiCInvoiceBank), input t_sApiCInvoiceBankPayCodeCIJE (tApiCInvoiceBankPayCode), input t_sApiCInvoiceMovementCIJE (tApiCInvoiceMovement), input t_sApiCInvoicePOCIJE (tApiCInvoicePO), input t_sApiCInvoicePostingCIJE (tApiCInvoicePosting), input t_sApiCInvoiceVatCIJE (tApiCInvoiceVat), input t_sApiCInvoiceStageCIJE (tApiCInvoiceStage), input t_sApiCInvoiceWHTCIJE (tApiCInvoiceWHT), input icAction (icAction), output vcLstPrimKey (ocLstPrimKey), output vcLstReturn (ocLstReturn), output vcLstRowId (ocLstRowid), output viFcReturnSuper (oiReturnStatus)) in BCInvoice> assign ocLstPrimKey = vcLstPrimKey ocLstReturn = vcLstReturn ocLstRowId = vcLstRowId. if viFcReturnSuper <> 0 then do: assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then do : assign vcMsgApi = trim(substitute(#T-82'An error (&1) occurred while saving the new supplier invoice. See other messages for further details.':255(1261)T-82#,string(viFcReturnSuper))). <M-81 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3308':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> Leave BLOCKTRANSACTIONBLOCK. end. /* if viBlockReturnStatus < 0 */ end. /* if viFcReturnSuper <> 0 */ /* ================================================================================================================ */ /* Get Instance data from Supplier invoice component and store it in the class-level handle vhBCInvoiceInstanceData */ /* ================================================================================================================ */ if vlReturnCIInstanceDataCIJE = true then do : <M-7 run GetDBDatasetHandle (output vhBCInvoiceInstanceDataCIJE (ohHandleToTheClassDataset), output viFcReturnSuper (oiReturnStatus)) in BCInvoice> if viFcReturnSuper <> 0 then do: assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then Leave BLOCKTRANSACTIONBLOCK. end. /* if viFcReturnSuper <> 0 */ end. /* if vlReturnCIInstanceDataCIJE = true */ /* ======================================================================================= */ /* End TransactionBlock // Note: the transaction-component is always closed at this point */ /* ======================================================================================= */ END. /* BLOCKTRANSACTIONBLOCK */ /* ==================================================================== */ /* First close creditor invoice instance and the journal entry instance */ /* ==================================================================== */ if vlBCInvoiceStarted = true then. /* ========================================================================================================= */ /* Normally we would here close BCInvoice 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 */ /* ========================================================================================================= */ if vlBJournalEntryStarted = true then. /* ========================================================================================================= */ /* Normally we would here close BJournalEntry 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 */ /* ========================================================================================================= */ /* ==================================================================================== */ /* In case of errors, we need to perform AbortTransaction: otherwise the components are */ /* not correctly closed (important for the reset of the Numbering-mechanism) */ /* ==================================================================================== */ <I-87 {bFcOpenInstance &CLASS = "Transaction"}> if viBlockReturnStatus <> 0 /* check for errors in the big block */ then do: assign oiReturnStatus = viBlockReturnStatus. if oiReturnStatus < 0 then do : <M-88 run AbortTransaction (input ? (ihParentInstance), output vcDummy (ocInstances), output viFcReturnSuper (oiReturnStatus)) in Transaction> if viFcReturnSuper <> 0 then do : assign vcMsgApi = trim(substitute(#T-90'An error occurred while cancelling the transaction: &1. See other messages for further details.':255(14416)T-90#,string(viFcReturnSuper))). <M-89 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3311':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> end. /* if viFcReturnSuper <> 0 */ <I-91 {bFcCloseInstance &CLASS = "Transaction"}> return. end. /* if oiReturnStatus < 0 */ end. /* if viFcReturnSuper <> 0 */ /* ==================================================================================== */ /* The remove is needed because otherwise the commit tries to execute some methods that */ /* our parent-class (BusinessComponent) doesn't have. This also implicates that with */ /* the call towards CommitTransaction we do not pass a value for 'ihParentInstance' */ /* ==================================================================================== */ <M-31 run RemoveInstance (input viFcCurrentInstanceId (iiInstanceNr), output viFcReturnSuper (oiReturnStatus)) in Transaction> if viFcReturnSuper <> 0 then do: assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then do : assign vcMsgApi = trim(substitute(#T-99'An error occurred when removing the current instance from the transaction: &1. See other messages for further details.':255(14417)T-99#,string(viFcReturnSuper))). <M-98 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3314':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> <M-94 run AbortTransaction (input ? (ihParentInstance), output vcDummy (ocInstances), output viFcReturnSuper (oiReturnStatus)) in Transaction> if viFcReturnSuper <> 0 then do : assign vcMsgApi = trim(substitute(#T-97'An error occurred while cancelling the transaction: &1. See other messages for further details.':255(14416)T-97#,string(viFcReturnSuper))). <M-95 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3313':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> end. /* if viFcReturnSuper <> 0 */ <I-96 {bFcCloseInstance &CLASS = "Transaction"}> return. end. /* if oiReturnStatus < 0 */ end. /* if viFcReturnSuper <> 0 */ /* ==================================================================================== */ /* Save the whole thing (including BJE, BCI, BDI and BEI); Open instance, remove this */ /* component from the instance and Commit */ /* ==================================================================================== */ if icAction <> {&DAEMONACTION-VALIDATE} then do: <M-34 run CommitTransaction (input true (ilStop), input ? (ihParentInstance), output vcDummy (ocInstances), output viFcReturnSuper (oiReturnStatus)) in Transaction> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then do : assign vcMsgApi = trim(substitute(#T-107'An error occurred when saving the transaction: &1. See other messages for further details.':255(14418)T-107#,string(viFcReturnSuper))). <M-103 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3320':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> <M-104 run AbortTransaction (input ? (ihParentInstance), output vcDummy (ocInstances), output viFcReturnSuper (oiReturnStatus)) in Transaction> if viFcReturnSuper <> 0 then do : assign vcMsgApi = trim(substitute(#T-108'An error occurred while cancelling the transaction: &1. See other messages for further details.':255(14416)T-108#,string(viFcReturnSuper))). <M-105 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3321':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> end. /* if viFcReturnSuper <> 0 */ <I-106 {bFcCloseInstance &CLASS = "Transaction"}> return. end. /* if oiReturnStatus < 0 */ end. /* if viFcReturnSuper <> 0 */ /* ================================================================================================================================== */ /* If this method (its callers) is called from MaintainByDataSetWithOutput then it can be that vhBCInvoiceInstanceData points to the */ /* invoice-instance-dataset and when the 'ChronologicalInvoiceNumber' is turned on on the domain then the final InvoiceVoucher is */ /* only known after the APMatching is saved. As such, we will update the InvoiceVoucher in vhBCInvoiceInstanceData with the final one */ /* ================================================================================================================================== */ if vlReturnCIInstanceDataCIJE and valid-handle(vhBCInvoiceInstanceDataCIJE) and vhBCInvoiceInstanceDataCIJE:num-buffers > 0 then UPDATEINVOICEVOUCHERBLOCK: DO : assign viNewCInvoiceID = integer(ocLstPrimKey) no-error. if error-status:error then Leave UPDATEINVOICEVOUCHERBLOCK. <Q-83 run CInvoiceByID (all) (Read) (NoCache) (input ?, (CompanyId) input viNewCInvoiceID, (CInvoiceID) output dataset tqCInvoiceByID) in BCInvoice> find first tqCInvoiceByID where tqCInvoiceByID.tiCInvoice_ID = viNewCInvoiceID no-lock no-error. if not available tqCInvoiceByID then Leave UPDATEINVOICEVOUCHERBLOCK. assign vhTempTable = vhBCInvoiceInstanceDataCIJE:get-buffer-handle(1) no-error. if error-status:error or valid-handle(vhTempTable) = false then Leave UPDATEINVOICEVOUCHERBLOCK. Create query vhQuery no-error. if error-status:error or valid-handle(vhQuery) = false then Leave UPDATEINVOICEVOUCHERBLOCK. vhQuery:add-buffer(vhTempTable) no-error. if error-status:error or valid-handle(vhQuery) = false then Leave UPDATEINVOICEVOUCHERBLOCK. vhQuery:query-prepare("for each " + vhTempTable:name ) no-error. if error-status:error or valid-handle(vhQuery) = false then Leave UPDATEINVOICEVOUCHERBLOCK. vhQuery:query-open() no-error. if error-status:error or valid-handle(vhQuery) = false then Leave UPDATEINVOICEVOUCHERBLOCK. vhQuery:get-first() no-error. if error-status:error or valid-handle(vhQuery) = false or vhTempTable:available = false or vhTempTable::CInvoiceVoucher = tqCInvoiceByID.tiCInvoiceVoucher then Leave UPDATEINVOICEVOUCHERBLOCK. assign vhTempTable::CInvoiceVoucher = tqCInvoiceByID.tiCInvoiceVoucher no-error. END. /* UPDATEINVOICEVOUCHERBLOCK */ if valid-handle(vhQuery) then do : vhQuery:query-close() no-error. delete object vhQuery. end. /* if valid-handle(vhQuery) */ end. /* if icAction <> {&DAEMONACTION-VALIDATE} */ else do : <M-113 run AbortTransaction (input ? (ihParentInstance), output vcDummy (ocInstances), output viFcReturnSuper (oiReturnStatus)) in Transaction> if viFcReturnSuper <> 0 then do : assign vcMsgApi = trim(substitute(#T-116'An error occurred while aborting the transaction for a validate action: &1. See other messages for further details.':255(14453)T-116#,string(viFcReturnSuper))). <M-114 run SetMessage (input vcMsgApi (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 1 (iiSeverity), input '':U (icRowid), input 'QADFIN-3328':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BCInvoiceJournalEntry> <I-117 {bFcCloseInstance &CLASS = "Transaction"}> return. end. /* if viFcReturnSuper <> 0 */ end. /* if icAction = {&DAEMONACTION-VALIDATE} */ /* ================================================== */ /* Stop the transaction in case it was started here */ /* Mark the instance as we have no active transaction */ /* ================================================== */ if vlStartTransactionFromCIJE = true and valid-handle(vhTransactionInst) = true then do: <I-35 {bFcCloseAndStopInstance &CLASS = "Transaction"}> end. /* if vlStartTransactionFromCIJE = true */ else do: <I-36 {bFcCloseInstance &CLASS = "Transaction"}> end. /* if vlStartTransactionFromCIJE <> true */ assign vlTransactionActive = false. /* ====================== */ /* Set return-status = OK */ /* ====================== */ if oiReturnStatus = -98 then assign oiReturnStatus = 0.
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 = "ApiStdMaintainTTV01". 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.apistdmaintainttv01.i.xsd", ?). vhParameter = vhInputDS:get-buffer-handle("tParameterI"). vhParameter:buffer-create(). assign vhParameter::icAction = <parameter value>. 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> ... 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("tApiCInvoiceWHTCIJE"). 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> ... /* 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.