icBusinessComponent | input | character | Business component name |
iiObject_ID | input | integer | Identity field value of the parent record |
ilKeepPreviousData | input | logical | KeepPreviousData; set TRUE if you want the previously loaded to be available in this instance. set to FALSE if you want all previously loaded and created instances to be skipped. |
tUpdWorkObject | input | temp-table | object to create/update; Note that this temp-table should only contain a single record. |
biWorkObject_ID | input-output | integer | WorkObject_ID; this input-output parameter will: - as input; contain the WorkObjectID of the Object that needs to be updated or can be empty in case a workobject needs to be created. - as output; contain created or updated work-object it ID. |
oiReturnStatus | output | integer | Return status of the method. |
/* ================================================================================= */ /* Set default return status */ /* Validate the input parameters; the temp-table should only contain a single record */ /* Find the single Temp-table record */ /* ================================================================================= */ assign oiReturnStatus = -98. find first tUpdWorkObject no-lock no-error. if not available tUpdWorkObject then do : assign oiReturnStatus = -1. <M-7 run SetMessage (input trim(#T-21'The input parameter temp table did not contain a single record.':200(488)t-21#) (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'S':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'BLF-272':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BWorkObject> return. end. find next tUpdWorkObject no-lock no-error. if available tUpdWorkObject then do : assign oiReturnStatus = -1. <M-8 run SetMessage (input trim(#T-22'The input parameter temp table should contain only one single record, but multiple records were found.':200(489)t-22#) (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'S':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'BLF-273':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BWorkObject> return. end. find first tUpdWorkObject no-lock no-error. /* ========================================================= */ /* Clear the previously loaded / created instances if needed */ /* ========================================================= */ if ilKeepPreviousData = false then do : <M-11 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BWorkObject> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper <> 0 */ end. /* if ilKeepPreviousData = false */ /* ======================================================= */ /* Load the instance (update) or create a new one (create) */ /* ======================================================= */ if biWorkObject_ID = ? or biWorkObject_ID = 0 then do : <M-15 run AddDetailLine (input 'WorkObject':U (icTable), input '' (icParentRowid), output viFcReturnSuper (oiReturnStatus)) in BWorkObject> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper <> 0 */ end. /* if biWorkObject_ID = ? or */ else do : find first tWorkObject where tWorkObject.WorkObject_ID = biWorkObject_ID no-error. if not available tWorkObject then do : <M-10 run DataLoad (input '':U (icRowids), input biWorkObject_ID (icPkeys), input '':U (icObjectIds), input '' (icFreeform), input ilKeepPreviousData (ilKeepPrevious), output viFcReturnSuper (oiReturnStatus)) in BWorkObject> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper <> 0 */ end. /* if not available tWorkObject */ find first tWorkObject where tWorkObject.WorkObject_ID = biWorkObject_ID no-error. if not available tWorkObject then do : assign oiReturnStatus = -3. <M-14 run SetMessage (input trim(#T-23'Unable to load the work object based on this ID':200(490)t-23#) + '; ':U + (if biWorkObject_ID = ? then '?':U else string(biWorkObject_ID)) (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'S':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'BLF-274':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BWorkObject> return. end. /* if not available tWorkObject */ end. /* Not if biWorkObject_ID = ? or */ /* ================================================== */ /* Get the Activity of the component */ /* ================================================== */ <Q-19 run BusActivityByLabeslCodesIDs (all) (Read) (NoCache) (input ?, (BusComponentID) input icBusinessComponent, (BusComponentCode) input ?, (BusComponentLabel) input ?, (BusActivityID) input tUpdWorkObject.tcActivityCode, (BusActivityCode) input ?, (BusActivityLabel) output dataset tqBusActivityByLabeslCodesIDs) in BBusinessComponent > find first tqBusActivityByLabeslCodesIDs where tqBusActivityByLabeslCodesIDs.tcBusActivityCode = tUpdWorkObject.tcActivityCode and tqBusActivityByLabeslCodesIDs.tcBusComponentCode = icBusinessComponent no-lock no-error. /* ================ */ /* Get the RoleName */ /* ================ */ <Q-20 run RolePrim (all) (Read) (NoCache) (input tUpdWorkObject.tiRole_ID, (RoleID) input ?, (RoleName) output dataset tqRolePrim) in BRole > find tqRolePrim where tqRolePrim.tiRole_ID = tUpdWorkObject.tiRole_ID no-lock no-error. /* ========================= */ /* Set the workobject values */ /* ========================= */ assign tWorkObject.BusComponent_ID = (if available tqBusActivityByLabeslCodesIDs then tqBusActivityByLabeslCodesIDs.tiBusComponent_ID else 0) tWorkObject.tcBusComponentCode = (if available tqBusActivityByLabeslCodesIDs then tqBusActivityByLabeslCodesIDs.tcBusComponentCode else "":U) tWorkObject.BusActivity_ID = (if available tqBusActivityByLabeslCodesIDs then tqBusActivityByLabeslCodesIDs.tiBusActivity_ID else 0) tWorkObject.tcBusActivityCode = (if available tqBusActivityByLabeslCodesIDs then tqBusActivityByLabeslCodesIDs.tcBusActivityCode else "":U) tWorkObject.Company_ID = viCompanyId tWorkObject.ObjectFlexStatus_ID = tUpdWorkObject.tiObjectFlexStatus_ID tWorkObject.Role_ID = tUpdWorkObject.tiRole_ID tWorkObject.tcRoleName = (if available tqRolePrim then tqRolePrim.tcRoleName else "":U) tWorkObject.WorkObjectInternal_ID = iiObject_ID tWorkObject.WorkObjectExternal_ID = tUpdWorkObject.tcExternal_ID tWorkObject.tcWorkObjectInternalRef = tUpdWorkObject.tcObjectReference tWorkObject.WorkObjectInstruction = tUpdWorkObject.tcInstruction tWorkObject.WorkObjectIsExternalCtrl = tUpdWorkObject.tlIsInExternalControl tWorkObject.WorkObjectIsInternalCtrl = tUpdWorkObject.tlIsInInternalControl tWorkObject.WorkObjectIsReturnToSender = tUpdWorkObject.tlIsReturnToSender tWorkObject.WorkObjectIsSendMail = tUpdWorkObject.tlIsSendMail. if tWorkObject.tc_Status = '':U then assign tWorkObject.tc_Status = 'C':U. If tWorkObject.tc_Status = 'N':U Then Assign tWorkObject.CreatorUsr_ID = viUsrId tWorkObject.tcCreatorUsrLogin = vcUserLogin. /* ======================================= */ /* Perform additional updates and validate */ /* ======================================= */ <M-13 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BWorkObject> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper <> 0 */ <M-16 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BWorkObject> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper <> 0 */ /* ================================================================================= */ /* Set returnstatus to indicate everything succeded and set the output Workobject ID */ /* ================================================================================= */ find first tWorkObject no-lock no-error. assign oiReturnStatus = 0 biWorkObject_ID = if available tWorkObject then tWorkObject.WorkObject_ID else 0.