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 banking entry can be found (based on his logical key : Company ID, GL_ID, bank statemenet year, bank statement number), the existing banking entry will be updated. If not, a new banking entry will be created.
Parameters
tApiBankState | input | temp-table | Input temp-table holding the bank statement data to be created, updated or deleted. |
tApiBankStateLine | input | temp-table | Input temp-table holding the bank statement line reocrds linked to the bank statement data to be created, updated or deleted. |
tApiBankAlloc | input | temp-table | Input temp-table holding the allocations records linked to the bank statement data to be created, updated or deleted. |
tApiBankStateAllocColl | input | temp-table | Input temp-table holding the collection allocations records linked to the bank statement data to be created, updated or deleted. |
tApiBankStateStageAlloc | input | temp-table | Input temp-table holding the stage allocations records linked to the bank statement 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 | Character 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. |
ocLstReturn | output | character | Char 4 separated list with the return status of the newly created main-table records. Zero means not errors occurred. |
ocLstRowid | output | character | Char 4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program9/bbankentry.p)
/* ================================================== */
/* Method Info: */
/* BBankEntry will be loaded based on the logical key */
/* ================================================== */
/* ============================================================================ */
/* Clear the instance: */
/* this will also clear the t_s tables that were filled in ApiMaintainByDataset */
/* ============================================================================ */
<M-37 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
/* ==================== */
/* Set Default Return */
/* Parameter Validation */
/* ==================== */
assign oiReturnStatus = -98
vlDraftInstanceCreated = false.
if icAction = ? then assign icAction = "":U.
if icAction <> {&DAEMONACTION-SAVESTORE} and
icAction <> {&DAEMONACTION-SAVE} and
icAction <> {&DAEMONACTION-STORE} and
icAction <> {&DAEMONACTION-VALIDATE}
then do:
assign vcMsgApi = trim(subst(#T-21'A bank statement integration error occurred. The specified action (&1) must be in the list '&2'.':255(306)t-21#,trim(icAction),"{&DAEMONACTION-SAVESTORE},{&DAEMONACTION-SAVE},{&DAEMONACTION-STORE},{&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-1648':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
return.
end. /* if icAction */
/* ======================== */
/* Count main-table records */
/* ======================== */
for each tApiBankState no-lock :
assign viMainTableRecordCount = viMainTableRecordCount + 1.
end. /* for each */
if viMainTableRecordCount = 0
then do:
assign vcMsgApi = trim(#T-22'A bank statement integration error occurred. The system could not find main table records (bank state).':255(307)t-22#)
oiReturnStatus = -1.
<M-7 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-1649':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
return.
end. /* if viMainTableRecordCount */
/* ================================ */
/* Start loop on main-table records */
/* ================================ */
for each tApiBankState by tApiBankState.tc_Rowid:
/* =========== */
/* Start Block */
/* =========== */
MAIN-BLOCK: DO :
/* ================================== */
/* Initialise and Create new instance */
/* ================================== */
assign vcMsgApi = "":U
vcNewRowid = "":U
vlWarningsFound = false
vlSaveAsDraft = (icAction = {&DAEMONACTION-STORE}).
/* ======================================================= */
/* Period company_id should be the same as the viCompanyID */
/* ======================================================= */
if tApiBankState.Company_ID = ? or tApiBankState.Company_ID = 0
then assign tApiBankState.Company_ID = viCompanyId.
if tApiBankState.Company_ID <> viCompanyId
then do:
assign vcMsgApi = trim(substitute(#T-39'The entity (ID &1) does not match the current entity.':200(2211)t-39#, trim(string(tApiBankState.Company_ID)) ))
ocLstReturn = ocLstReturn + chr(4) + (if viFcReturnSuper = 0 then "-3":U else string(viFcReturnSuper))
ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
ocLstRowid = ocLstRowid + chr(4) + "*":U
vlSaveAsDraft = false.
<M-40 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-3248':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
leave MAIN-BLOCK.
end.
/* ============================================= */
/* Get the BankEntry_ID based on the logical key */
/* ============================================= */
if (tApiBankState.BankState_ID = ? or
tApiBankState.BankState_ID = 0) and
tApiBankState.BankStateYear <> ? and
tApiBankState.BankStateYear <> 0 and
tApiBankState.BankStateNumber <> ? and
tApiBankState.BankStateNumber <> "":U
then do:
<M-79 run GetBankStateID
(input tApiBankState.Company_ID (iiCompanyID),
input tApiBankState.tcGLCode (icGLCode),
input tApiBankState.BankStateYear (iiBankStateYear),
input tApiBankState.BankStateNumber (icBankStateNumber),
output viBankState_ID (oiBankStateID),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viBankState_ID <> ? and viBankState_ID <> 0
then assign tApiBankState.BankState_ID = viBankState_ID.
end.
/* ====================== */
/* Load/Create BankState */
/* ====================== */
if tApiBankState.BankState_ID = ? or
tApiBankState.BankState_ID = 0
then assign viFcReturnSuper = -4.
else do:
<M-2 run DataLoad (input '':U (icRowids),
input string(tApiBankState.BankState_ID) (icPkeys),
input '':U (icObjectIds),
input ? (icFreeform),
input false (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
end.
/* INFO: if dataload fails because of invalid ID, -4 is returned and a new record should be created */
if viFcReturnSuper = -4
then do:
assign viFcReturnSuper = 0.
<M-20 run DataNew (output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0
then assign vcMsgApi = trim(subst(#T-23'Cannot create a new instance. Error number: &1.':255(308)t-23#, string(viFcReturnSuper))).
end.
else do:
if viFcReturnSuper < 0
then assign vcMsgApi = trim(subst(#T-24'Cannot load the instance (error number: &1, instance ID: &2).':255(289)t-24#, string(viFcReturnSuper), string(tApiBankState.BankState_ID))).
else do:
find tBankState where
tBankState.BankState_ID = tApiBankState.BankState_ID
no-error.
if not available tBankState
then assign vcMsgApi = trim(subst(#T-25'Cannot find the instance after it has been loaded (instance ID: &1).':255(290)t-25#, string(tApiBankState.BankState_ID))).
else assign tBankState.tc_Status = "C":U.
end.
end.
/* ================================================================= */
/* Check for errors in the previous block */
/* ================================================================= */
if vcMsgApi <> "":U
then do :
assign vlSaveAsDraft = false
ocLstReturn = ocLstReturn + chr(4) + (if viFcReturnSuper = 0 then "-3":U else string(viFcReturnSuper))
ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
ocLstRowid = ocLstRowid + chr(4) + "*":U.
<M-5 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-1647':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Leave MAIN-BLOCK.
end. /* if viFcReturnSuper < 0 */
/* get OpeningBalance when it's not yet filled */
assign vhFcComponent = ?.
<M-52 run ApiGetAccountBalance
(input 9999 (iiAccYear),
input 99 (iiAccPeriod),
input tApiBankState.GL_ID (iiGL_ID),
input tApiBankState.tcGLCode (icGLCode),
input tApiBankState.Company_ID (iiCompanyID),
input '':U (icCompanyCode),
output vdDummy (odBalanceLC),
output vdDummy (odBalanceCC),
output tApiBankState.BankStateOpeningBalance (odBalanceTC),
output viFcReturnSuper (oiReturnStatus)) in BGL>
if viFcReturnSuper < 0
then next.
else if viFcReturnSuper > 0
then assign vlWarningsFound = true.
/* =========================================================================================== */
/* Copy all data into the new BankState */
/* =========================================================================================== */
buffer-copy tApiBankState except
BankState_ID
tc_Rowid
tc_ParentRowid
tc_Status
BankStateYear
BankStateNumber
GL_ID
tcGLCode
Company_ID
to tBankState.
if tBankState.tc_Status = 'N':U
then do:
/* get BankStateNumber when it's not yet filled */
if tApiBankState.BankStateNumber = '':U or
tApiBankState.BankStateNumber = ?
then do:
<M-36 run GetNewBankStateNumber
(input tApiBankState.Company_ID (iiCompanyID),
input tApiBankState.GL_ID (iiBankGLID),
input tApiBankState.tcGLCode (icBankGLCode),
input tApiBankState.BankStateYear (iiBankStateYear),
output tApiBankState.BankStateNumber (ocNewBankStateNumber),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0
then next.
else if viFcReturnSuper > 0
then assign vlWarningsFound = true.
end. /* if tApiBankState.BankStateNumber = '':U or */
/* Assign fields in instance table from imported table */
assign tBankState.BankStateNumber = tApiBankState.BankStateNumber
tBankState.BankStateYear = tApiBankState.BankStateYear
tBankState.GL_ID = tApiBankState.GL_ID
tBankState.tcGLCode = tApiBankState.tcGLCode
tBankState.Company_ID = tApiBankState.Company_ID
tBankState.BankStateMovement = 0
tBankState.BankStateClosingBalance = tBankState.BankStateOpeningBalance.
end. /* if tBankState.tc_status = 'N':U */
assign tApiBankState.BankState_ID = tBankState.BankState_ID
vcNewRowid = tBankState.tc_Rowid.
/* =================================================================== */
/* Process other Temp-Tables BankStateLine, Alloc and AlloColl */
/* =================================================================== */
<M-8 run ApiStdMaintainTTSub (input icAction (icAction),
input-output ocLstReturn (bcLstReturn),
input-output ocLstPrimKey (bcLstPrimKey),
input-output ocLstRowid (bcLstRowid),
input-output vlSaveAsDraft (blSaveAsDraft),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0
then Leave MAIN-BLOCK.
else if viFcReturnSuper > 0
then assign vlWarningsFound = true.
/* ================================================================= */
/* If only save-as-draft is needed then set the return params as if */
/* there was an error and we skip further actions in the Mainblock */
/* ================================================================= */
if vlSaveAsDraft
then do :
assign ocLstReturn = ocLstReturn + chr(4) + "-1":U
ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
ocLstRowid = ocLstRowid + chr(4) + "*":U.
Leave MAIN-BLOCK.
end. /* vlSaveAsDraft */
/* =============================== */
/* Set Actvity */
/* =============================== */
if can-find (first tBankState where
tBankState.tc_Status = "N":U)
then assign vcActivityCode = "Create":U.
else if can-find (first tBankState where
tBankState.tc_Status = "C":U)
then assign vcActivityCode = "Modify":U.
/* ============================================================================== */
/* Validate the data and Perform external updates (can also contain validations). */
/* ============================================================================== */
<M-12 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0
then do :
assign ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
ocLstRowid = ocLstRowid + chr(4) + "*":U
vlSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE}).
Leave MAIN-BLOCK.
end. /* viFcReturnSuper < 0 */
else if viFcReturnSuper > 0
then assign vlWarningsFound = true.
/* ================ */
/* External updates */
/* ================ */
<M-13 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0
then do :
assign ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
ocLstRowid = ocLstRowid + chr(4) + "*":U
vlSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE}).
Leave MAIN-BLOCK.
end. /* viFcReturnSuper < 0 */
else if viFcReturnSuper > 0
then assign vlWarningsFound = true.
/* ================================================== */
/* Save the data */
/* ================================================== */
if icAction <> {&DAEMONACTION-VALIDATE}
then do :
<M-14 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0
then do :
assign ocLstReturn = ocLstReturn + chr(4) + string(viFcReturnSuper)
ocLstPrimKey = ocLstPrimKey + chr(4) + "*":U
ocLstRowid = ocLstRowid + chr(4) + "*":U
vlSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE}).
Leave MAIN-BLOCK.
end. /* viFcReturnSuper < 0 */
else if viFcReturnSuper > 0
then assign vlWarningsFound = true.
end. /* if icAction = {&DAEMONACTION-VALIDATE} */
/* =========================================================== */
/* Indicate the data is saved/stored correctly and set primkey */
/* =========================================================== */
assign ocLstReturn = ocLstReturn + chr(4) + (if vlWarningsFound = true then "1":U else "0":U)
ocLstPrimKey = ocLstPrimKey + chr(4) + string(tApiBankState.BankState_ID)
ocLstRowid = ocLstRowid + chr(4) + vcNewRowid.
END. /* MAIN-BLOCK */
/* ================================================================= */
/* Handle errors; store if SaveAsDraft is needed */
/* Check: only 1 draft is allowed in a single bus-component instance */
/* ================================================================= */
if vlSaveAsDraft and
index(substring(ocLstReturn,r-index(ocLstReturn,chr(4)) + 1,-1,"CHARACTER":U),"-":U) <> 0
then do :
if vlDraftInstanceCreated = true
then do :
assign vcMsgApi = trim(#T-43'Only one draft instance can be created per method call.':255(13856)T-43#) +
chr(10) +
trim(#T-44'This second object cannot be stored as a draft instance and so is an error.':255(13879)t-44#).
<M-45 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-3264':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
next.
end.
<M-15 run StoreState
(input '(':U + tBankState.BankStateNumber + ') ':U + trim(#T-26'The bank statement number was created using an API method.':200(295)t-26#) (icDescription),
input ? (icUIClass),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
assign vlDraftInstanceCreated = true
entry(num-entries(ocLstReturn,chr(4)),ocLstReturn,chr(4)) = string(viFcReturnSuper)
entry(num-entries(ocLstPrimKey,chr(4)),ocLstPrimKey,chr(4)) = string(tBankState.BankState_ID)
entry(num-entries(ocLstRowid,chr(4)),ocLstPrimKey,chr(4)) = vcNewRowid.
end. /* substring ... */
end. /* for each tApiBankState */
/* ============================================================ */
/* Trim the first character of ocLstReturn and primkey */
/* Check for correct number and format of the return-parameters */
/* ============================================================ */
if length(ocLstReturn, "CHARACTER":U) > 1
then assign ocLstReturn = substring(ocLstReturn, 2,-1,"CHARACTER":U).
if length(ocLstPrimKey,"CHARACTER":U) > 1
then assign ocLstPrimKey = substring(ocLstPrimKey,2,-1,"CHARACTER":U).
if length(ocLstRowid, "CHARACTER":U) > 1
then assign ocLstRowid = substring(ocLstRowid, 2,-1,"CHARACTER":U).
if num-entries(ocLstReturn, chr(4)) <> viMainTableRecordCount or
num-entries(ocLstPrimKey,chr(4)) <> viMainTableRecordCount or
num-entries(ocLstRowid, chr(4)) <> viMainTableRecordCount
then do :
assign vcMsgApi = trim(#T-27'A bank statement integration error occurred. An API method returned incomplete information. See other messages for further details.':200(309)t-27#) + chr(10) +
trim(substitute(#T-28'Main table records: &1.':255(310)T-28#,string(viMainTableRecordCount))) + chr(10) +
trim(substitute(#T-29'Return Statuses: &1.':255(311)T-29#,ocLstReturn)) + chr(10) +
trim(substitute(#T-30'Primary keys: &1.':255(312)T-30#,ocLstPrimKey)) + chr(10) +
trim(substitute(#T-31'Row IDs: &1.':255(313)T-31#,ocLstRowid)).
oiReturnStatus = -3.
<M-16 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-1653':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
return.
end. /* if num-entries */
/* ===================================================== */
/* Set global return value based on the individual ones: */
/* assign it to zero if all individual ones are zero. */
/* ===================================================== */
if ocLstReturn = substring(fill("0":U + CHR(4),viMainTableRecordCount),1,length(ocLstReturn,"CHARACTER":U),"CHARACTER":U)
then assign oiReturnStatus = 0.
else do :
if index(ocLstReturn, '-':U) <> 0
then do:
assign vcMsgApi = trim(#T-47'An error occurred while running the API method. See other error messages for more details.':255(14334)t-47#)
oiReturnStatus = -1.
<M-17 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-1654':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
end.
else do:
assign vcMsgApi = trim(#T-48'A warning has occurred while running this API method. See other error messages for more details.':255(14089)T-48#)
oiReturnStatus = +1.
<M-49 run SetMessage (input vcMsgApi (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-3265':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
end.
end. /* Not ocLstReturn = .... */
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 = "BBankEntry".
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/bbankentry.apistdmaintaintt.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icAction = <parameter value>.
vhParameter = vhInputDS:get-buffer-handle("tApiBankState").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
vhParameter::<field-name-2> = <field-value-2>
...
vhParameter = vhInputDS:get-buffer-handle("tApiBankStateLine").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
vhParameter::<field-name-2> = <field-value-2>
...
vhParameter = vhInputDS:get-buffer-handle("tApiBankAlloc").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
vhParameter::<field-name-2> = <field-value-2>
...
vhParameter = vhInputDS:get-buffer-handle("tApiBankStateAllocColl").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
vhParameter::<field-name-2> = <field-value-2>
...
vhParameter = vhInputDS:get-buffer-handle("tApiBankStateStageAlloc").
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.