project BLF > class BCompany > method PreValidateComponent
Description
Do some checks before the real ValidateComponent is executed.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/bcompany.p)
/*
* It is not possible to change the Creditor Code value on the account
* as this is a key value that is used in MFG/PRO, the financials
* can handle these changes as they used the Creditor_ID for foreign key
* relationships but it will cause major data integrity problems
* within MFG/PRO if this data is allowed to change.
*/
for each t_sCompany where
t_sCompany.tc_Status = "C":U on error undo, throw:
find first t_iCompany where t_iCompany.tc_Rowid = t_sCompany.tc_Rowid no-error.
if t_iCompany.CompanyCode <> t_sCompany.CompanyCode then do:
assign
vcMessage = #T-4'Cannot change key field value.':50(6803)T-4#
oiReturnStatus = -1.
<M-5 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'CompanyCode':U (icFieldName),
input t_sCompany.CompanyCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCompany.tc_Rowid (icRowid),
input 'BLF-51':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
return.
end.
end.
/* ================================ */
/* Actions for the CompanySharedSet */
/* ================================ */
for each t_sCompanySharedSet where
t_sCompanySharedSet.tc_status = "N":U or
t_sCompanySharedSet.tc_status = "C":U on error undo, throw:
/* SharedSetCode is mandatory */
if t_sCompanySharedSet.tcSharedSetCode = "":U or
t_sCompanySharedSet.tcSharedSetCode = ? or
t_sCompanySharedSet.tcSharedSetCode = "?":U
then do:
<M-1 run SetMessage
(input #T-1'You must enter the shared set code for $1':100(6605)T-1# (icMessage),
input t_sCompanySharedSet.tcSharedSetCode (icArguments),
input 'tCompanySharedSet.tcSharedSetCode':U (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCompanySharedSet.tc_Rowid (icRowid),
input 'BLF-49':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
assign oiReturnStatus = -1.
end.
else do:
/* check whether the entered code is valid */
<Q-2 run SharedSetByIDCodeType (all) (Read) (NoCache)
(input t_sCompanySharedSet.tcSharedSetCode, (SharedSetCode)
input true, (SharedSetIsActive)
input ?, (SharedSetTypeCode)
input ?, (SharedSetID)
output dataset tqSharedSetByIDCodeType) in BSharedSet >
find first tqSharedSetByIDCodeType where
tqSharedSetByIDCodeType.tcSharedSetCode = t_sCompanySharedSet.tcSharedSetCode and
tqSharedSetByIDCodeType.tlSharedSetIsActive = true
no-error.
if available tqSharedSetByIDCodeType
then assign t_sCompanySharedSet.SharedSet_ID = tqSharedSetByIDCodeType.tiSharedSet_ID
t_sCompanySharedSet.tcSharedSetTypeCode = tqSharedSetByIDCodeType.tcSharedSetTypeCode.
else do:
<M-3 run SetMessage
(input #T-2'Invalid Shared Set Code for $1':100(6606)T-2# (icMessage),
input t_sCompanySharedSet.tcSharedSetTypeTranslated (icArguments),
input 'tCompanySharedSet.tcSharedSetCode':U (icFieldName),
input t_sCompanySharedSet.tcSharedSetCode (icFieldValue),
input 'E':u (icType),
input 3 (iiSeverity),
input t_sCompanySharedSet.tc_rowid (icRowid),
input 'BLF-50':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
assign oiReturnStatus = -1.
end.
end.
end. /* for each t_sCompanySharedSet where */