Description
Write the data of current instance to the database.
PreCondition
The data must be available on the server instance and validated.
If the instance was added to a transaction, method DataSave will do nothing.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
QadFinancials
QadFitnesse
program code (program1/database.p)
/* set context for auditing */
if vcActivityCode = ""
then do:
do while program-name(viLvl + 1) <> ?:
viLvl = viLvl + 1.
end.
vcContextforAudit = "API|" + vcFcComponentName + "|" + program-name(viLvl).
end.
else vcContextforAudit = "MENU|" + vcFcComponentName + "|" + vcActivityCode.
<M-20 run StartPersistence
(output vhPLforAudit (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in database>
vhFcComponent = vhPLforAudit.
<M-16 run SetAuditContext
(input vcContextforAudit (icAppContext),
input viSessionID (iiSessionId)) in persistence>
if viTransactionId <> 0
then do:
if vlTransactionActive
then do:
<I-7 {bFcOpenInstance
&CLASS = "Transaction"}>
<M-10 run CommitTransaction
(input yes (ilStop),
input {&TARGETPROCEDURE} (ihParentInstance),
output vcDummy (ocInstances),
output oiReturnStatus (oiReturnStatus)) in Transaction>
if oiReturnStatus < 0
then do:
<I-8 {bFcCloseInstance
&CLASS = "Transaction"}>
return.
end.
<I-9 {bFcCloseAndStopInstance
&CLASS = "Transaction"}>
assign vlTransactionActive = no.
end.
return.
end.
do transaction on error undo, throw:
<M-1 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-2 run InitTransaction (output viFcReturnSuper (oiReturnStatus)) in persistence>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-3 run DataSaveWorker (output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
assign vhFcComponent = vhFcPersistence.
<M-4 run AbortTransaction (output viFcReturnSuper (oiReturnStatus)) in persistence>
undo, return.
end.
assign vhFcComponent = vhFcPersistence.
<M-5 run CommitTransaction (output viFcReturnSuper (oiReturnStatus)) in persistence>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
undo, return.
end.
end.
<M-6 run UpdateStatus (output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
finally:
if vhPLforAudit <> ?
then do:
vhFcComponent = vhPLforAudit.
<M-21 run ClearAuditContext () in persistence>
end.
end finally.