project QadFinancials > class BMfgSupplier > 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/bmfgsupplier.p)

/* Without the <ANCESTOR-CODE> tag, the t_sCreditor is not available so we need to have it in */
<ANCESTOR-CODE>

assign oiReturnStatus = -98.
/*
* Create a query to extract the currnecy data from the MFG/PRO database into the objects 
* tcu_mstr temp table that holds the objects data 
*/

find current tCreditor no-error.

assign
    vcTableKeys = icMfgDomain + chr(2) + tCreditor.CreditorCode.
 
 
/*
* Get the Creditor Code From MFG/PRO that we need to update.
*/
  <M-1 run DataLoad (input  '' (icRowids), 
                   input  vcTableKeys (icPkeys), 
                   input  '' (icObjectIds), 
                   input  '' (icFreeform), 
                   input  true (ilKeepPrevious), 
                   output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>

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 tac_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 fins are 
* executed.
*/
find first tvd_mstr
     where tvd_mstr.vd_domain = icMfgDomain
       and tvd_mstr.vd_addr   = tCreditor.CreditorCode
    no-error.

if not available tvd_mstr and tCreditor.tc_Status <> "N":U then do:
    assign vcMessageText = trim(substitute(#T-4'Cannot find the static record for the replication based on the key &1.':255(45624)t-4#, icMfgDomain + "/":U + tCreditor.CreditorCode))
           oiReturnStatus = -3.
    <M-2 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-5084':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>
    return.
end. /* if not availabe tvd_mstr */

assign
    vcWhereClause = "where vd_domain = ":U + <M-6 EnQuote  (input  icMfgDomain (icToQuote)) in BMfgSupplier> + 
                    " and vd_addr = ":U + <M-7 EnQuote  (input  tCreditor.CreditorCode (icToQuote)) in BMfgSupplier>.

temp-table tvd_mstr:default-buffer-handle:find-first(vcWhereClause) no-error.

if error-status:error then do:
    assign vcMessageText = trim(substitute(#T-5'Cannot find the dynamic record for the replication based on following key: &1':255(45741)t-5#, icMfgDomain + "/":U + tCreditor.CreditorCode))
           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-5085':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>
    return.
end. /* if error-status:error then do */

if oiReturnStatus = -98
then assign oiReturnStatus = 0.