project QadFinancials > class BCountry > method ValidateComponent
Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bcountry.p)
/* ============================================ */
/* Stop External Instances */
/* ============================================ */
<M-6 run StopExternalInstances
(output viFcReturnSuper (oiReturnStatus)) in BCountry>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
for each t_sCountry where
t_sCountry.tc_Status <> "D":U and
(t_sCountry.CountryCode <> ? and
t_sCountry.CountryCode <> "":U):
assign t_sCountry.CountryCode = trim(t_sCountry.CountryCode).
end.
/* ============================================ */
/* Check for allowed changes on the CountryCode */
/* ============================================ */
<M-3 run ValidateComponentCountryCodeChanges
(output viFcReturnSuper (oiReturnStatus)) in BCountry>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* ================================================================================================= */
/* Check on usage in table address when deleting: we have to do this manualy because the generated */
/* messages shows the unique-key of the address-record and this is either a combination of 7 fields, */
/* either the sequence of the address-record and this information is not very usefull to end-users */
/* We will thus end up with one clear message that is manualy given and one unclear generated one */
/* ================================================================================================= */
<M-5 run ValidateComponentUsageInAddress
(output viFcReturnSuper (oiReturnStatus)) in BCountry>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* ================================================================= */
/* Unit test case for the new exception handling. */
/* This code is designed to fail. */
/* ================================================================= */
if can-find (first t_sCountry where t_sCountry.CountryDescription = "exception handling unit test")
then find first t_iCountry where t_iCountry.CountryDescription = "exception handling unit test completed".
<ANCESTOR-CODE>