project BLF > class BWorkObject > method DeleteWorkObjectScopeHolders
Description
This method will remove all WorkObjectScopeHolder records that are identified by input parameter
icRowIDListWorkObjectScopeHolder that represents a chr(2) separated string with the rowids of the records that need to be removed
Parameters
icRowIDListWorkObjectScopeHolder | input | character | icRowIDListWorkObjectScopeHolder is a chr(2) separated string with the rowids of the records that need to be removed |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program6/bworkobject.p)
/* ====================================================================================== */
/* Build a string with all the rowid's of WorkObject of the WorkObjectScopeHolder records */
/* We use vcPrimKeyListWorkObject to hold the primary-key of WorkObject. Note that we use */
/* a chr(4) encapsulation to make sure we haven't got the same ID twice in the list */
/* ====================================================================================== */
assign vcPrimKeyListWorkObject = chr(4).
do viCounter = num-entries(icRowIDListWorkObjectScopeHolder,chr(2)) to 1 by -1 :
<Q-1 run WorkObjectScopeHolderByRowid (all) (Read) (NoCache)
(input entry(vicounter,icRowIDListWorkObjectScopeHolder,chr(2)), (Rowid)
output dataset tqWorkObjectScopeHolderByRowid) in BWorkObject >
find tqWorkObjectScopeHolderByRowid where
tqWorkObjectScopeHolderByRowid.tc_rowid = entry(vicounter,icRowIDListWorkObjectScopeHolder,chr(2))
no-lock no-error.
if not available tqWorkObjectScopeHolderByRowid
then do :
assign vcMessage = trim(substitute(#T-8'Unable to remove the task responsible, because the record cannot be found based on the row ID (&1)':255(484)T-8#,entry(vicounter,icRowIDListWorkObjectScopeHolder,chr(2))))
oiReturnStatus = -3.
<M-6 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'BLF-276':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
Return.
end. /* if not available tqWorkObjectScopeHolderByRowid */
if index(vcPrimKeyListWorkObject,chr(4) + string(tqWorkObjectScopeHolderByRowid.tiWorkObject_ID) + chr(4)) = 0
then assign vcPrimKeyListWorkObject = vcPrimKeyListWorkObject + string(tqWorkObjectScopeHolderByRowid.tiWorkObject_ID) + chr(4).
end. /* do viCounter */
if vcPrimKeyListWorkObject = chr(4) or
vcPrimKeyListWorkObject = "":U
then return.
else assign vcPrimKeyListWorkObject = substring(vcPrimKeyListWorkObject,2, length(vcPrimKeyListWorkObject,"CHARACTER":U) - 1,"CHARACTER":U).
/* ====================== */
/* Load all the instances */
/* ====================== */
<M-2 run DataLoad
(input ? (icRowids),
input vcPrimKeyListWorkObject (icPkeys),
input ? (icObjectIds),
input '' (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ================================================================== */
/* Go through all WorkObjectScopeHolder marked by the input parameter */
/* ================================================================== */
do viCounter = num-entries(icRowIDListWorkObjectScopeHolder,chr(2)) to 1 by -1 :
find tWorkObjectScopeHolder where
tWorkObjectScopeHolder.tc_Rowid = entry(viCounter,icRowIDListWorkObjectScopeHolder,chr(2))
no-error.
if not available tWorkObjectScopeHolder
then do :
assign vcMessage = trim(substitute(#T-9'Unable to remove the task responsible, because the record cannot be loaded based on the row ID (&1)':255(485)T-9#,entry(vicounter,icRowIDListWorkObjectScopeHolder,chr(2))))
oiReturnStatus = -3.
<M-7 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'BLF-277':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
Return.
end. /* if not av tWorkObjectScopeHolder */
assign tWorkObjectScopeHolder.tc_Status = "D":U.
End. /* do viCounter */
/* ============================ */
/* Validations, AddUpd and Save */
/* ============================ */
<M-3 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-4 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-5 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.