Description
Check the role has access to the journal
Parameters
iiUserID | input | integer | |
icUserCode | input | character | |
iiJournalID | input | integer | |
icJournalCode | input | character | |
iiCompanyID | input | integer | |
icCompanyCode | input | character | |
iiSessionID | input | integer | |
ocErrorMessage | output | character | |
olJournalAccessAllowed | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tjournalrole.p)
/* ==================================================================================================== */
/* Method : CheckJournalRole */
/* Desc : Check whether a user can post to a Journal */
/* ---------------------------------------------------------------------------------------------------- */
/* Params: (I) iiUserID User ID of the User to be verified */
/* (I) icUserCode User Code of the User to be verified */
/* (I) iiJournalID Journal ID of the Journal to be verified */
/* (I) icJournalCode Journal Code of the Journal to be verified */
/* (I) iiCompanyID Company ID of the Journal and User to be verified */
/* (I) icCompanyCode Company Code of the Journal and User to be verified */
/* (I) SessionID Technical variable holding session ID */
/* (O) ocErrorMessage Error message to return should an error occur */
/* (O) olJournalAccessAllowed Varibale specifying whether the User can posting in the Journal */
/* (O) oiReturnStatus Return Status */
/* ==================================================================================================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0
viSessionID = iiSessionID.
/* =================================================================================================== */
/* Default output values */
/* =================================================================================================== */
assign olJournalAccessAllowed = false
ocErrorMessage = ?.
/* =================================================================================================== */
/* Normalize input parameters */
/* =================================================================================================== */
if iiUserID = 0 then assign iiUserID = ?.
if icUserCode = "":U then assign icUserCode = ?.
if iiJournalID = 0 then assign iiJournalID = ?.
if icJournalCode = "":U then assign icJournalCode = ?.
if iiCompanyID = 0 then assign iiCompanyID = ?.
if icCompanyCode = "":U then assign icCompanyCode = ?.
/* =================================================================================================== */
/* Retrieve IDs from Code if necessary */
/* =================================================================================================== */
if iiUserID = ? and
icUserCode <> ?
then do:
<Q-2 run UserPrim (all) (Read) (NoCache)
(input iiUserID, (UsrId)
input icUserCode, (UsrLogin)
output dataset tqUserPrim) in BUser >
find first tqUserPrim where
tqUserPrim.tcUsrLogin = icUserCode no-error.
if available tqUserPrim
then assign iiUserID = tqUserPrim.tiUsr_ID.
else do:
assign ocErrorMessage = #T-5'User Code is not valid.':50(345552498)T-5#
oiReturnStatus = -1.
return.
end.
end.
if iiCompanyID = ? and
icCompanyCode <> ?
then do:
<Q-33 run CompanyPrim (all) (Read) (NoCache)
(input iiCompanyID, (LookupCompanyId)
input icCompanyCode, (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
find first tqCompanyPrim where
tqCompanyPrim.tcCompanyCode = icCompanyCode no-error.
if available tqCompanyPrim
then assign iiCompanyID = tqCompanyPrim.tiCompany_ID.
else do:
assign ocErrorMessage = #T-9'Company Code is not valid.':50(76983949)T-9#
oiReturnStatus = -1.
return.
end.
end.
if iiJournalID = ? and
icJournalCode <> ?
then do:
<Q-31 run JournalPrim (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input icJournalCode, (JournalCode)
input iiJournalID, (JournalID)
output dataset tqJournalPrim) in BJournal >
find first tqJournalPrim where
tqJournalPrim.tcJournalCode = icJournalCode no-error.
if available tqJournalPrim
then assign iiJournalID = tqJournalPrim.tiJournal_ID.
else do:
assign ocErrorMessage = #T-61'Daybook Code is not valid.':50(166311088)T-61#
oiReturnStatus = -1.
return.
end.
end.
/* =================================================================================================== */
/* Validate input parameters */
/* =================================================================================================== */
if iiUserID = ? or
iiJournalID = ? or
iiCompanyID = ?
then do:
assign ocErrorMessage = #T-47'Missing information to check Journal Access':100(900056220)T-47#
oiReturnStatus = -1.
return.
end.
/* =================================================================================================== */
/* Check Journal Access */
/* =================================================================================================== */
JOURNALACCESSBLOCK:
DO:
<Q-59 run JournalByJournalIDCodeType (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input iiJournalID, (JournalID)
input icJournalCode, (JournalCode)
input ?, (JournalTypeCode)
output dataset tqJournalByJournalIDCodeType) in BJournal >
find first tqJournalByJournalIDCodeType no-error.
if available tqJournalByJournalIDCodeType
then do:
if tqJournalByJournalIDCodeType.tiRole_ID <> ? and
tqJournalByJournalIDCodeType.tiRole_ID <> 0
then do:
<Q-25 run UsrRoleByUsrId (all) (Read) (NoCache)
(input iiUserID, (UsrId)
input iiCompanyID, (CompanyId)
output dataset tqUsrRoleByUsrId) in BUserRole >
find first tqUsrRoleByUsrId
where tqUsrRoleByUsrId.tiRole_ID = tqJournalByJournalIDCodeType.tiRole_ID and
tqUsrRoleByUsrId.tiCompany_ID = iiCompanyID no-error.
if available tqUsrRoleByUsrId
then do:
assign olJournalAccessAllowed = true.
leave JOURNALACCESSBLOCK.
end.
else do:
assign olJournalAccessAllowed = false.
leave JOURNALACCESSBLOCK.
end.
end. /* if tqJournalByJournalIDCodeType.tiRole_ID <> ? */
else do:
assign olJournalAccessAllowed = true.
leave JOURNALACCESSBLOCK.
end.
end. /* if availble tqJournalByJournalIDCodeType */
else do:
assign ocErrorMessage = #T-85'Unable to retrieve daybook information':50(525228453)T-85#
viLocalReturnStatus = -1.
leave JOURNALACCESSBLOCK.
end.
END. /* JOURNALACCESSBLOCK */
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
assign oiReturnStatus = viLocalReturnStatus.