project QadFinancials > class BMfgExchangeRate > method LoadMfgData

Description

Controls the process of loading data from the qaddb database into the business component. This method is part of the Generic MFG/PRO update infrastrcuture.


Parameters


icMfgDomaininputcharacterThe MFG/PRO Domain currently being processed. Required when extracting information from MFG/PRO for a table that belons to a domain.
icMfgTableNameinputcharacterName of the MFG/PRO table name that is currently being processed. This is used to determine which logic to execute within the method in the cases where one business component maps to multiple tables in MFG/PRO.
icFinancialTableNameinputcharacterName of the current financials table being processed, used to determine which logic to execute.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program/bmfgexchangerate.p)

<ANCESTOR-CODE>

    /* ====================================================== */
    /* Set the return status to unexpected system error (-98) */
    /* ====================================================== */
    assign oiReturnStatus = -98.
    
    /* ======================================================================== */
    /* Create a query to extract the cost center data from the MFG/PRO database */
    /* into the objects tcc_mstr temp table that holds the objects data         */
    /* Get the CostCentreCode From MFG/PRO that we need to update.              */
    /* ======================================================================== */
    if(vtInitialValidDateFrom = ? or tCopyExchangeRate.tc_rowid <> vcModifiedRowID) then
        assign vtStartDate = tCopyExchangeRate.ExchangeRateValidDateFrom.
    else
        assign vtStartDate = vtInitialValidDateFrom.
    if(vcInitialExchangeRateTypeCode = ? or tCopyExchangeRate.tc_rowid <> vcModifiedRowID) then do:
        assign vcExchangeRateTypeCode = <M-6 GetMfgExchangeRateType
                                           (input  tCopyExchangeRate.tcExchangeRateTypeCode (icExchangeRateType)) in BMfgExchangeRate>.
    end.
    else
        assign vcExchangeRateTypeCode = <M-7 GetMfgExchangeRateType
                                           (input  vcInitialExchangeRateTypeCode (icExchangeRateType)) in BMfgExchangeRate>.

    assign vcFreeForm = 'for each exr_rate where exr_curr1=~'':U + tCopyExchangeRate.tcFromCurrencyCode + 
                        '~' and exr_curr2=~'':U + tCopyExchangeRate.tcToCurrencyCode + 
                        '~' and exr_start_date=':U + string(vtStartDate) +
                        ' and exr_ratetype=~'':U + vcExchangeRateTypeCode  +
                        '~' and exr_domain=~'':U + icMfgDomain + '~'':U.
                        
    <M-1 run DataLoad (input  '' (icRowids), 
                   input  '' (icPkeys), 
                   input  '' (icObjectIds), 
                   input  vcFreeForm (icFreeform), 
                   input  true (ilKeepPrevious), 
                   output viFcReturnSuper (oiReturnStatus)) in BMfgExchangeRate>                   
    if viFcReturnSuper <> 0 
    then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then Return.
        
    /* ===================================================================== */
    /* Synchronize the static buffer and the buffer handle to ensure that    */
    /* both are pointing to the same record. First we find the tcc_mstr      */
    /* record using the static temp table and then we execute the same       */
    /* find-first against the temp table buffer handle.                      */
    /* We need to execute both of these queries because the two buffers      */
    /* do not automatically synchronize when a dynamic/static finds are      */
    /* executed.                                                             */
    /* ===================================================================== */
    find texr_rate where 
               texr_rate.exr_curr1      = tCopyExchangeRate.tcFromCurrencyCode and
               texr_rate.exr_curr2      = tCopyExchangeRate.tcToCurrencyCode and
               texr_rate.exr_start_date = vtStartDate and
               texr_rate.exr_ratetype   = vcExchangeRateTypeCode and
               texr_rate.exr_domain     = icMfgDomain no-error.
    if not available texr_rate
    then do :
        assign  vcMessageText  = trim(substitute(#T-2'Cannot find the static record for the replication based on the key &1.':255(45624)t-2#, icMfgDomain + "/":U + tCopyExchangeRate.tcFromCurrencyCode + "/":U + tCopyExchangeRate.tcToCurrencyCode + "/":U + string(tCopyExchangeRate.ExchangeRateValidDateFrom) + "/":U + tCopyExchangeRate.tcExchangeRateTypeCode))
                oiReturnStatus = -3.
        <M-3 run SetMessage (input  vcMessageText (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  '':U (icRowid), 
                     input  'QadFin-5045':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BMfgExchangeRate>
        Return.
    end. /* if not avail */               

    assign vcWhereClause = 'where exr_curr1=~'':U + tCopyExchangeRate.tcFromCurrencyCode + 
                           '~' and exr_curr2=~'':U + tCopyExchangeRate.tcToCurrencyCode + 
                           '~' and exr_start_date=':U + string(tCopyExchangeRate.ExchangeRateValidDateFrom) +
                           ' and exr_ratetype=~'':U + vcExchangeRateTypeCode  +
                           '~' and exr_domain=~'':U + icMfgDomain + '~'':U.
                           
    temp-table  texr_rate:default-buffer-handle:handle:find-first(vcWhereClause) no-error.
    if error-status:error
    then do :
        assign  vcMessageText  = trim(substitute(#T-4'Cannot find the dynamic record for the replication based on the key &1.':255(45625)t-4#, icMfgDomain + "/":U + tCopyExchangeRate.tcFromCurrencyCode + "/":U + tCopyExchangeRate.tcToCurrencyCode + "/":U + string(tCopyExchangeRate.ExchangeRateValidDateFrom) + "/":U + tCopyExchangeRate.tcExchangeRateTypeCode))
                oiReturnStatus = -3.
        <M-5 run SetMessage (input  vcMessageText (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  '':U (icRowid), 
                     input  'QadFin-5046':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BMfgExchangeRate>
        Return.
    end. /* if error */        
    
    /* ====================================================== */
    /* Set the return status = OK                             */
    /* ====================================================== */
    if oiReturnStatus = -98 
    then assign oiReturnStatus = 0.