project BLF > class BSharedSetType > method ApiSynchronise
Description
synchronise fixed data
Parameters
olUpdatesDone | output | logical | UpdatesDone; true in cases updates were done |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program9/bsharedsettype.p)
/* ================== */
/* Clear the instance */
/* ================== */
<M-4 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BSharedSetType>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
/* ============================ */
/* Load all existing Types */
/* ============================ */
<M-5 run DataLoad
(input '':U (icRowids),
input '':U (icPkeys),
input '':U (icObjectIds),
input '' (icFreeform),
input false (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetType>
if viFcReturnSuper = -4 /* nothing-read - emtpy-table */
then assign viFcReturnSuper = 0.
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
/* =============================================================== */
/* Check for every system Type if it exists */
/* De-activiate the existing ones that are no longer in the list */
/* =============================================================== */
assign viMaxCounter = num-entries(vcSharedSetTypeCodes,chr(2)).
do viCounter = viMaxCounter to 2 by -2 :
find tSharedSetType where
tSharedSetType.SharedSetTypeCode = entry(viCounter,vcSharedSetTypeCodes,chr(2))
no-lock no-error.
if not available tSharedSetType
then do :
<M-7 run AddDetailLine (input 'SharedSetType':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetType>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
assign tSharedSetType.SharedSetTypeCode = entry(viCounter,vcSharedSetTypeCodes,chr(2))
tSharedSetType.SharedSetTypeIsActive = true
olUpdatesDone = true.
end. /* if not available tSharedSetType */
else if tSharedSetType.SharedSetTypeIsActive = false
then assign tSharedSetType.SharedSetTypeIsActive = true
tSharedSetType.tc_Status = "C":U
olUpdatesDone = true.
end. /* do viCounter */
/* ==================================== */
/* Validate, AdditionalUpdates and Save */
/* ==================================== */
<M-1 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BSharedSetType>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-2 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BSharedSetType>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-3 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BSharedSetType>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
/* Also make sure the necessary default shared sets get created */
<I-11 {bFcStartAndOpenInstance
&CLASS = "BSharedSet"}>
<M-12 run ApiSynchronise (output vlUpdatesDone (olUpdatesDone),
output viFcReturnSuper (oiReturnStatus)) in BSharedSet>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
<I-14 {bFcCloseAndStopInstance
&CLASS = "BSharedSet"}>
assign olUpdatesDone = (olUpdatesDone or vlUpdatesDone).
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 = "BSharedSetType".
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.