Description
This empty method allows to do additional updates on class temp-tables after records were received (and validated) from outside, using method SetPublicTables.
You can start instances of other business classes to do those updates.
Parameters
oiReturnStatus | output | integer | |
Internal usage
QadFinancials
program code (program/bbankimportline.p)
<ANCESTOR-CODE>
/* ======================================================================= */
/* Validate the table to check if debtor/creditor name and code changed */
/* ======================================================================= */
assign vlCodeNameChanged = false.
/* defect 10249-0227 we now create remittance address whenever user changed supplier/customer code/name on UI */
for each tBankImpLine where
tBankImpLine.tc_Status <> 'D':U and
tBankImpLine.BankImpLineProcessedStatus <> {&BANKIMPPROCSTATUS-PROCESSED-ERROR} and
((tBankImpLine.Debtor_ID > 0 and
tBankImpLine.BankImpLineDebtorCode <> "":U and
tBankImpLine.BankImpLineDebtorName <> "":U ) or
(tBankImpLine.Creditor_ID > 0 and
tBankImpLine.BankImpLineCreditorCode <> "":U and
tBankImpLine.BankImpLineCreditorName <> "":U )) :
find first tBankImpLineOrig where tBankImpLineOrig.BankImpLine_ID = tBankImpLine.BankImpLine_ID and
((tBankImpLine.Debtor_ID > 0 and
(tBankImpLineOrig.BankImpLineDebtorCode <> tBankImpLine.BankImpLineDebtorCode or
tBankImpLineOrig.BankImpLineDebtorName <> tBankImpLine.BankImpLineDebtorName)) or
(tBankImpLine.Creditor_ID > 0 and
(tBankImpLineOrig.BankImpLineCreditorCode <> tBankImpLine.BankImpLineCreditorCode or
tBankImpLineOrig.BankImpLineCreditorName <> tBankImpLine.BankImpLineCreditorName)))
no-error.
if available tBankImpLineOrig
then do:
assign vlCodeNameChanged = true.
leave.
end.
end. /* end of for each tBankImpLine */
/* ============================================================= */
/* Create Remittance address for the debtor of BankImportLine */
/* ============================================================= */
if vlCodeNameChanged
then do:
empty temp-table tRemittanceAddress.
/* ================================================================= */
/* get remittance address type ID at the begining because it should */
/* not be included in the main for each loop */
/* ================================================================= */
<Q-8 run AddressTypeByCode (all) (Read) (NoCache)
(input {&ADDRESSTYPECODESYSTEM-REMITTANCE}, (AddressTypeCode)
output dataset tqAddressTypeByCode) in BAddressType >
find first tqAddressTypeByCode no-error.
if available tqAddressTypeByCode
then do:
/* start quries that will be called multiple times in For each */
<Q-26 run DebtorPrim (Start) in BDebtor >
<Q-40 run CreditorPrim (Start) in BCreditor >
/* ===================================================================== */
/* checking Debtor ID to make sure the debtor infor was not missing */
/* checking debtor code and name is because they are the key fields, */
/* processing logic needs the two fields to get saved remittance address */
/* ===================================================================== */
for each tBankImpLine where
tBankImpLine.tc_Status <> 'D':U and
tBankImpLine.BankImpLineProcessedStatus <> {&BANKIMPPROCSTATUS-PROCESSED-ERROR} and
tBankImpLine.Debtor_ID > 0 and
tBankImpLine.BankImpLineDebtorCode <> "":U and
tBankImpLine.BankImpLineDebtorName <> "":U :
/* to check if there is remittance address with same debtor name and code exists */
<Q-28 assign vlFcQueryRecordsAvailable = AddressByDebtorAddressType (NoCache)
(input viCompanyId, (CompanyId)
input ?, (DebtorId)
input tBankImpLine.BankImpLineDebtorCode, (AddressSearchName)
input tBankImpLine.BankImpLineDebtorName, (AddressName)
input {&ADDRESSTYPECODESYSTEM-REMITTANCE}, (AddressTypeCode)) in BBusinessRelation >
if vlFcQueryRecordsAvailable = false
then do:
/* get business relation ID for validation and assignment later*/
<Q-42 run DebtorPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input '':U, (DebtorCode)
input tBankImpLine.Debtor_ID, (Debtor_ID)
output dataset tqDebtorPrim) in BDebtor >
find first tqDebtorPrim no-error.
if available tqDebtorPrim
then do:
/* not using check exist because if the zip/city is empty, it will be ignored by the query */
<Q-46 run AddressPrim (all) (Read) (NoCache)
(input '':U, (AddressCity)
input '':U, (AddressStreet1)
input '':U, (AddressStreet2)
input '':U, (AddressZip)
input '':U, (AddressTypeCode)
input ?, (AddressID)
input tqDebtorPrim.tiBusinessRelation_ID, (BusinessRelationID)
input '':U, (BusinessRelationCode)
input tqAddressTypeByCode.tiAddressType_ID, (AddressTypeID)
input '':U, (AddressStreet3)
output dataset tqAddressPrim) in BBusinessRelation >
find first tqAddressPrim where tqAddressPrim.tcAddressCity = tBankImpLine.BankImpLineAddressCity and
tqAddressPrim.tcAddressZip = tBankImpLine.BankImpLineAddressZip
no-error.
if not available tqAddressPrim
then do:
create tRemittanceAddress.
/* assign address info from Import Line to remittance address */
assign tRemittanceAddress.AddressCity = tBankImpLine.BankImpLineAddressCity
tRemittanceAddress.tcCountryCode = tBankImpLine.BankImpLineAddressCountry
tRemittanceAddress.AddressName = tBankImpLine.BankImpLineDebtorName
tRemittanceAddress.AddressSearchName = tBankImpLine.BankImpLineDebtorCode
tRemittanceAddress.AddressZip = tBankImpLine.BankImpLineAddressZip
tRemittanceAddress.AddressType_ID = tqAddressTypeByCode.tiAddressType_ID
tRemittanceAddress.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-REMITTANCE}
tRemittanceAddress.tc_Rowid = string(rowid(tRemittanceAddress))
tRemittanceAddress.BusinessRelation_ID = tqDebtorPrim.tiBusinessRelation_ID.
end. /* end of if vlFcQueryRecordsAvailable */
end. /* end of if available tqDebtorPrim */
end. /* end of if vlFcQueryRecordsAvailable = false */
end. /* end of for each */
/* ==================================================================== */
/* checking Creditor ID to make sure the Creditor infor was not missing */
/* checking Creditor code and name is because they are the key fields, */
/* processing logic needs the two fields to get saved remittance address*/
/* ==================================================================== */
for each tBankImpLine where
tBankImpLine.tc_Status <> 'D':U and
tBankImpLine.BankImpLineProcessedStatus <> {&BANKIMPPROCSTATUS-PROCESSED-ERROR} and
tBankImpLine.Creditor_ID > 0 and
tBankImpLine.BankImpLineCreditorCode <> "":U and
tBankImpLine.BankImpLineCreditorName <> "":U :
/* to check if there is remittance address with same Creditor name and code exists */
<Q-31 assign vlFcQueryRecordsAvailable = AddressByCreditorAddressType (NoCache)
(input viCompanyId, (CompanyId)
input ?, (CreditorId)
input tBankImpLine.BankImpLineCreditorCode, (AddressSearchName)
input tBankImpLine.BankImpLineCreditorName, (AddressName)
input {&ADDRESSTYPECODESYSTEM-REMITTANCE}, (AddressTypeCode)) in BBusinessRelation >
if vlFcQueryRecordsAvailable = false
then do:
/* get business relation ID for validation and assignment later*/
<Q-45 run CreditorPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tBankImpLine.Creditor_ID, (CreditorId)
input '':U, (CreditorCode)
output dataset tqCreditorPrim) in BCreditor >
find first tqCreditorPrim no-error.
if available tqCreditorPrim
then do:
/* to validate if it is address table unique index violate: street, zip, city, br_id, type_id */
/* not using check exist because if the zip/city is empty, it will be ignored by the query */
<Q-44 run AddressPrim (all) (Read) (NoCache)
(input '':U, (AddressCity)
input '':U, (AddressStreet1)
input '':U, (AddressStreet2)
input '':U, (AddressZip)
input '':U, (AddressTypeCode)
input ?, (AddressID)
input tqCreditorPrim.tiBusinessRelation_ID, (BusinessRelationID)
input '':U, (BusinessRelationCode)
input tqAddressTypeByCode.tiAddressType_ID, (AddressTypeID)
input '':U, (AddressStreet3)
output dataset tqAddressPrim) in BBusinessRelation >
find first tqAddressPrim where tqAddressPrim.tcAddressCity = tBankImpLine.BankImpLineAddressCity and
tqAddressPrim.tcAddressZip = tBankImpLine.BankImpLineAddressZip
no-error.
if not available tqAddressPrim
then do:
create tRemittanceAddress.
/* assign address info from Import Line to remittance address */
assign tRemittanceAddress.AddressCity = tBankImpLine.BankImpLineAddressCity
tRemittanceAddress.tcCountryCode = tBankImpLine.BankImpLineAddressCountry
tRemittanceAddress.AddressName = tBankImpLine.BankImpLineCreditorName
tRemittanceAddress.AddressSearchName = tBankImpLine.BankImpLineCreditorCode
tRemittanceAddress.AddressZip = tBankImpLine.BankImpLineAddressZip
tRemittanceAddress.AddressType_ID = tqAddressTypeByCode.tiAddressType_ID
tRemittanceAddress.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-REMITTANCE}
tRemittanceAddress.tc_Rowid = string(rowid(tRemittanceAddress))
tRemittanceAddress.BusinessRelation_ID = tqCreditorPrim.tiBusinessRelation_ID.
end. /* end of if vlFcQueryRecordsAvailable */
end. /* end of if available tqCreditorPrim */
end. /* end of if vlFcQueryRecordsAvailable = false */
end. /* end of for each */
/* stop quries */
<Q-27 run DebtorPrim (Stop) in BDebtor >
<Q-37 run CreditorPrim (Stop) in BCreditor >
if can-find(first tRemittanceAddress)
then do:
/* =============================================*/
/* create remittance address */
/* start component instance of Business Relation*/
/* =============================================*/
if viBBusinessRelation3ID = 0 or
viBBusinessRelation3ID = ?
then do:
<I-16 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BBusinessRelation"}>
end. /* end of if if viBBusinessRelation3ID = 0 */
else do:
<I-17 {bFcOpenInstance
&CLASS = "BBusinessRelation"}>
end. /* end of else do */
/* call method in BBusinessRelation to create remittance */
<M-20 run CreateRemittanceAddress
(input tRemittanceAddress (tRemittanceAddressToCreate),
input false (ilClearData),
output viExternalReturnStatus (oiReturnStatus)) in BBusinessRelation>
if viExternalReturnStatus < 0 or (viExternalReturnStatus > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viExternalReturnStatus.
if viExternalReturnStatus < 0
then do:
<I-21 {bFcStopInstance
&CLASS = "BBusinessRelation"}>
return.
end.
/* call the validation and additional methods of Business Relation and stop instance if failed */
<M-22 run ValidateBCAndAdditionalUpdates (output viExternalReturnStatus (oiReturnStatus)) in BBusinessRelation>
<I-23 {bFcCloseInstance
&CLASS = "BBusinessRelation"}>
if viExternalReturnStatus < 0 or (viExternalReturnStatus > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viExternalReturnStatus.
if viExternalReturnStatus < 0
then do:
<I-24 {bFcStopInstance
&CLASS = "BBusinessRelation"}>
return.
end.
end. /* end of if can-find(first tRemittanceAddress) */
end. /* end of if available */
end. /* end of if vlCodeNameChanged */