| opPrimeKey | output | longchar | Primary Key field value of loaded record(s). Keys are chr(4) separated. Key fields are chr(2) separated. |
| oiReturnStatus | output | integer | Return status of the method. |
for each t_sResources on error undo, throw:
/* ================================================================= */
/* When deleting a resource of type 'Menu', */
/* do not delete the resource but delete the menu. */
/* ================================================================= */
if vcActivityCode = "Delete":U
and t_sResources.ResourceType = {&RESOURCE-TYPE-MENU}
then do:
delete t_sResources.
next.
end.
/* ================================================================= */
/* Lookup resource */
/* When in create mode, skip lookup. */
/* do not return any validation errors */
/* ================================================================= */
if vcActivityCode <> "Create":U
then case t_sResources.ResourceType:
when {&RESOURCE-TYPE-ACTIVITY}
then do:
if t_sResources.tcBusActivityCode = ""
or t_sResources.tcBusActivityCode = ?
or t_sResources.tcBusComponentCode = ""
or t_sResources.tcBusComponentCode = ?
then do:
/*should be updated to use activityid, if the componentcode and activitycode
are not available in the input parameter dataset. */
if t_sResources.BusActivity_ID <> 0 and
t_sResources.BusActivity_ID <> ?
then do:
<Q-49 run BusActivityPrim (all) (Read) (NoCache)
(input t_sResources.BusActivity_ID, (BusActivityID)
input '', (BusActivityCode)
input '', (BusComponentCode)
output dataset tqBusActivityPrim) in BBusinessComponent >
find first tqBusActivityPrim no-error.
if available tqBusActivityPrim
then do:
assign t_sResources.tcBusActivityCode = tqBusActivityPrim.tcBusActivityCode
t_sResources.tcBusComponentCode = tqBusActivityPrim.tcBusComponentCode.
end.
else assign viFcReturnSuper = -4.
end.
else assign viFcReturnSuper = -4.
end. /*viFcReturnSuper = -4.*/
if t_sResources.tcBusActivityCode = ""
or t_sResources.tcBusActivityCode = ?
or t_sResources.tcBusComponentCode = ""
or t_sResources.tcBusComponentCode = ?
then assign viFcReturnSuper = -4.
else do:
<Q-3 run BusActivityPrim (all) (Read) (NoCache) (input 0, (BusActivityID)
input t_sResources.tcBusActivityCode, (BusActivityCode)
input t_sResources.tcBusComponentCode, (BusComponentCode)
output dataset tqBusActivityPrim) in BBusinessComponent >
find first tqBusActivityPrim no-error.
if available tqBusActivityPrim
then do:
vcFreeform = "for each Resources where Resources.BusActivity_ID = ":U + string(tqBusActivityPrim.tiBusActivity_ID).
<M-4 run DataLoad (input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input vcFreeform (icFreeform),
input yes (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BResource>
if viFcReturnSuper >= 0
then find first tResources where
tResources.BusActivity_ID = tqBusActivityPrim.tiBusActivity_ID no-error.
end.
else viFcReturnSuper = -4.
end.
end.
when {&RESOURCE-TYPE-MENU}
then do:
if t_sResources.ResourceURI = ""
or t_sResources.ResourceURI = ?
then viFcReturnSuper = -4.
else do:
vcFreeform = "for each Resources where Resources.ResourceURI = '":U + t_sResources.ResourceURI + "'":U.
<M-6 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input vcFreeform (icFreeform),
input yes (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BResource>
if viFcReturnSuper >= 0
then find first tResources where
tResources.ResourceURI = t_sResources.ResourceURI no-error.
end.
end.
otherwise viFcReturnSuper = -4.
end case.
/* ================================================================= */
/* When in delete mode, ignore input data. */
/* When resource not found, do not return an error. */
/* ================================================================= */
if vcActivityCode = "Delete":U
then do:
if viFcReturnSuper = -4
then delete t_sResources.
else do:
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
<Q-14 run BusActivityPrim (Stop) in BBusinessComponent >
return.
end.
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sResources.tc_Rowid = tResources.tc_Rowid
t_sResources.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tResources.Resource_ID).
end.
next.
end.
if vcActivityCode = "Create":U
or viFcReturnSuper = -4
then do:
/* ================================================================= */
/* When resource not found and in modify only mode, return an error. */
/* ================================================================= */
if vcActivityCode = "Modify":U
then do:
case t_sResources.ResourceType:
when {&RESOURCE-TYPE-ACTIVITY}
then vcFreeform = substitute (#T-7'Resource for activity &1 does not exist.':100(6801)T-7#,
t_sResources.tcBusComponentCode + "/":U +
t_sResources.tcBusActivityCode).
when {&RESOURCE-TYPE-MENU}
then vcFreeform = substitute (#T-8'Resource for menu $1 does not exist.':100(6799)T-8#,
t_sResources.ResourceURI).
otherwise
vcFreeform = substitute (#T-9'Unknown resource type $1.':100(6800)T-9#,
t_sResources.ResourceType).
end case.
<M-10 run SetMessage (input vcFreeform (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sResources.tc_Rowid (icRowid),
input 'BLF-170':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BResource>
assign oiReturnStatus = -1.
<Q-16 run BusActivityPrim (Stop) in BBusinessComponent >
return.
end.
/* ================================================================= */
/* When resource not found or in create mode, create it. */
/* ================================================================= */
<M-11 run AddDetailLine (input 'Resources':U (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BResource>
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sResources.tc_Status = "N":U.
end.
else do:
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sResources.tc_Status = "C":U.
end.
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
<Q-18 run BusActivityPrim (Stop) in BBusinessComponent >
return.
end.
/* ================================================================= */
/* override value for identity fields in input */
/* ================================================================= */
assign t_sResources.Resource_ID = tResources.Resource_ID
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
t_sResources.tc_Rowid = tResources.tc_Rowid
t_sResources.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tResources.Resource_ID).
end.