project QadFinancials > class BMfgAddress > method ReplicateFromFinancialsEndUserUpd
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program9/bmfgaddress.p)
/* ====================================================================================== *
* Method : ReplicateFromFinancialsEndUserUpd *
* Description : Copy data from Finance data into Operational data *
* -------------------------------------------------------------------------------------- *
* Parameters : *
* ====================================================================================== */
assign oiReturnStatus = -98
viLocalReturn = 0.
MAIN_BLOCK:
do on error undo, return:
if tDebtorEndUsersToUpdate.DebtorEndUserIsDebtor = true
then assign vcRelationType = "customer":U.
else if tDebtorEndUsersToUpdate.DebtorEndUserIsShipTo
then assign vcRelationType = {&ADDRESSTYPECODESYSTEM-DELIVERY}.
else assign vcRelationType = {&ADDRESSTYPECODESYSTEM-ENDUSER}.
if tAddress.tcCountryDescription = "":U or
tAddress.tcCountryDescription = ?
then do :
<Q-35 run CountryByCode (all) (Read) (NoCache)
(input tAddress.tcCountryCode, (CountryCode)
output dataset tqCountryByCode) in BCountry>
find first tqCountryByCode where
tqCountryByCode.tcCountryCode = tAddress.tcCountryCode
no-error .
if available tqCountryByCode
then assign tAddress.tcCountryDescription = tqCountryByCode.tcCountryDescription.
end.
assign tad_mstr.ad_ref = tDebtorEndUsersToUpdate.tcDebtorCode
tad_mstr.ad_line1 = tAddress.AddressStreet1
tad_mstr.ad_line2 = tAddress.AddressStreet2
tad_mstr.ad_line3 = tAddress.AddressStreet3
tad_mstr.ad_zip = tAddress.AddressZip
tad_mstr.ad_city = tAddress.AddressCity
tad_mstr.ad_state = tAddress.AddressState
tad_mstr.ad_county = tAddress.tcCountyCode
tad_mstr.ad_country = tAddress.tcCountryDescription
tad_mstr.ad_state = tAddress.tcStateCode
tad_mstr.ad_ctry = tAddress.tcCountryCode
tad_mstr.ad_lang = tAddress.tcLngCode
tad_mstr.ad_name = tAddress.AddressName
tad_mstr.ad_sort = tAddress.AddressSearchName
tad_mstr.ad_address_id = tAddress.Address_ID
tad_mstr.ad_bus_relation = tDebtorEndUsersToUpdate.tcBusinessRelationCode
tad_mstr.ad_mod_date = tAddress.LastModifiedDate
tad_mstr.ad_type = vcRelationType
tad_mstr.ad_taxable = tAddress.AddressIsTaxable
tad_mstr.ad_tax_zone = tAddress.TxzTaxZone
tad_mstr.ad_taxc = tAddress.TxclTaxCls
tad_mstr.ad_tax_usage = tAddress.TxuTaxUsage
tad_mstr.ad_gst_id = tAddress.AddressTaxIDFederal
tad_mstr.ad_pst_id = tAddress.AddressTaxIDState
tad_mstr.ad_misc1_id = tAddress.AddressTaxIDMisc1
tad_mstr.ad_misc2_id = tAddress.AddressTaxIDMisc2
tad_mstr.ad_misc3_id = tAddress.AddressTaxIDMisc3
tad_mstr.ad_format = tAddress.AddressFormat
tad_mstr.ad_userid = tAddress.LastModifiedUser
tad_mstr.ad_phone = substring(tAddress.AddressTelephone, 1, 20, "CHARACTER")
tad_mstr.ad_fax = substring(tAddress.AddressFax, 1, 20, "CHARACTER")
tad_mstr.ad_email = substring(tAddress.AddressEMail, 1, 48, "CHARACTER")
tad_mstr.ad_tax_in_city = tAddress.AddressIsTaxInCity
tad_mstr.tc_Status = (if tDebtorEndUsersToUpdate.tc_Status = "D":U and
/* no need to delete ad_mstr since no ad_mstr record is
created when enduser is linked to debtor */
tDebtorEndUsersToUpdate.DebtorEndUserIsDebtor <> true
then tDebtorEndUsersToUpdate.tc_Status
else tad_mstr.tc_Status).
for each tContactsToUpdate where
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.
if tContactsToUpdate.ContactIsSecondary
then assign ad_attn2 = tContactsToUpdate.ContactName
ad_phone2 = tContactsToUpdate.ContactTelephone
ad_fax2 = tContactsToUpdate.ContactFax
ad_email2 = tContactsToUpdate.ContactEmail.
end. /* end of for each contact */
end. /* MAIN_BLOCK */
assign oiReturnStatus = viLocalReturn.