Description
Add code here to initialize the calculated fields of the class temp-tables after loading existing records from the application database.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bdebtorshipto.p)
<ANCESTOR-CODE>
empty temp-table tDebtorShiptoContact.
for each tDebtorShipTo:
if vlDataLoadKeepPrevious and
can-find (tAlreadyCalculatedRecords where
tAlreadyCalculatedRecords.tcTableName = "DebtorShipTo" and
tAlreadyCalculatedRecords.tc_Rowid = tDebtorShipTo.tc_Rowid)
then next.
/* Get the Businress Relation id for the Debtor and store it in the calculate field */
<Q-2 run DebtorPrim (all) (Read) (Cache)
(input viCompanyID, (CompanyId)
input '', (DebtorCode)
input tDebtorShipTo.debtor_id, (Debtor_ID)
output dataset tqDebtorPrim) in BDebtor >
for first tqDebtorPrim:
assign tDebtorShipTo.tiDebtorBusinessRelation_ID = tqDebtorPrim.tiBusinessRelation_ID.
end.
/* store the rowid of the current address if there is one*/
if tDebtorShipto.Address_id <> 0
then do:
<Q-89 run AddressPrim (all) (Read) (Cache)
(input ?, (AddressCity)
input ?, (AddressStreet1)
input ?, (AddressStreet2)
input ?, (AddressZip)
input ?, (AddressTypeCode)
input tDebtorShipto.address_id, (AddressID)
input ?, (BusinessRelationID)
input ?, (BusinessRelationCode)
input ?, (AddressTypeID)
input ?, (AddressStreet3)
output dataset tqAddressPrim) in BBusinessRelation >
for first tqAddressPrim:
assign tDebtorShipTo.tcAddress_rowid = tqAddressPrim.tc_rowid.
end.
end.
/* retrieve all the contacts for this address */
<Q-13 run ContactByAddress (all) (Read) (Cache)
(input tDebtorShipto.address_id, (AddressId)
output dataset tqContactByAddress) in BBusinessRelation >
/* add the contact to the address if we don't already have it stored */
for each tqContactByAddress where
tqContactbyAddress.tiAddress_id = tDebtorShipto.address_id:
if not can-find(tDebtorShiptoContact where tDebtorShiptoContact.contact_id = tqContactByAddress.ticontact_id)
then do:
create tDebtorShiptoContact.
<M-14 run BufferCopy
(input buffer tqContactByAddress:handle (ihFrom),
input buffer tDebtorShiptoContact:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDebtorShipTo>
if viFcReturnSuper < 0 or
viFcReturnSuper <> 0 and
viLocalStatus = 0
then assign viLocalStatus = viFcReturnSuper.
assign tDebtorShiptoContact.tc_ParentRowid = tDebtorShipTo.tcAddress_rowid.
end.
end. /* end for each contact */
/* Populate the tlAddressIsShared field - this indicates if the address is in use by other ship-tos or not */
<Q-31 assign vlFcQueryRecordsAvailable = DebtorShiptoByAddress (NoCache)
(input ?, (CompanyId)
input tDebtorShipto.address_id, (AddressID)
input tDebtorShipTo.DebtorShipTo_ID, (DebtorShiptoIDDifferentFrom)) in BDebtorShipTo >
if vlFcQueryRecordsAvailable <> no
then
assign tDebtorShipto.tlAddressIsShared = true.
end.
assign oiReturnStatus = viLocalStatus.