project QadFinancials > class BMfgCustomer > method UpdateMfgData

Description

Controls the processing of any update logic that is required when performing a create/modfiy operation on an MFG/PRO business component.
KEEP THE ANCESTOR TAG IN THE DESCENDANTS TO AVOID SCOPING PROBLEMS ON THE RECORD-AVAILABILITY
This method is the place holder for nay update ligic and complex mapping from the financials table to MFG/PRO.


Parameters


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 Financial 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 has multiple tables that map to MFG/PRO.
ihFinancialDataBufferinputhandle
ihMfgDataBufferinputhandle
icMfgDomaininputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program/bmfgcustomer.p)

<ANCESTOR-CODE>
if oiReturnStatus = 0
then oiReturnStatus = -98.

assign
    tcm_mstr.cm_mod_date = TODAY
    tcm_mstr.cm_userid = vcUserLogin.
/*  tcm_mstr.cm_lang should be populated with the Language Code from the HEADOFFICE address of 
the business relation assigned to the customer not the BusinessRelation itself */
/* Get the language from the related Business Relation */
/*
<Q-1 run BusinessRelationByIdCode (all) (Read) (NoCache)
          (input tDebtor.BusinessRelation_ID, (BusinessRelationId)
           input '', (BusinessRelationCode)
           output dataset tqBusinessRelationByIdCode) in BBusinessRelation >

/* 
* Now map this language to an MFG/PRO language code
* This is done in 2 steps - the segment that the GetMfgLanguage code runs in does not have access to the temp table 
*/
/* Mfg language and Fin language are equal and GetMfgLanguage is not needed */
for first tqBusinessRelationByIdCode:
   assign    
       tcm_mstr.cm_lang =   tqBusinessRelationByIdCode.tcLngCode.
end.
*/  
/*
* mapping search name to MFG/PRO sort name, assign the sort name as the headoffice's search name
*/
if vlAutoGenACEdit = ? then 
do:
    <Q-62 run PricingControlByDomain (all) (Read) (NoCache)
       (input vcDomainCode, (Domain)
        output dataset tqPricingControlByDomain) in BMfgPricingControl>
    find first tqPricingControlByDomain where tqPricingControlByDomain.tcpic_domain = Vcdomaincode no-error.
    if available tqPricingControlByDomain and
        substring(tqPricingControlByDomain.tcpic__qadc01,1,1,"CHARACTER":U) = "Y" 
    then vlAutoGenACEdit = true.
    else vlAutoGenACEdit = false.
end.

<Q-29 run AddressByAddressType (all) (Read) (NoCache)
   (input tDebtor.BusinessRelation_ID, (BusinessRelationId)
    input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
    output dataset tqAddressByAddressType) in BBusinessRelation >

find first tqAddressByAddressType no-error.
   
if available tqAddressByAddressType 
then do: 
    if vlAutoGenACEdit and tcm_mstr.cm_sort <> tqAddressByAddressType.tcAddressSearchName then
    do:
        find first tAutoGenCustList where tAutoGenCustList.tcanx_domain = tcm_mstr.cm_domain and 
            tAutoGenCustList.tcanx_node = tcm_mstr.cm_addr 
        no-error.
        if not available tAutoGenCustList 
        then do:
             create tAutoGenCustList.
             assign tAutoGenCustList.tcanx_domain = tcm_mstr.cm_domain
                    tAutoGenCustList.tcanx_node   = tcm_mstr.cm_addr
                    tAutoGenCustList.tcanx_type   = "9".
        end.
    end.
      assign 
          tcm_mstr.cm_sort = tqAddressByAddressType.tcAddressSearchName
          tcm_mstr.cm_lang = tqAddressByAddressType.tcLngCode.

end.   
else do:
      assign vhFcComponent  = ?
         oiReturnStatus = -25.
      <M-30 run CreateCorruption
          (input  'tDebtor':U (icTableName), 
           input  tDebtor.DebtorCode (icKey), 
           input  trim(#T-1'A head office address has not been defined for this customer.':100(46824)t-1#) (icDescription), 
           input  ? (ilSkipMessage), 
           output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
end.   

if oiReturnStatus eq -98
    then assign oiReturnStatus = 0.