Description
This method will do the synchronisation/upload of the Payment Formats
Parameters
| olUpdatesDone | output | logical | indicates whether some DB updates were done |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bpaymentformat.p)
/* ================== */
/* Clear the instance */
/* ================== */
<M-1 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
/* ================================ */
/* Load all existing PaymentFormats */
/* ================================ */
<M-2 run DataLoad
(input '':U (icRowids),
input '':U (icPkeys),
input '':U (icObjectIds),
input '' (icFreeform),
input false (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper = -4 /* nothing-read - emtpy-table */
then assign viFcReturnSuper = 0.
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
/* ============================================================================================= */
/* Go through the preprocessor containing all possible (untranslatable and translatable) values. */
/* Here we will only use the even-entries because we just need the untranslatable values */
/* ============================================================================================= */
assign vcPaymentFormats = {&PAYMENTFORMATS}
viMaxCounter = num-entries(vcPaymentFormats ,chr(2)).
do viCounter = viMaxCounter to 2 by -2 :
/* Apparently, we first have to place the preprocessor-entry in a variable, or else the FIND won't work */
assign vcPaymentFormatTypeCode = entry(viCounter,vcPaymentFormats,chr(2)).
find tPayFormatType where
tPayFormatType.PayFormatTypeCode = vcPaymentFormatTypeCode
no-lock no-error.
if not available tPayFormatType
then do :
<M-3 run AddDetailLine (input 'PayFormatType':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
assign tPayFormatType.PayFormatTypeCode = entry(viCounter,vcPaymentFormats,chr(2))
tPayFormatType.PayFormatTypeIsActive = true
olUpdatesDone = true.
end. /* if not available tPayFormatType */
else if tPayFormatType.PayFormatTypeIsActive = false
then assign tPayFormatType.PayFormatTypeIsActive = true
tPayFormatType.tc_Status = "C":U
olUpdatesDone = true.
end. /* do viCounter */
/* ======================================================================== */
/* De-activate all existing PaymentFormat-type that are no longer in the preprocessor */
/* ======================================================================== */
assign vcListCode = ?.
do viIndex = 2 to num-entries(vcPaymentFormats,chr(2)) by 2:
assign vcListCode = if vcListCode = ?
then entry(viIndex, vcPaymentFormats,chr(2))
else vcListCode + chr(2) + entry(viIndex, vcPaymentFormats,chr(2)).
end.
for each tPayFormatType where
tPayFormatType.PayFormatTypeIsActive = true :
assign viCounter = lookup(tPayFormatType.PayFormatTypeCode, vcListCode,chr(2)) no-error.
if viCounter = 0
then assign tPayFormatType.PayFormatTypeIsActive = false
tPayFormatType.tc_Status = "C":U
olUpdatesDone = true.
end. /* for each tPayFormatType */
/* ==================================== */
/* Validate, AdditionalUpdates and Save */
/* ==================================== */
<M-4 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-5 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-6 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BPaymentFormat".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiSynchronise".
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 = "".
/* 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.