project QadFinancials > class BDebtorShipTo > 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


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bdebtorshipto.p)

/* Stop external instances is not called here as the APi needs access to the Businress Relations component started earlier */
/*
 *  We only want to check if the end user code is an ad_mstr record already if the user has not ticked the customer or shipto tick boxes
 *  This is because if these boxes are ticked then ad_mstr records will already exists with the enduser code. 
 */
    
 /* check if replication is enabled */
<I-526 {bFcOpenInstance
     &CLASS           = "Session"}>

<M-3 run GetLogicalValue
   (input  'ReplicationEnabled':U (icName), 
    output vlReplicationEnabled (olValue), 
    output viFcReturnSuper (oiReturnStatus)) in Session>      

<I-17 {bFcCloseInstance
     &CLASS           = "Session"}>

VALIDATE_BLOCK:
do on error undo, leave:

for each t_sDebtorShipTo where
         t_sDebtorShipTo.tc_Status <> "D":U and
        (t_SDebtorShipTo.DebtorShipToCode <> ? and
         t_SDebtorShipTo.DebtorShipToCode <> "":U):
    assign t_SDebtorShipTo.DebtorShipToCode = trim(t_SDebtorShipTo.DebtorShipToCode).
end.  
  
    /* first populate the address_id and retrieve shared end users - if required */
    <M-26 run ValidateComponentUpdateAllSharedShiptos  (output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
    if viFcReturnSuper < 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.

    shiptosA:
    for each t_sDebtorShipto: 
        /* Check to see if the address already exists in the instance */
        if t_sDebtorShipTo.tc_Status = "N":U or
           t_SDebtorShipTo.tc_Status = "C":U
        then do:
            if can-find (bDebtorShipTo where   bDebtorShipTo.tcAddressStreet1 = t_SDebtorShipTo.tcAddressStreet1 and
                                               bDebtorShipTo.tcAddressStreet2 = t_SDebtorShipTo.tcAddressStreet2 and
                                               bDebtorShipTo.tcAddressStreet3 = t_SDebtorShipTo.tcAddressStreet3 and
                                               bDebtorShipTo.tcAddressCity = t_SDebtorShipTo.tcAddressCity and
                                               bDebtorShipTo.tcAddressZip = t_SDebtorShipTo.tcAddressZip and
                                               bDebtorShipTo.tcAddressTypeCode = t_sDebtorShipTo.tcAddressTypeCode and
                                               bDebtorShipTo.tiBusinessRelation_ID = t_SDebtorShipTo.tiBusinessRelation_ID and
                                               bDebtorShipTo.DebtorShipTo_ID <> t_SDebtorShipTo.DebtorShipTo_ID) and
                                               t_sDebtorShipTo.tlAddressIsShared <> true
            then do:
                    
                if (t_SDebtorShipTo.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-ENDUSER})             
                    then assign vcMessage =  #T-46'The address below already exists - To assign an end user to an existing address use the 'Link to end user address', $1, $2, $3, $4, $5, $6':255(269168777)T-46#.
                else
                    assign vcMessage =    #T-60'This address below already exists - To assign a ship-to to an existing address use the 'Link to ship-to address' ,$1, $2, $3, $4, $5, $6':255(393182381)T-60#.
                 
                 assign oiReturnStatus = -1.
                 <M-77 run SetMessage
                    (input  vcMessage (icMessage), 
                     input  t_SDebtorShipTo.tcAddressStreet1 + chr(2) + t_SDebtorShipTo.tcAddressStreet2 + chr(2) + t_SDebtorShipTo.tcAddressStreet3 + chr(2) + t_SDebtorShipTo.tcAddressCity + chr(2) + t_SDebtorShipTo.tcAddressZip  + chr(2) + t_SDebtorShipTo.tcBusinessRelationCode (icArguments), 
                     input  'AddressIsShared' (icFieldName), 
                     input  t_SDebtorShipTo.tlAddressIsShared (icFieldValue), 
                     input  'E' (icType), 
                     input  3 (iiSeverity), 
                     input  t_SDebtorShipTo.tc_rowid (icRowid), 
                     input  'qadfin-741090':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                  
                    leave shiptosA.
                    
            end.
        end. 
        
        if t_SDebtorShipTo.tc_Status = "C":U 
            then do :
                find first t_iDebtorShipTo where
                           t_iDebtorShipTo.DebtorShipToCode   = t_sDebtorShipTo.DebtorShipToCode and 
                           t_iDebtorShipTo.tcAddressTypeCode  <>  t_sDebtorShipTo.tcAddressTypeCode no-error .
                if available  t_iDebtorShipTo 
                then do :
                    assign oiReturnStatus = -1.
                    <M-84 run SetMessage
                       (input  #T-13'Ship-to already exists and address type cannot be changed':255(469368742)T-13# (icMessage), 
                        input  ? (icArguments), 
                        input  'AddressTypeCode' (icFieldName), 
                        input  t_sDebtorShipTo.tcAddressTypeCode (icFieldValue), 
                        input  'E' (icType), 
                        input  3 (iiSeverity), 
                        input  t_SDebtorShipTo.tc_rowid (icRowid), 
                        input  'qadfin-401644':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                  
                    leave shiptosA.
                end.
         end.
        /* Normalize values */
        if t_sDebtorShipTo.Debtor_ID    = 0    then assign t_sDebtorShipTo.Debtor_ID    = ?.
        if t_sDebtorShipTo.tcDebtorCode = '':U then assign t_sDebtorShipto.tcDebtorCode = ?.


        if  t_sDebtorShipto.tc_status = "N":U
        then do:
            /* Check for an automatic number for debtor */
            if t_sDebtorShipTo.DebtorShipToCode = '':U or
               t_sDebtorShipTo.DebtorShipToCode = ?
            then do:
                assign vhFcComponent = ?.
                <M-95 run GetAutoNumber
                   (input  t_sDebtorShipTo.tc_Rowid (icRowid), 
                    output t_sDebtorShipTo.DebtorShipToCode (ocDebtorShipToCode), 
                    output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                if viFcReturnSuper <> 0
                then assign oiReturnStatus = viFcReturnSuper.
                if viFcReturnSuper < 0
                then leave shiptosA.
            end.  

            <Q-123 run DebtorByDebtorIDCodeNoJoins (all) (Read) (Cache)
               (input viCompanyID, (CompanyId)
                input t_sDebtorShipto.Debtor_id, (DebtorID)
                input t_sDebtorShipto.tcDebtorCode, (DebtorCode)
                output dataset tqDebtorByDebtorIDCodeNoJoins) in BDebtor >             
   
            for first tqDebtorByDebtorIDCodeNoJoins where
                      (tqDebtorByDebtorIDCodeNoJoins.tiDebtor_ID  = t_sDebtorShipto.Debtor_id    or t_sDebtorShipTo.Debtor_ID = ?) and
                      (tqDebtorByDebtorIDCodeNoJoins.tcDebtorCode = t_sDebtorShipto.tcDebtorCode or t_sDebtorShipto.tcDebtorCode = ?):

                if not tqDebtorByDebtorIDCodeNoJoins.tlDebtorIsActive
                then do:
                    assign 
                        vcMessageText =    #T-89'Customer $1 is not active':255(63859)T-89#
                        oiReturnStatus = -1.
                    <M-92 run SetMessage
                       (input  vcMessageText (icMessage), 
                        input  t_sDebtorShipTo.tcDebtorCode (icArguments), 
                        input  't_sDebtorShipTo.tcDebtorCode' (icFieldName), 
                        input  t_sDebtorShipTo.tcDebtorCode (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '' (icRowid), 
                        input  'QadFin-6604':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>                    
                    leave shiptosA.
                end.
            end. 
            if not available tqDebtorByDebtorIDCodeNoJoins
            then do:                                                    
                assign 
                    vcMessageText =     #T-90'The specified customer: $1 is invalid.':255(63858)t-90#
                    oiReturnStatus = -1.
               <M-93 run SetMessage
                   (input  vcMessageText (icMessage), 
                    input  t_sDebtorShipTo.tcDebtorCode (icArguments), 
                    input  't_sDebtorShipTo.tcDebtorCode' (icFieldName), 
                    input  t_sDebtorShipTo.tcDebtorCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '' (icRowid), 
                    input  'QadFin-6605':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>        
                leave shiptosA.
            end.
                  end. /* end new record only */

        if oiReturnStatus < 0 and oiReturnStatus <> -98 
        then do:
            <M-126 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
            leave shiptosA.
        end.              

    end. /* for each t_sDebtorShipto: */

    if oiReturnStatus < 0 and oiReturnStatus <> -98 
    then leave VALIDATE_BLOCK.

    
    <ANCESTOR-CODE>

    shiptos:
    for each t_sDebtorShipto 
        where t_sDebtorShipto.tc_status = "N":U 
           or t_sDebtorShipto.tc_status = "C":U:    
           
        if t_sDebtorShipto.tc_status = "N":U
        then do:
            if not(t_sDebtorShipto.DebtorShiptoIsDebtor) and
                (t_sDebtorShipto.DebtorEndUser_ID = 0 or t_sDebtorShipto.DebtorEndUser_ID = ?)
            then do:                        
            
                 /* if this shipto is not linked to a customer or enduser then the address type has to be ship-to*/
                 if t_sDebtorShipTo.tcAddressTypeCode <> {&ADDRESSTYPECODESYSTEM-DELIVERY}
                 then do:
                 
                    assign
                        vcMessageText  = #T-86'Address type must be $1 when creating a new address for a Customer Ship-to':255(145344867)T-86#
                        oiReturnStatus = -1.
                    
                        <M-48 run SetMessage
                           (input  vcMessageText (icMessage), 
                            input  #T-3'Ship-To':20(40747)T-3# (icArguments), 
                            input  'tcAddressTypeCode' (icFieldName), 
                            input  t_sDebtorShipto.tcAddressTypeCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sDebtorShipto.tc_rowid (icRowid), 
                            input  'qadfin-458320':U (icFcMsgNumber), 
                            input  '' (icFcExplanation), 
                            input  '' (icFcIdentification), 
                            input  '' (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo> 
                      leave shiptos.
                 
                 end. /* end of addresstypecode validation */
                 
                /* only check for existing ad_mstr records if replication is not enabled */
                if vlReplicationEnabled <> false 
                then do:      
                    <Q-94 run CompanyBySharedSet (all) (Read) (Cache)
                       (input '', (CompanyId)
                        input t_sDebtorShipTo.SharedSet_ID, (SharedSetId)
                        output dataset tqCompanyBySharedSet) in BCompany>           

                    DomainLoop:
                    for each tqCompanyBySharedSet 
                        break by tqCompanyBySharedSet.tcDomainCode:
                
                        if not first-of(tqCompanyBySharedSet.tcDomainCode)
                        then next DomainLoop.
                          
                        <Q-63 assign vlFcQueryRecordsAvailable = AdMstrByDomainByCode (NoCache)
                           (input tqCompanyBySharedSet.tcDomainCode, (Domain)
                            input t_sDebtorShipto.DebtorShiptoCode, (Code)) in BMfgAddress>

                        if vlFcQueryRecordsAvailable 
                        then do:
                            assign
                                 vcMessageText  = #T-30'Code $1 is already in use in the address master (ad_mstr).':100(45744)T-30#
                                 oiReturnStatus = -1.
                            <M-164 run SetMessage
                               (input  vcMessageText (icMessage), 
                                input  t_sDebtorShipto.DebtorShiptoCode (icArguments), 
                                input  'DebtorShiptoCode':U (icFieldName), 
                                input  t_sDebtorShipto.DebtorShiptoCode (icFieldValue), 
                                input  'E':U (icType), 
                                input  3 (iiSeverity), 
                                input  t_sDebtorShipto.tc_rowid (icRowid), 
                                input  'qadfin-486195':U (icFcMsgNumber), 
                                input  '' (icFcExplanation), 
                                input  '' (icFcIdentification), 
                                input  '' (icFcContext), 
                                output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo> 
                            leave shiptos.
                        end.
                    end.               
                end.  /* replication enabled */      
            end. /* not customer or end user */
        
        end. /*end new record only */    
              
        /*
        * It is not possible to change the Debtor Shipto 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 DebtorShipto_ID for foreign key
        * relationships but it will cause major data integrity problems 
        * within MFG/PRO if this data is allowed to change.
        */    
        for first t_iDebtorShipto
            where t_iDebtorShipto.tc_Rowid = t_sDebtorShipto.tc_Rowid:
            if t_iDebtorShipto.DebtorShiptoCode <> t_sDebtorShipto.DebtorShiptoCode 
            then do:
                assign
                    vcMessageText      = #T-22'Cannot change key field value.':50(17933)T-22#
                    oiReturnStatus = -1.
                <M-23 run SetMessage
                   (input  vcMessageText (icMessage), 
                    input  '' (icArguments), 
                    input  'DebtorShiptoCode':U (icFieldName), 
                    input  t_sDebtorShipto.DebtorShiptoCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDebtorShipto.tc_rowid (icRowid), 
                    input  'QadFin-4856':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>            
                leave shiptos.
            end.
        end. /* end of find old record */

        if t_sDebtorShipto.DebtorShiptoIsDebtor = true then
        do:
            /* The value specifed in the Ship-to Code field must be a valid debtor */       
            <Q-4 assign vlFcQueryRecordsAvailable = DebtorPrim (NoCache)
                (input viCompanyId, (CompanyId)
                 input t_sDebtorShipto.DebtorShiptoCode, (DebtorCode)
                 input '', (Debtor_ID)) in BDebtor >                                                                                                                                  

            if vlFcQueryRecordsAvailable <> true then
            do:
                /* if the the current shipto value does not point to a debtor then raise an error and return */
                assign
                      vcMessageText  =   #T-14'Ship-to $1 is a not a valid customer. Use Customer is selected.':63(986)T-14#
                      oiReturnStatus = -3.
             
                <M-2 run SetMessage
                    (input  vcMessageText (icMessage), 
                     input  t_sDebtorShipto.DebtorShiptoCode (icArguments), 
                     input  '' (icFieldName), 
                     input  '' (icFieldValue), 
                     input  '' (icType), 
                     input  '' (iiSeverity), 
                     input  '' (icRowid), 
                     input  '-108':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                leave shiptos.
            end.  /* end vlFcQueryRecordsAvailable */
          
            if  t_sDebtorShipto.DebtorShiptoCode =  t_sDebtorShipto.tcDebtorCode
            then do:
                assign
                   vcMessageText  =    #T-73'Cyclic relationships are not allowed.':35(55939)t-73#
                   oiReturnStatus = -3.
         
                <M-71 run SetMessage
                    (input  vcMessageText (icMessage), 
                     input  t_sDebtorShipto.DebtorShiptoCode (icArguments), 
                     input  'DebtorShiptoCode' (icFieldName), 
                     input  t_sDebtorShipto.DebtorShiptoCode (icFieldValue), 
                     input  'E' (icType), 
                     input  3 (iiSeverity), 
                     input  '' (icRowid), 
                     input  'QadFin-5589':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                leave shiptos. 
            end.
                    
            /* A debtor can only be a shipto for one other debtor */         
            <Q-12 run DebtorShipToForDebtorByIsDebtor (all) (Read) (NoCache)
               (input t_sDebtorShipto.Debtor_ID, (DebtorID)
                input true, (DebtorShiptoIsDebtor)
                input t_sDebtorShipto.DebtorShiptoCode, (DebtorShiptoCode)
                input viCompanyID, (CompanyId)
                output dataset tqDebtorShipToForDebtorIsDebtor) in BDebtorShipTo >

            for first  tqDebtorShiptoForDebtorIsDebtor:
                /* if the the current shipto value does not point to a debtor then raise an error and return */
                assign
                     vcMessageText  =    #T-6'Customer $1 is already a ship-to for customer $2.':50(987)T-6#
                     oiReturnStatus = -1.

                <M-7 run SetMessage (input  vcMessageText (icMessage), 
                 input  t_sDebtorShipto.DebtorShiptoCode + chr(2) + tqDebtorShipToForDebtorIsDebtor.tcDebtorCode (icArguments), 
                 input  '' (icFieldName), 
                 input  '' (icFieldValue), 
                 input  '' (icType), 
                 input  '' (iiSeverity), 
                 input  '' (icRowid), 
                 input  '-110':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                leave shiptos.              

            end. /* end for first tqDebtorShiptoByIsDebtor */
        end.  /* end of if DebtorShiptoIsDebtor */
          
    end.  /* end of for each t_sDebtorShipto */

    /* if we have had an error then return */
    if oiReturnStatus < 0 
    then leave VALIDATE_BLOCK.

    DeleteShiptos:
    for each t_sDebtorShipto 
        where t_sDebtorShipto.tc_status = "D":U:     
            
         <Q-24 run CompanyBySharedSet (all) (Read) (NoCache)
            (input '', (CompanyId)
             input t_sDebtorShipTo.SharedSet_ID, (SharedSetId)
             output dataset tqCompanyBySharedSet) in BCompany >          
         
        /*
        * check each of the domains assoicated with this company.
        */
        DomainLoop:
        for each tqCompanyBySharedSet where             
                 break by tqCompanyBySharedSet.tcDomainCode:

            if not first-of(tqCompanyBySharedSet.tcDomainCode) 
            then next DomainLoop.                      
            
            /* check if sales order exists for debtor shipto */         
            <Q-25 run SalesOrderByShipto (all) (Read) (NoCache)
               (input t_sDebtorShipTo.DebtorShipToCode, (ShiptoCode)
                input tqCompanyBySharedset.tcDomainCode, (Domain)
                output dataset tqSalesOrderByShipto) in BMfgSalesOrder >
            
            /* If we found a sales order then we can't delete the shipto - raise an error */
            for first tqSalesOrderByShipto:        
               assign 
                    vcMessageText =#T-31'You cannot delete the customer ship-to. It is used by sales order $1.':65(50173)t-31#.
                     oiReturnStatus = -1.
                <M-32 run SetMessage
                   (input  vcMessageText (icMessage), 
                    input  tqSalesOrderByShipto.tcSo_nbr (icArguments), 
                    input  '' (icFieldName), 
                    input  '' (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '' (icRowid), 
                    input  'QadFin-5424':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                leave DeleteShiptos.
            end.
            
            /* check for any sales quotes.*/
            <Q-33 run SalesQuoteByShipto (all) (Read) (NoCache)
               (input tqCompanyBySharedSet.tcDomainCode, (domain)
                input t_sDebtorShipTo.DebtorShipToCode, (shipto)
                output dataset tqSalesQuoteByShipto) in BMfgSalesQuote >
                                  
            for first tqSalesQuoteByShipto:
                assign 
                    vcMessageText =#T-35'You cannot delete the customer ship-to. It is used by sales quote $1.':65(50172)t-35#
                     oiReturnStatus = -1.
                <M-34 run SetMessage (input  vcMessageText (icMessage), 
                          input  tqSalesQuoteByShipto.tcqo_nbr (icArguments), 
                          input  '' (icFieldName), 
                          input  '' (icFieldValue), 
                          input  'E':U (icType), 
                          input  3 (iiSeverity), 
                          input  '' (icRowid), 
                          input  'QadFin-5425':U (icFcMsgNumber), 
                          input  '' (icFcExplanation), 
                          input  '' (icFcIdentification), 
                          input  '' (icFcContext), 
                          output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>         
                leave DeleteShiptos.
            end.   
            
            
            /* check for any service repair orders */
            <Q-36 run ServiceRepairOrderByShipto (all) (Read) (NoCache)
               (input tqCompanyBySharedSet.tcDomainCode, (domain)
                input t_sDebtorShipTo.DebtorShipToCode, (shipto)
                output dataset tqServiceRepairOrderByShipto) in BMfgServiceRepairOrder >                
                
            for first tqServiceRepairOrderByShipto:
                assign  
                    vcMessageText =#T-38'You cannot delete the customer ship-to. It is used by service repair order $1.':70(50296)t-38#
                     oiReturnStatus = -1.
                <M-37 run SetMessage
                   (input  vcMessageText (icMessage), 
                        input  tqServiceRepairOrderByShipto.tcsro_nbr (icArguments), 
                        input  '' (icFieldName), 
                        input  '' (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '' (icRowid), 
                        input  'QadFin-5429':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>         
                leave DeleteShiptos.
            end.   
            
            /* check for any project orders */
            <Q-39 run ProjectRealizationByShipto (all) (Read) (NoCache)
               (input t_sDebtorShipTo.DebtorShipToCode, (shipto)
                input tqCompanyBySharedSet.tcDomainCode, (domain)
                output dataset tqProjectRealizationByShipto) in BMfgProjectRealization >
            for first tqProjectRealizationByShipto:
                assign 
                    vcMessageText =#T-41'You cannot delete the customer ship-to. It is used by project order $1.':70(50412)t-41#
                     oiReturnStatus = -1.
                <M-40 run SetMessage
                   (input  vcMessageText (icMessage), 
                    input  tqProjectRealizationByShipto.tcprj_nbr (icArguments), 
                    input  '' (icFieldName), 
                    input  '' (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '' (icRowid), 
                    input  'QadFin-5430':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
                leave DeleteShiptos.
            end.       
        end.  /* end of companybysharedset */
    end. /* end of t_sDebtorShipto.tc_status = "D" */
end. /* of VALIDATE BLOCK */

/* Close instances of the component when and error was found and system does not *
 * continue with the next execution of the AdditionalUpdates                     */
if oiReturnStatus < 0
then do:
    if vlIsBBusinessRelationOpenedHr and
       valid-handle(vhBBusinessRelation1Inst)
    then do:
        <I-53 {bFcCloseInstance
             &CLASS           = "BBusinessRelation"}>
        assign vlIsBBusinessRelationOpenedHr = false.
    end.
end.