project QadFinancials > class BCompany > method ValidateCompanyCode
validation procedure
Description
Provides validation that the company code is unique across all connected MFG/PRO dbs
Parameters
| icTargetField | input | character | Value of the business field to validate. |
| icTargetFieldName | input | character | Name of the business field to validate. |
| icRowid | input | character | Contents of field tc_Rowid, if the target field is a field of a component temp-table. |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bcompany.p)
if oiReturnStatus = 0 then
assign oiReturnStatus = -98.
/* ========================================================================== */
/* Check first to see if replication is enabled - replication can be disabled */
/* for conversion routines that need to replicate data from MFG/PRO to */
/* financials. */
/* ========================================================================== */
<I-1 {bFcOpenInstance
&CLASS = "Session"}>
<M-2 run GetLogicalValue
(input 'ReplicationEnabled':U (icName),
output vlReplicationEnabled (olValue),
output viFcReturnSuper (oiReturnStatus)) in Session>
<I-3 {bFcCloseInstance
&CLASS = "Session"}>
if vlReplicationEnabled <> false then do:
/* Check that all databases are connected */
<I-4 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BMfgDBConnections"}>
<M-5 run IsMultiDB
(output vlMultiDB (olisMultiDB),
output viFcReturnSuper (oiReturnStatus)) in BMfgDBConnections>
if vlMultiDB then do:
<M-6 run CheckDBConnections
(output viFcReturnSuper (oiReturnStatus)) in BMfgDBConnections>
if viFcReturnSuper < 0 then do:
assign
oiReturnStatus = viFcReturnSuper.
end.
/* Only proceed with the uniqueness check if all the DBs are connected */
else do:
<I-9 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "PMultiDB"}>
/* Check that the company code (entity code) is unique across all dbs */
<M-10 run validateEntityCodeByParams
(input icTargetField (icEntityCode),
output vlEntityIsValid (olEntityValid),
output viFcReturnSuper (oiReturnStatus)) in PMultiDB>
if not vlEntityIsValid then do:
assign
oiReturnStatus = -1
vcMessage = #T-11'This entity code already exists in another MFG/PRO database.':70(59518)t-11#
.
<M-12 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6036':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
end.
<I-13 {bFcCloseAndStopInstance
&CLASS = "PMultiDB"}>
end.
end. /* if vlMultidb */
<I-14 {bFcCloseAndStopInstance
&CLASS = "BMfgDBConnections"}>
end. /* if vlReplication <> false */
if oiReturnStatus = -98 then
assign oiReturnStatus = 0.