project QadFinancials > class BResource > method ApiMfgproFunctionIsAllowed
Description
This api method checks if an given mfgpro function can be executed by the user in the given domain or not.
Parameters
iiUsrID | input | integer | |
icUsrLogin | input | character | |
iiDomainID | input | integer | |
icDomainCode | input | character | |
icResourceURI | input | character | |
olIsAllowed | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bresource.p)
if oiReturnStatus = 0
then assign oiReturnStatus = -98.
assign vcMsg = '':U
olIsAllowed = false.
/* Check icUsrLogin */
if iiUsrID = 0 or iiUsrID = ?
then do:
if icUsrLogin = '' or icUsrLogin = ?
then do:
assign vcMsg = trim(#T-2'One of the input parameters is missing.':200(3572)T-2#).
end.
else do:
<Q-3 run UserPrim (all) (Read) (NoCache)
(input ?, (UsrId)
input icUsrLogin, (UsrLogin)
output dataset tqUserPrim) in BUser >
find first tqUserPrim no-error.
if available tqUserPrim
then assign iiUsrID = tqUserPrim.tiUsr_ID.
else assign vcMsg = trim(#T-4'One of the input parameters is invalid:':200(3829)T-4#).
end.
if vcMsg <> '':U
then do:
assign oiReturnStatus = -1.
<M-14 run SetMessage
(input vcMsg (icMessage),
input '' (icArguments),
input 'icUsrLogin' (icFieldName),
input icUsrLogin (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6522':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BResource>
return.
end.
end.
/* Check icDomainCode */
if iiDomainID = 0 or iiDomainID = ?
then do:
if icDomainCode = '' or icDomainCode = ?
then do:
assign vcMsg = trim(#T-6'One of the input parameters is missing.':200(3572)T-6#).
end.
else do:
<Q-8 run DomainsPrim (all) (Read) (NoCache)
(input ?, (DomainID)
input icDomainCode, (DomainCode)
output dataset tqDomainsPrim) in BDomain >
find first tqDomainsPrim no-error.
if available tqDomainsPrim
then assign iiDomainID = tqDomainsPrim.tiDomain_ID.
else assign vcMsg = trim(#T-10'One of the input parameters is invalid:':200(3829)T-10#).
end.
if vcMsg <> '':U
then do:
assign oiReturnStatus = -1.
<M-15 run SetMessage
(input vcMsg (icMessage),
input '' (icArguments),
input 'icDomainCode' (icFieldName),
input icDomainCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6523':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BResource>
return.
end.
end.
/* Check icResourceURI */
if icResourceURI = '' or icResourceURI = ?
then do :
assign vcMsg = trim(#T-11'One of the input parameters is missing.':200(3572)T-11#)
oiReturnStatus = -1.
<M-9 run SetMessage
(input vcMsg (icMessage),
input '' (icArguments),
input 'icResourceURI' (icFieldName),
input icResourceURI (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6519':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BResource>
return.
end.
<Q-1 run ResourceByUsrDomainUri (all) (Read) (NoCache)
(input iiUsrID, (UsrID)
input iiDomainID, (DomainID)
input icResourceURI, (ResourceURI)
output dataset tqResourceByUsrDomainUri) in BResource >
assign olIsAllowed = can-find (first tqResourceByUsrDomainUri).
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 = "BResource".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiMfgproFunctionIsAllowed".
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/bresource.apimfgprofunctionisallowed.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiUsrID = <parameter value>
vhParameter::icUsrLogin = <parameter value>
vhParameter::iiDomainID = <parameter value>
vhParameter::icDomainCode = <parameter value>
vhParameter::icResourceURI = <parameter value>.
/* 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.