Parameters
| iiPaySel_ID | input | integer | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program7/bpaymentselection.p)
/* ========================================================= */
/* Fill the ttGL temp table and it's child temp tables
step1. Start All the Queries which will be used in the procedure.
step2. Run the Query to get the records of the target table by supplying the ID parameter.
step3. Validate whether the query return the expect records,if yes then continue else return.
step4. Buffercopy the query result to the target temp table.
step5. (optional) Do some calculation work.
step6. Go to step2 until fill all the child temp tables.
step7. Stop all the querries used in the procedure. */
/* ========================================================= */
if oiReturnStatus = 0
then assign oiReturnStatus = -98.
<Q-7 run GLByIDsAllInfo
(Start) in BGL >
<Q-8 run CurrencyByIDAllInfo
(Start) in BCurrency >
<Q-26 run BankNumberByParentAllInfo
(Start) in BBankNumber >
<Q-44 run ContactByIDAllInfo
(Start) in BBusinessRelation >
<Q-45 run BusinessRelationByIDAllInfo
(Start) in BBusinessRelation >
<Q-46 run AddressByIDsAllInfo
(Start) in BBusinessRelation >
<Q-47 run CountryByIDAllInfo
(Start) in BCountry >
<Q-48 run StateByIDAllInfo
(Start) in BState >
<Q-16 run BankBranchByUnqIdx
(Start) in BBankBranch>
for each tPaySel where tPaySel.PaySel_ID = iiPaySel_ID:
<Q-1 run GLByIDsAllInfo (all) (Read) (NoCache)
(input tPaySel.Company_ID, (CompanyId)
input tPaySel.GL_ID, (GL_ID)
output dataset tqGLByIDsAllInfo) in BGL >
find first tqGLByIDsAllInfo no-error.
if not available tqGLByIDsAllInfo
then do:
<M-18 run SetMessage
(input #T-19'No GL account record is available.':50(999890601)T-19# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5345':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign
oiReturnStatus = -1.
return.
end. /* end of if not available tqGLByIDsAllInfo */
else do:
assign
vhBufferForProDataSet = dataset tqGLByIDsAllInfo:get-buffer-handle(1).
for each tqGLByIDsAllInfo:
find first tPaySelGL where tPaySelGL.GL_ID = tqGLByIDsAllInfo.tiGL_ID no-error.
if not available tPaySelGL
then do: /* avoid duplicate key issue */
create tPaySelGL.
<M-5 run BufferCopy
(input vhBufferForProDataSet (ihFrom),
input buffer tPaySelGL:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
/*Enhancement for SEPA*/
if tPaySelGL.GLIsLocalCurrency = true
then assign tPaySelGL.Currency_ID = tPropertyOfCompany.Currency_ID.
<Q-6 run CurrencyByIDAllInfo (all) (Read) (NoCache)
(input tPaySelGL.Currency_ID, (Currency_ID)
output dataset tqCurrencyByIDAllInfo) in BCurrency >
find first tqCurrencyByIDAllInfo no-error.
if not available tqCurrencyByIDAllInfo
then do:
<M-20 run SetMessage
(input #T-21'No currency record is available.':50(49130)T-21# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5346':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end. /* end of if not available tqCurrencyByIDAllInfo */
else do:
assign
vhBufferForCurrency = dataset tqCurrencyByIDAllInfo:get-buffer-handle(1).
for each tqCurrencyByIDAllInfo:
find first tCurrencyOfGL where tCurrencyOfGL.Currency_ID = tqCurrencyByIDAllInfo.tiCurrency_ID no-error.
if not available tCurrencyOfGL
then do: /* avoid duplicate key issue */
create tCurrencyOfGL.
<M-14 run BufferCopy
(input vhBufferForCurrency (ihFrom),
input buffer tCurrencyOfGL:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
end. /* for each tqCurrencyAllInfo */
end. /* tqCurrencyAllInfo else do */
/* defect 10249-0373 to find the correct bank number by bank payment format */
<Q-56 run BankPayFormatPrim (all) (Read) (NoCache)
(input ?, (BankNumberId)
input tPaySel.BankPayFormat_ID, (BankPayFormatId)
input '':U, (PayFormatTypeCode)
output dataset tqBankPayFormatPrim) in BBankPayFormat >
find first tqBankPayFormatPrim no-error.
if available tqBankPayFormatPrim
then do:
<Q-25 run BankNumberByParentAllInfo (all) (Read) (NoCache)
(input ?, (BankNumberIsDefault)
input tPaySelGL.GL_ID, (ParentObject_ID)
input viCompanyId, (CompanyId)
output dataset tqBankNumberByParentAllInfo) in BBankNumber >
find first tqBankNumberByParentAllInfo where
tqBankNumberByParentAllInfo.tiBankNumber_ID = tqBankPayFormatPrim.tiBankNumber_ID no-error.
if not available tqBankNumberByParentAllInfo
then do:
<M-22 run SetMessage
(input #T-23'No GL bank number record is available.':50(999890602)T-23# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5347':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
else do:
assign
vhBufferForBankNumber = dataset tqBankNumberByParentAllInfo:get-buffer-handle(1).
for each tqBankNumberByParentAllInfo where tqBankNumberByParentAllInfo.tiBankNumber_ID = tqBankPayFormatPrim.tiBankNumber_ID:
find first tBankNumberOfGL where tBankNumberOfGL.BankNumber_ID = tqBankNumberByParentAllInfo.tiBankNumber_ID no-error.
if not available tBankNumberOfGL
then do: /* avoid dupliate key issue */
create tBankNumberOfGL.
<M-17 run BufferCopy
(input vhBufferForBankNumber (ihFrom),
input buffer tBankNumberOfGL:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<Q-57 run BankAccFormatPrim (all) (Read) (NoCache)
(input tBankNumberOfGL.BankAccFormat_ID, (BankAcctFormatId)
input ?, (BankAcctFormatCode)
output dataset tqBankAccFormatPrim) in BBankAccountFormat >
find first tqBankAccFormatPrim no-error.
if available tqBankAccFormatPrim then
tBankNumberOfGL.tcBankAccFormatCode = tqBankAccFormatPrim.tcBankAccFormatCode.
end.
if tBankNumberOfGL.Currency_ID<>0
then do:
<Q-54 run CurrencyByIDAllInfo (all) (Read) (NoCache)
(input tBankNumberOfGL.Currency_ID, (Currency_ID)
output dataset tqCurrencyByIDAllInfo) in BCurrency >
find first tqCurrencyByIDAllInfo no-error.
if available tqCurrencyByIDAllInfo
then do:
find first tGLBankCurrency where tGLBankCurrency.Currency_ID = tqCurrencyByIDAllInfo.tiCurrency_ID no-error.
if not available tGLBankCurrency
then do:
create tGLBankCurrency.
<M-55 run BufferCopy
(input buffer tqCurrencyByIDAllInfo:handle (ihFrom),
input buffer tGLBankCurrency:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
end.
end.
if tBankNumberOfGL.BankBusinessRelation_ID <> 0
then do:
if tBankNumberOfGL.BankNumberBranch <> ? and tBankNumberOfGL.BankNumberBranch <> "":U
then do:
<Q-77 run BankBranchByUnqIdx (all) (Read) (NoCache)
(input tBankNumberOfGL.BankBusinessRelation_ID, (BusinessRelation_ID)
input tBankNumberOfGL.BankNumberBranch, (BankBranchCode)
output dataset tqBankBranchByUnqIdx) in BBankBranch>
find first tqBankBranchByUnqIdx no-error.
if available tqBankBranchByUnqIdx then do:
assign tBankNumberOfGL.tcBankBranchName1 = tqBankBranchByUnqIdx.tcBankBranchName1
tBankNumberOfGL.tcBankBranchName2 = tqBankBranchByUnqIdx.tcBankBranchName2.
end.
end.
<Q-28 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
(input tBankNumberOfGL.BankBusinessRelation_ID, (BusinessRelation_ID)
output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >
find first tqBusinessRelationByIDAllInfo no-error.
if not available tqBusinessRelationByIDAllInfo
then do:
<M-29 run SetMessage
(input #T-41'No business relation record is available.':50(49134)T-41# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5732':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign
oiReturnStatus = -1.
return.
end. /* end of if not available tqBusinessRelationByIDAllInfo */
else do:
assign
vhBufferForBusinessRelation = dataset tqBusinessRelationByIDAllInfo:get-buffer-handle(1).
for first tqBusinessRelationByIDAllInfo:
find first tGLBankBusRel where tGLBankBusRel.BusinessRelation_ID = tqBusinessRelationByIDAllInfo.tiBusinessRelation_ID no-error.
if not available tGLBankBusRel
then do: /* avoid dupliate key issue */
create tGLBankBusRel.
<M-30 run BufferCopy
(input vhBufferForBusinessRelation (ihFrom),
input buffer tGLBankBusRel:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
<Q-31 run ContactByIDAllInfo (all) (Read) (NoCache)
(input tGLBankBusRel.BusinessRelation_ID, (BusinessRelation_ID)
output dataset tqContactByIDAllInfo) in BBusinessRelation >
assign
vhBufferForContact = dataset tqContactByIDAllInfo:get-buffer-handle(1).
for each tqContactByIDAllInfo:
find first tGLBankContact where tGLBankContact.Contact_ID = tqContactByIDAllInfo.tiContact_ID no-error.
if not available tGLBankContact
then do: /* avoid duplicate key issue */
create tGLBankContact.
<M-32 run BufferCopy
(input vhBufferForContact (ihFrom),
input buffer tGLBankContact:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
end. /*for each tqContactByIDAllInfo*/
<Q-33 run AddressByIDsAllInfo (all) (Read) (NoCache)
(input tGLBankBusRel.BusinessRelation_ID, (BusinessRelation_ID)
input viAddressType_ID, (AddressType_ID)
output dataset tqAddressByIDsAllInfo) in BBusinessRelation >
find first tqAddressByIDsAllInfo no-error.
if not available tqAddressByIDsAllInfo
then do:
<M-34 run SetMessage
(input #T-42'No address record is available.':50(49132)T-42# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5733':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign
oiReturnStatus = -1.
return.
end. /* end of if not available tqAddressByIDsAllInfo */
else do:
assign
vhBufferForAddress = dataset tqAddressByIDsAllInfo:get-buffer-handle(1).
for first tqAddressByIDsAllInfo:
find first tGLBankAddress where tGLBankAddress.Address_ID = tqAddressByIDsAllInfo.tiAddress_ID no-error.
if not available tGLBankAddress
then do:
create tGLBankAddress.
<M-35 run BufferCopy
(input vhBufferForAddress (ihFrom),
input buffer tGLBankAddress:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
<Q-36 run CountryByIDAllInfo (all) (Read) (NoCache)
(input tGLBankAddress.Country_ID, (Country_ID)
output dataset tqCountryByIDAllInfo) in BCountry >
find first tqCountryByIDAllInfo no-error.
if not available tqCountryByIDAllInfo
then do:
<M-37 run SetMessage
(input #T-43'No country record is available.':50(49133)T-43# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5734':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign
oiReturnStatus = -1.
return.
end. /* end of if not available tqCountryByIDAllInfo */
else do:
assign
vhBufferForCountry = dataset tqCountryByIDAllInfo:get-buffer-handle(1).
for first tqCountryByIDAllInfo:
find first tGLBankCountry where
tGLBankCountry.CountryCode = tqCountryByIDAllInfo.tcCountryCode
no-error.
if not available tGLBankCountry then do:
find first tGLBankCountry where tGLBankCountry.Country_ID = tqCountryByIDAllInfo.tiCountry_ID no-error.
if not available tGLBankCountry
then do: /* avoid duplicate key issue */
create tGLBankCountry.
<M-38 run BufferCopy
(input vhBufferForCountry (ihFrom),
input buffer tGLBankCountry:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
end. /* if not available tGLBankCountry */
end. /* for first tqCountryByIDAllInfo*/
end. /* tqCountryAllInfo else do */
if tGLBankAddress.State_ID<>0
then do:
<Q-39 run StateByIDAllInfo (all) (Read) (NoCache)
(input tGLBankAddress.State_ID, (State_ID)
output dataset tqStateByIDAllInfo) in BState >
assign
vhBufferForState = dataset tqStateByIDAllInfo:get-buffer-handle(1).
for first tqStateByIDAllInfo:
find first tGLBankState where tGLBankState.State_ID = tqStateByIDAllInfo.tiState_ID no-error.
if not available tGLBAnkState
then do: /* avoid duplicate key issue */
create tGLBankState.
<M-40 run BufferCopy
(input vhBufferForState (ihFrom),
input buffer tGLBankState:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
end. /*for each tqStataByIDAllInfo */
end. /* if tBankAddress.State_ID<>0 */
end. /* for each tqAddressByIDAllInfo */
end. /* tqAddressAllInfo else do */
end. /* for each tqBusinessRelationByIDAllInfo */
end. /* tqBusinessRelationByIDAllInfo else do */
end. /*if tBankNumberOfGL.BankBusinessRelation_ID <> 0 */
end. /* for each tqBankNumberByIDAllInfo */
end. /* tqBankNumberByIDAllInfo else do */
end. /* tqBankPayFormatPrim */
end. /* for each tqGlAllInfo */
end. /* tqGLByIDAllInfo else do */
end. /*for each tPaySel */
<Q-49 run ContactByIDAllInfo
(Stop) in BBusinessRelation >
<Q-50 run BusinessRelationByIDAllInfo
(Stop) in BBusinessRelation >
<Q-51 run AddressByIDsAllInfo
(Stop) in BBusinessRelation >
<Q-52 run CountryByIDAllInfo
(Stop) in BCountry >
<Q-53 run StateByIDAllInfo
(Stop) in BState >
<Q-27 run BankNumberByParentAllInfo
(Stop) in BBankNumber >
<Q-11 run CurrencyByIDAllInfo
(Stop) in BCurrency >
<Q-10 run GLByIDsAllInfo
(Stop) in BGL >
<Q-70 run BankBranchByUnqIdx
(Stop) in BBankBranch>
/* ========================= */
/* Set default return status */
/* ========================= */
if oiReturnStatus = -98
then assign oiReturnstatus = 0.