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
icMfgTableName | input | character | Name 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. |
icFinancialTableName | input | character | Name 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. |
ihFinancialDataBuffer | input | handle | |
ihMfgDataBuffer | input | handle | |
icMfgDomain | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program/bmfgenduser.p)
<ANCESTOR-CODE>
assign oiReturnStatus = -98.
/* get the address information from the business relation instance.*/
if icMfgTableName EQ 'eu_mstr'
then do:
empty temp-table tEndUserAddress.
<M-12 run GetAddressWithID (input tDebtorEndUser.address_id (iiAddressID),
input-output tEndUserAddress (tApiAddress),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
/* find the t_saddress record we just created */
for first tEndUserAddress
where tEndUserAddress.address_id = tDebtorEndUser.address_id:
assign
teu_mstr.eu_lang = tEndUserAddress.tcLngCode
teu_mstr.eu_sort = tEndUserAddress.AddressSearchName.
end.
empty temp-table tContact.
/* get the current contacts for this address */
<M-19 run GetContactByAddress (input tDebtorEndUser.Address_id (iiAddressID),
input-output tContact (tApiContact),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
if tDebtorEndUser.tc_status = "C"
then do:
/* if we are doing a modify then get all the change contacts.*/
<Q-25 run ContactByAddress (all) (Read) (NoCache)
(input tDebtorEndUser.Address_ID, (AddressId)
output dataset tqContactByAddress) in BBusinessRelation >
end.
for each tContact break by tContact.tc_Status:
if tContact.tc_Status = "C"
then do:
/* Get the old contact name (ie one currently stored in db) this allows us to indentify the mfg/pro record
correctly to update the name */
/* We need to delete this record as its key value is changing */
/* zjc eB3RegTst1-2636 Begin */
for first tqContactByAddress
where tqContactByAddress.tiContact_id = tContact.contact_id:
/* and tqContactByAddress.tcContactName <> tContact.ContactName: */
for first teud_det
where teud_det.eud_domain = teu_mstr.eu_domain
and teud_det.eud_addr = tDebtorEndUser.DebtorEndUserCode
and teud_det.eud_sort = tqContactByAddress.tcContactName:
assign teud_det.tc_status = "D".
end.
end.
/* zjc eB3RegTst1-2636 end */
end.
else do:
/* Check to see if we have an existing teud_det record for the contact*/
for first teud_det
where teud_det.eud_domain = teu_mstr.eu_domain
and teud_det.eud_addr = tDebtorEndUser.DebtorEndUserCode
and teud_det.eud_sort = tContact.ContactName:
assign teud_det.tc_status = tContact.tc_status.
end.
end.
/* if we don't have eud_det record for this contact then create one */
/* or if the contact name is changed then create a new eud_det as the preivous one is marked as "D" */
if not available(teud_det) or (available(teud_det) and teud_det.tc_status = "D" and tContact.tc_Status = "C" )
then do:
<M-20 run AddDetailLine (input 'eud_det':u (icTable),
input teu_mstr.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BMfgEndUser>
assign
teud_det.oid_eud_det = <M-23 GetNextOidValue () in BMfgEndUser>
teud_det.eud_ls_type = {&ADDRESSTYPECODESYSTEM-ENDUSER}
teud_det.eud_domain = teu_mstr.eu_domain.
end.
/* assign complex mapping fields */
assign
teud_det.eud_sort = tContact.ContactName
teud_det.eud_title = tContact.ContactTitle
teud_det.eud_type = tContact.ContactFunction
teud_det.eud_phone = tContact.ContactTelephone
teud_det.eud_fax = tContact.ContactFax
teud_det.eud_updt = TODAY
teud_det.eud_nametype = if tContact.ContactisPrimary then "P" else ""
teud_det.eud_addr = tDebtorEndUser.DebtorEndUserCode.
end.
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end.
if oiReturnStatus = -98
then assign oiReturnStatus = 0.