project QadFinancials > class BCountry > method ValidateComponentUsageInAddress

Description

ValidateComponentUsageInAddress: Check the usage of a Country in the Address-table in case of deletion


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCountry.ValidateComponent


program code (program4/bcountry.p)

/* ================================================================================================= */
    /* 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    */
    /* ================================================================================================= */
    <Q-2 run AddressByCountryID
       (Start) in BBusinessRelation >
    for each t_sCountry where
             t_sCountry.tc_Status           = "D":U and 
             t_sCountry.Country_ID         <> 0     and
             t_sCountry.Country_ID         <> ?
             no-lock :
        <Q-1 run AddressByCountryID (all) (Read) (NoCache)
           (input t_sCountry.Country_ID, (CountryID)
            output dataset tqAddressByCountryID) in BBusinessRelation >
        find first tqAddressByCountryID no-lock no-error.
        if available tqAddressByCountryID
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(substitute(#T-4'Country '&1' cannot be deleted as it is still used in the address definitions. Address '&2' of business relation '&3' still uses this country.':255(59842)t-4#,t_sCountry.CountryCode,tqAddressByCountryID.tcAddressName,tqAddressByCountryID.tcBusinessRelationCode)).
            <M-5 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCountry.CountryCode':U (icFieldName), 
                input  t_sCountry.CountryCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCountry.tc_Rowid (icRowid), 
                input  'QadFin-6115':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCountry>
        end. /* if avail tqAddressByCountryID */
    end. /* for each t_sCountry where */
    <Q-3 run AddressByCountryID
       (Stop) in BBusinessRelation >