project QadFinancials > class BExchangeRate > method PreValidateComponent

Description

This method is used to fill in the id fields based on the code fields


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BExchangeRate.ValidateComponent


program code (program1/bexchangerate.p)

/* only for new or changed records */
<Q-12 run ExchangeRateTypePrim (Start) in BExchangeRateType >
<Q-13 run CurrencyPrim (Start) in BCurrency >

PREVAL_BLOCK:
DO:
    for each t_sExchangeRate where
             t_sExchangeRate.tc_Status = "N":U or
             t_sExchangeRate.tc_Status = "C":U:
             
         /* =================== */
         /* exchange rate type  */
         /* =================== */
         if t_sExchangeRate.tcExchangeRateTypeCode = "":U or
            t_sExchangeRate.tcExchangeRateTypeCode = "?":U or
            t_sExchangeRate.tcExchangeRateTypeCode = ?
         then do:
             <M-1 run SetMessage
                (input  #T-16'You must enter the exchange rate type.':60(1870)T-16# (icMessage), 
                 input  '':U (icArguments), 
                 input  'tExchangeRate.tcExchangeRateTypeCode':U (icFieldName), 
                 input  '':U (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  t_sExchangeRate.tc_Rowid (icRowid), 
                 input  'QADFIN-125':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BExchangeRate>
             assign oiReturnStatus = -1.
             /* LBO leave PREVAL_BLOCK. */
         end.
         else do:
             /* LBO
             /* only when the type has changed */
             if t_sExchangeRate.tcExchangeRateTypeCode <> t_iExchangeRate.tcExchangeRateTypeCode
             then do:
             */
                 <Q-2 run ExchangeRateTypePrim (all) (Read) (Cache)
                    (input 0, (ExchangeRateTypeId)
                     input t_sExchangeRate.tcExchangeRateTypeCode, (ExchangeRateTypeCode)
                     output dataset tqExchangeRateTypePrim) in BExchangeRateType >
                 find first tqExchangeRateTypePrim no-error.
                 if available tqExchangeRateTypePrim
                 then assign t_sExchangeRate.ExchangeRateType_ID = tqExchangeRateTypePrim.tiExchangeRateType_ID.
                 else do:
                     <M-3 run SetMessage
                        (input  #T-17'The specified exchange rate type is not defined in the system.':60(1871)T-17# (icMessage), 
                         input  '':U (icArguments), 
                         input  'tExchangeRate.tcExchangeRateTypeCode':U (icFieldName), 
                         input  t_sExchangeRate.tcExchangeRateTypeCode (icFieldValue), 
                         input  'E':U (icType), 
                         input  3 (iiSeverity), 
                         input  t_sExchangeRate.tc_Rowid (icRowid), 
                         input  'QADFIN-126':U (icFcMsgNumber), 
                         input  '' (icFcExplanation), 
                         input  '' (icFcIdentification), 
                         input  '' (icFcContext), 
                         output viFCReturnSuper (oiReturnStatus)) in BExchangeRate>
                     assign oiReturnStatus = -1.
                     /* LBO leave PREVAL_BLOCK. */
                 end.
             /* LBO
             end.
             */
         end.
         
        /* ================== */
        /* Currency Code From */
        /* ================== */
         if t_sExchangeRate.tcFromCurrencyCode = "":U or
            t_sExchangeRate.tcFromCurrencyCode = "?":U or
            t_sExchangeRate.tcFromCurrencyCode = ?
         then do:
             <M-4 run SetMessage
                (input  #T-18'You must enter the first currency code.':60(1872)T-18# (icMessage), 
                 input  '':U (icArguments), 
                 input  'tExchangeRate.tcFromCurrencyCode':U (icFieldName), 
                 input  '':U (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  t_sExchangeRate.tc_Rowid (icRowid), 
                 input  'QADFIN-127':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BExchangeRate>
             assign oiReturnStatus = -1.
             /* LBO leave PREVAL_BLOCK. */
         end.
         else do:
             /* LBO 
             /* only when the from currency has changed */
             if t_sExchangeRate.tcFromCurrencyCode <> t_iExchangeRate.tcFromCurrencyCode
             then do:
             */   
                 <Q-10 run CurrencyPrim (all) (Read) (Cache)
                    (input t_sExchangeRate.tcFromCurrencyCode, (CurrencyCode)
                     input ?, (Currency_ID)
                     output dataset tqCurrencyPrim) in BCurrency >
                 find first tqCurrencyPrim no-error.
                 if available tqCurrencyPrim
                 then assign t_sExchangeRate.FromCurrency_ID = tqCurrencyPrim.tiCurrency_ID.
                 else do:
                     <M-6 run SetMessage
                        (input  #T-19'The first currency code is invalid.':60(1873)T-19# (icMessage), 
                         input  '':U (icArguments), 
                         input  'tExchangeRate.tcFromCurrencyCode':U (icFieldName), 
                         input  t_sExchangeRate.tcFromCurrencyCode (icFieldValue), 
                         input  'E':U (icType), 
                         input  3 (iiSeverity), 
                         input  t_sExchangeRate.tc_Rowid (icRowid), 
                         input  'QADFIN-128':U (icFcMsgNumber), 
                         input  '' (icFcExplanation), 
                         input  '' (icFcIdentification), 
                         input  '' (icFcContext), 
                         output viFCReturnSuper (oiReturnStatus)) in BExchangeRate>
                     assign oiReturnStatus = -1.
                     /* LBO
                     leave PREVAL_BLOCK.
                     */
                 end.
             /* LBO 
             end.
             */
         end.
         
         /* ================ */
         /* Currency Code To */
         /* ================ */
         if t_sExchangeRate.tcToCurrencyCode = "":U or
            t_sExchangeRate.tcToCurrencyCode = "?":U or
            t_sExchangeRate.tcToCurrencyCode = ?
         then do:
             <M-7 run SetMessage
                (input  #T-20'You must enter the last currency code.':60(1874)T-20# (icMessage), 
                 input  '':U (icArguments), 
                 input  'tExchangeRate.tcToCurrencyCode':U (icFieldName), 
                 input  '':U (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  t_sExchangeRate.tc_Rowid (icRowid), 
                 input  'QADFIN-129':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BExchangeRate>
             assign oiReturnStatus = -1.
             /* leave PREVAL_BLOCK. */
         end.
         else do:
             /* LBO
             /* only when to currency has changed */
             if t_sExchangeRate.tcToCurrencyCode <> t_iExchangeRate.tcToCurrencyCode
             then do:
             */
                 <Q-11 run CurrencyPrim (all) (Read) (Cache)
                    (input t_sExchangeRate.tcToCurrencyCode, (CurrencyCode)
                     input ?, (Currency_ID)
                     output dataset tqCurrencyPrim) in BCurrency >
                 find first tqCurrencyPrim no-error.
                 if available tqCurrencyPrim
                 then assign t_sExchangeRate.ToCurrency_ID = tqCurrencyPrim.tiCurrency_ID.
                 else do:
                     <M-9 run SetMessage
                        (input  #T-21'The last currency code is invalid.':60(1875)T-21# (icMessage), 
                         input  '':U (icArguments), 
                         input  'tExchangeRate.tcToCurrencyCode':U (icFieldName), 
                         input  t_sExchangeRate.tcToCurrencyCode (icFieldValue), 
                         input  'E':U (icType), 
                         input  3 (iiSeverity), 
                         input  t_sExchangeRate.tc_Rowid (icRowid), 
                         input  'QADFIN-130':U (icFcMsgNumber), 
                         input  '' (icFcExplanation), 
                         input  '' (icFcIdentification), 
                         input  '' (icFcContext), 
                         output viFCReturnSuper (oiReturnStatus)) in BExchangeRate>
                     assign oiReturnStatus = -1.
                     /* LBO leave PREVAL_BLOCK. */
                 end.
             /* LBO
             end.
             */
         end.
    end.
END.

<Q-14 run ExchangeRateTypePrim (Stop) in BExchangeRateType >
<Q-15 run CurrencyPrim (Stop) in BCurrency >

/* call the sub-method to fill in Till Date */
<M-22 run PreValidateComponentDateTill  (output viFcReturnSuper (oiReturnStatus)) in BExchangeRate>
if viFcReturnSuper <> 0 and oiReturnStatus >= 0
then assign oiReturnStatus = viFcReturnSuper.