project BLF > class BWorkClass > method ApiUpdate
Description
This method is used on the UI to store the workflow class
Parameters
tApiUpdWorkClass | input | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bworkclass.p)
If oiReturnStatus = 0
Then Assign oiReturnStatus = -98.
Assign viCounter = 0.
For Each tApiUpdWorkClass No-lock:
Assign viCounter = viCounter + 1.
End.
Find First tApiUpdWorkClass No-lock No-error.
If viCounter <> 1 Or Not Available tApiUpdWorkClass
Then Do:
Assign vcMsg = Trim(Substitute(#T-2'You can only give one record to this method (&1).':255(6530)T-2#,"BWorkClass.ApiUpdate":U))
oiReturnStatus = -3.
<M-3 run SetMessage (input vcMsg (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input '1':U (iiSeverity),
input '':U (icRowid),
input 'BLF-266':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWorkClass>
Return.
End.
<M-1 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BWorkClass>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
/*The tApiUpdWorkClass should be available now*/
<Q-4 run WorkClassPrim (all) (Read) (NoCache)
(input ?, (WorkClassId)
input tApiUpdWorkClass.WorkClassDescription, (WorkClassDescription)
output dataset tqWorkClassPrim) in BWorkClass >
Find First tqWorkClassPrim Where
tqWorkClassPrim.tcWorkClassDescription = tApiUpdWorkClass.WorkClassDescription
No-lock No-error.
If Available tqWorkClassPrim
Then Do:
<M-5 run DataLoad (input ? (icRowids),
input String(tqWorkClassPrim.tiWorkClass_ID) (icPkeys),
input ? (icObjectIds),
input ? (icFreeform),
input False (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BWorkClass>
Find First tWorkClass Where
tWorkClass.WorkClass_ID = tqWorkClassPrim.tiWorkClass_ID
No-lock No-error.
If Available tWorkClass
Then Assign tWorkClass.tc_Status = 'C':U.
End.
If viFcReturnSuper = -4 Or Not Available tqWorkClassPrim
Then Do:
Assign viFcReturnSuper = 0.
<M-6 run DataNew (output viFcReturnSuper (oiReturnStatus)) in BWorkClass>
End.
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
Buffer-copy tApiUpdWorkClass Except
WorkClass_ID
Usr_ID
tc_Status
tc_Rowid
tc_ParentRowid
Role_ID
ObjectFlexStatus_ID
LastModifiedUser
LastModifiedTime
LastModifiedDate
BusComponent_ID
BusActivity_ID
To tWorkClass.
<M-7 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BWorkClass>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
<M-8 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BWorkClass>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
<M-9 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BWorkClass>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
Empty Temp-table tApiUpdWorkClass No-error.
If oiReturnStatus = -98
Then Assign oiReturnStatus = 0.
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 = "BWorkClass".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiUpdate".
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/bworkclass.apiupdate.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tApiUpdWorkClass").
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.