Description
Update the SOD matrix
Parameters
tSetSODMatrix | input | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program3/bsodcategoryexclusion.p)
<M-1 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input '' (icFreeform),
input no (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
if viFcReturnSuper = -4
then viFcReturnSuper = 0.
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* add entries */
for each tSetSODMatrix where tSetSODMatrix.tlSODCategoriesConflict = true on error undo, throw:
if tSetSODMatrix.tcSODCategory1Code = tSetSODMatrix.tcSODCategory2Code
then do:
<M-6 run SetMessage
(input #T-1'A SOD category cannot be conflicting to itself.':255(73475939)T-1# (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-254':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
oiReturnStatus = -1.
return.
end.
if can-find (first bSetSODMatrix where
bSetSODMatrix.tcSODCategory1Code = tSetSODMatrix.tcSODCategory2Code and
bSetSODMatrix.tcSODCategory2Code = tSetSODMatrix.tcSODCategory1Code and
bSetSODMatrix.tlSODCategoriesConflict = false)
then do:
<M-7 run SetMessage
(input #T-2'Conflicting input for category $1 and category $2.':255(413968481)T-2# (icMessage),
input tSetSODMatrix.tcSODCategory1Code + chr(2) + tSetSODMatrix.tcSODCategory2Code (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-255':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
oiReturnStatus = -1.
return.
end.
/* In case we get invalid values from the client */
if tSetSODMatrix.tcExclusionDescription = ? then
assign tSetSODMatrix.tcExclusionDescription = "".
if tSetSODMatrix.tcExclusionLevel = ? then
assign tSetSODMatrix.tcExclusionLevel = "".
/* Ensure that we check both matrix lines for the pair: (A,B) & (B,A) */
assign vcCodePair = subst("&1,&2",
tSetSODMatrix.tcSODCategory1Code,
tSetSODMatrix.tcSODCategory2Code
).
do viIndex = 0 to 1:
assign
vcCategory1Code = entry(1 + viIndex, vcCodePair)
vcCategory2Code = entry(1 + (viIndex + 1) mod 2, vcCodePair).
find first tSODExclusion where
tSODExclusion.tcSODCategory1Code = vcCategory1Code and
tSODExclusion.tcSODCategory2Code = vcCategory2Code no-error.
if available tSODExclusion
then do:
/* If this combination has already been updated and the description or level do not match
then we need to raise an error. We're assuming here that the record status cannot
be deleted: "D".
*/
if (tSODExclusion.tc_Status = "C" or tSODExclusion.tc_Status = "N")
and (
tSODExclusion.SODExclusionDescription <> tSetSODMatrix.tcExclusionDescription
or tSODExclusion.SODExclusionLevel <> tSetSODMatrix.tcExclusionLevel
) then do:
<M-49 run SetMessage
(input #T-15'Conflicting input for category $1 and category $2.':255(413968481)T-15# (icMessage),
input tSetSODMatrix.tcSODCategory1Code + chr(2) + tSetSODMatrix.tcSODCategory2Code (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-182131':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
oiReturnStatus = -1.
return.
end.
if tSODExclusion.SODExclusionDescription <> tSetSODMatrix.tcExclusionDescription
then assign tSODExclusion.SODExclusionDescription = tSetSODMatrix.tcExclusionDescription
tSODExclusion.tc_Status = "C".
if tSODExclusion.SODExclusionLevel <> tSetSODMatrix.tcExclusionLevel
then assign tSODExclusion.SODExclusionLevel = tSetSODMatrix.tcExclusionLevel
tSODExclusion.tc_Status = "C".
end.
else do:
<M-2 run AddDetailLine
(input 'SODExclusion' (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
assign tSODExclusion.tcSODCategory1Code = vcCategory1Code
tSODExclusion.tcSODCategory2Code = vcCategory2Code
tSODExclusion.SODExclusionDescription = tSetSODMatrix.tcExclusionDescription
tSODExclusion.SODExclusionLevel = tSetSODMatrix.tcExclusionLevel.
end.
end.
end.
/* delete entries */
for each tSetSODMatrix where tSetSODMatrix.tlSODCategoriesConflict = false on error undo, throw:
/* delete both entries */
find first tSODExclusion where
tSODExclusion.tcSODCategory1Code = tSetSODMatrix.tcSODCategory1Code and
tSODExclusion.tcSODCategory2Code = tSetSODMatrix.tcSODCategory2Code and
tSODExclusion.tc_Status = "" no-error.
if available tSODExclusion
then assign tSODExclusion.tc_Status = "D".
find first tSODExclusion where
tSODExclusion.tcSODCategory1Code = tSetSODMatrix.tcSODCategory2Code and
tSODExclusion.tcSODCategory2Code = tSetSODMatrix.tcSODCategory1Code and
tSODExclusion.tc_Status = "" no-error.
if available tSODExclusion
then assign tSODExclusion.tc_Status = "D".
end.
/* commit */
if can-find (first tSODExclusion where tSODExclusion.tc_Status <> "")
then do:
<M-3 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-4 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-5 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
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 = "BSODCategoryExclusion".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiSetMatrixData".
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/bsodcategoryexclusion.apisetmatrixdata.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tSetSODMatrix").
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.