project QadFinancials > class BMfgAddress > 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/bmfgaddress.p)

<ANCESTOR-CODE>

If oiReturnStatus = 0
Then Assign oiReturnStatus = -98.

assign 
    tad_mstr.ad_ref          = vcRelatedCustomer
    tad_mstr.ad_type         = vcRelationType.       
    
assign   
    tad_mstr.ad__qad01    = if (tAddress.AddressIsTaxInCity) then "1":U else ""
    tad_mstr.ad_lang =  tAddress.tcLngCode.

/* Only map the CoCNumber field for customer address records */
if vcRelationType = "supplier":U then
    tad_mstr.ad_coc_reg = tAddress.tcCoCNumber.

/* Get the language from the related Business Relation */
<Q-6 run BusinessRelationByIdCode (all) (Read) (NoCache)
          (input tAddress.BusinessRelation_ID, (BusinessRelationId)
           input '', (BusinessRelationCode)
           output dataset tqBusinessRelationByIdCode) in BBusinessRelation >

/* 
* Now map the business relation code.
*/
for first tqBusinessRelationByIdCode:
   assign 
         tad_mstr.ad_bus_relation = tqBusinessRelationByIdCode.tcBusinessRelationCode.
end.


/* get the description of the country */
<Q-2 run CountryPrim (all) (Read) (NoCache)
          (input tAddress.Country_ID, (CountryId)
           input '', (CountryCode)
           output dataset tqCountryPrim) in BCountry >
find first tqCountryPrim no-error.

if available tqCountryPrim then
    assign tad_mstr.ad_country = tqCountryPrim.tcCountryDescription.

/*Update Contact data*/
if can-find(first tContactsToUpdate) then
do:
    /*clear the fields to replicate - their values will be reassigned below*/
    assign
        ad_attn  = "":U
        ad_phone = "":U
        ad_fax   = "":U
        ad_email = "":U
        ad_attn2  = "":U
        ad_phone2 = "":U
        ad_fax2   = "":U
        ad_email2 = "":U.        
    
    /*use the contact data stored in the dataset tContactsToUpdate*/
    for each tContactsToUpdate
    where tContactsToUpdate.tc_Status NE "D"
      and tContactsToUpdate.Address_ID = tAddress.Address_ID:
        if tContactsToUpdate.ContactIsPrimary
        then 
            assign
                ad_attn  = tContactsToUpdate.ContactName
                ad_phone = tContactsToUpdate.ContactTelephone
                ad_fax   = tContactsToUpdate.ContactFax
                ad_email = tContactsToUpdate.ContactEmail.
        else if tContactsToUpdate.ContactIsSecondary
        then
            assign
                ad_attn2  = tContactsToUpdate.ContactName
                ad_phone2 = tContactsToUpdate.ContactTelephone
                ad_fax2   = tContactsToUpdate.ContactFax
                ad_email2 = tContactsToUpdate.ContactEmail.
    end.    
end.
else 

do:
    /* retrieve the contacts for this address from the financials database*/
    <Q-11 run ContactByAddress (all) (Read) (NoCache)
       (input tAddress.Address_ID, (AddressId)
        output dataset tqContactByAddress) in BBusinessRelation >
    for each tqContactByAddress
        where tqContactByAddress.tiaddress_id = tAddress.Address_id:
        if tqContactByAddress.tlContactIsPrimary
        then 
            assign
                ad_attn  = tqContactByAddress.tcContactName
                ad_phone = tqContactByAddress.tcContactTelephone
                ad_fax   = tqContactByAddress.tcContactFax
                ad_email = tqContactByAddress.tcContactEmail.
        else if tqContactByAddress.tlContactIsSecondary
        then
            assign
                ad_attn2  = tqContactByAddress.tcContactName
                ad_phone2 = tqContactByAddress.tcContactTelephone
                ad_fax2   = tqContactByAddress.tcContactFax
                ad_email2 = tqContactByAddress.tcContactEmail.    
    
    end.  /* end of for each contact */
end.

If oiReturnStatus = -98
Then Assign oiReturnStatus = 0.