project QadFinancials > class BDebtor > method ValDebtorBillTo

validation procedure


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDebtor.PostValidateComponent


program code (program1/bdebtor.p)

/* Verify that the bill-to code is an existing debtor.
 * It is allowed that the bill-to code refers to itself.
 */ 
/* Should this be defined in the data item section */
if t_sDebtor.tcBillToDebtorCode <> "":U and
   t_sDebtor.tcBillToDebtorCode <> ?    and 
   t_sDebtor.BillToDebtor_ID    <> 0    and 
   t_sDebtor.BillToDebtor_ID    <> ?    and 
   (t_sDebtor.tc_Status = "N":U or 
    (t_sDebtor.tc_Status = "C" and 
     can-find (t_iDebtor where 
               t_iDebtor.tc_Rowid        = t_sDebtor.tc_Rowid and 
               t_iDebtor.BillToDebtor_ID <> t_sDebtor.BillToDebtor_ID )))
then do: 
    <Q-8 run DebtorByDebtorIDCode (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input 0, (DebtorId)
        input t_sDebtor.tcBillToDebtorCode, (DebtorCode)
        input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
        output dataset tqDebtorByDebtorIDCode) in BDebtor >
        
    for first tqDebtorByDebtorIDCode:    
        if not(tqDebtorByDebtorIDCode.tlDebtorIsActive)
        then do:
            assign
                vcMessageText  = #T-11'Bill-To ($1) is not active':27(46869)T-11#
                oiReturnStatus = -1.
            <M-9 run SetMessage
               (input  vcMessageText (icMessage), 
                input  t_sDebtor.tcBillToDebtorCode (icArguments), 
                input  'tDebtor.tcBillToDebtorCode':U (icFieldName), 
                input  t_sDebtor.tcBillToDebtorCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDebtor.tc_Rowid (icRowid), 
                input  'QadFin-5399':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        end.     
    end.
    if not available tqDebtorByDebtorIDCode 
    then do:
        assign
            vcMessageText  = trim(substitute(#T-12'Bill-To ($1) must be a valid customer.':100(17939)t-12#, t_sDebtor.tcBillToDebtorCode)) 
            oiReturnStatus = -1.
        <M-10 run SetMessage
           (input  vcMessageText (icMessage), 
            input  '':U (icArguments), 
            input  'tDebtor.tcBillToDebtorCode':U (icFieldName), 
            input  t_sDebtor.tcBillToDebtorCode (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sDebtor.tc_Rowid (icRowid), 
            input  'QadFin-5400':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDebtor>                
    end.
end.