Parameters
| iiCollectionID | input | integer | |
| ohDset | output | handle | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdcollection.p)
/*
The procedure is to build a ProDataSet based on the provided collection ID.
*/
/*
Steps:
1. Empty every temp table that will be used by the prodataset.
2. Add buffer for each temp table to the prodataset
3. Add relationship of these temp tables to the ProdataSet
4.Fill data for the data set by invoking FillProDataSet.
*/
assign
oiReturnStatus = -98
vlARBankPaymentInitial = false.
<M-6 run ClearProDataSet (output viFcReturnSuper (oiReturnStatus)) in BDCollection>
<Q-3 run DCollectionByIDAllInfo (all) (Read) (NoCache)
(input ?, (CompanyId)
input iiCollectionID, (DCollection_ID)
output dataset tqDCollectionByIDAllInfo) in BDCollection >
find first tqDCollectionByIDAllInfo no-error.
if not available tqDCollectionByIDAllInfo
then do:
<M-2 run SetMessage
(input #T-1'No payment collection is defined with the ID: $1.':100(49046)t-1# (icMessage),
input iiCollectionID (icArguments),
input 'tDCollection.DCollection_ID':U (icFieldName),
input tDCollection.DCollection_ID (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-5239':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign
oiReturnStatus = -1.
return.
end.
vhBufferForProDataSet = dataset tqDCollectionByIDAllInfo:get-buffer-handle(1).
create tDCollectionAllInfo.
<M-4 run BufferCopy (input vhBufferForProDataSet (ihFrom),
input buffer tDCollectionAllInfo:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper < 0
then do:
assign
oiReturnStatus = viFcReturnSuper.
return.
end.
else if viFcReturnSuper > 0
then do:
if oiReturnStatus = -98 or oiReturnStatus >=0 then
assign oiReturnStatus = viFcReturnSuper.
end.
/* Initiate the TpAddress TpSite which will be used in EDI mapping */
for each tDCollectionAllInfo:
assign
tDCollectionAllInfo.tcTpAddress = tDCollectionAllInfo.DCollectionBankFileFormat
tDCollectionAllInfo.tcTpSite = tDCollectionAllInfo.DCollectionBankFileFormat.
end.
<M-5 run FillProDataSet (input iiCollectionID (iiDCollectionID),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper < 0
then do:
assign
oiReturnStatus = viFcReturnSuper.
return.
end.
else if viFcReturnSuper > 0
then do:
if oiReturnStatus = -98 or oiReturnStatus >=0 then
assign oiReturnStatus = viFcReturnSuper.
end.
/*
* Check to see if it is an intial collection/payment selection
* If it is then we want to use the ARBankPaymentInitial application defintition in EDI - as it handles stages
*/
for first tDCollectionAllInfo
where tDCollectionAllInfo.DCollection_ID = iiCollectionID,
first tDPaySel where tDPaySel.DPaySel_ID = tDCollectionAllInfo.DPaySel_ID:
if tDPaySel.DPaySelStatus = {&DOCUMENTSTATUS-INIT}
then assign vlARBankPaymentInitial = true.
end.
create dataset vhDCollectionDataSet in widget-pool "non-persistent".
vhDCollectionDataSet:name = 'ARBankPayment':U.
create buffer vhCompanyAddress for table temp-table tCompanyAddress:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCompBusRel for table temp-table tCompBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCompanyCountry for table temp-table tCompanyCountry:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCompanyState for table temp-table tCompanyState:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorState for table temp-table tDebtorState:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorCountry for table temp-table tDebtorCountry:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorBusRel for table temp-table tDebtorBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDCDebtor for table temp-table tDCDebtor:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorAddress for table temp-table tDebtorAddress:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDCollCompProperty for table temp-table tDCollCompProperty:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDCollectionCompany for table temp-table tDCollectionCompany:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDDocument for table temp-table tDDocument:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorGLBankNumber for table temp-table tDebtorGLBankNumber:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDInvoice for table temp-table tDInvoice:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGL for table temp-table tGL:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankNumber for table temp-table tGLBankNumber:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLCurrency for table temp-table tGLCurrency:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentCurrency for table temp-table tPaymentCurrency:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDCollectionAllInfo for table temp-table tDCollectionAllInfo:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankNumberBusRel for table temp-table tGLBankNumberBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankNumberAddress for table temp-table tGLBankNumberAddress:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankNumberContact for table temp-table tGLBankNumberContact:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankNumberCountry for table temp-table tGLBankNumberCountry:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankNumberState for table temp-table tGLBankNumberState:default-buffer-handle in widget-pool "non-persistent".
create buffer vhHeaderAttribute for table temp-table tHeaderAttribute:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentAttribute for table temp-table tPaymentAttribute:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDInvoiceAttribute for table temp-table tDInvoiceAttribute:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorBankBusRel for table temp-table tDebtorBankBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorBankAddress for table temp-table tDebtorBankAddress:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorBankCountry for table temp-table tDebtorBankCountry:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorBankState for table temp-table tDebtorBankState:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDebtorBankContact for table temp-table tDebtorBankContact:default-buffer-handle in widget-pool "non-persistent".
create buffer vhDPaySel for table temp-table tDPaySel:default-buffer-handle in widget-pool "non-persistent".
vhDCollectionDataSet:set-buffers(vhCompanyAddress, vhCompBusRel,
vhCompanyCountry, vhCompanyState, vhDebtorCountry,
vhDebtorState, vhDebtorBusRel, vhDCDebtor,
vhDebtorAddress, vhDCollCompProperty, vhDCollectionCompany,
vhDDocument, vhDebtorGLBankNumber, vhDInvoice,
vhGL, vhGLBankNumber).
vhDCollectionDataSet:add-buffer(vhGLCurrency).
vhDCollectionDataSet:add-buffer(vhPaymentCurrency).
vhDCollectionDataSet:add-buffer(vhDCollectionAllInfo).
vhDCollectionDataSet:add-buffer(vhGLBankNumberBusRel).
vhDCollectionDataSet:add-buffer(vhGLBankNumberAddress).
vhDCollectionDataSet:add-buffer(vhGLBankNumberContact).
vhDCollectionDataSet:add-buffer(vhGLBankNumberCountry).
vhDCollectionDataSet:add-buffer(vhGLBankNumberState).
vhDCollectionDataSet:add-buffer(vhHeaderAttribute).
vhDCollectionDataSet:add-buffer(vhPaymentAttribute).
vhDCollectionDataSet:add-buffer(vhDInvoiceAttribute).
vhDCollectionDataSet:add-buffer(vhDebtorBankBusRel).
vhDCollectionDataSet:add-buffer(vhDebtorBankAddress).
vhDCollectionDataSet:add-buffer(vhDebtorBankCountry).
vhDCollectionDataSet:add-buffer(vhDebtorBankState).
vhDCollectionDataSet:add-buffer(vhDebtorBankContact).
vhDCollectionDataSet:add-buffer(vhDPaySel).
vhDCollectionDataSet:add-relation(vhDCollectionAllInfo,vhDCollectionCompany,'Company_ID,Company_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDCollectionAllInfo,vhGL,'GL_ID,GL_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDCollectionAllInfo,vhDDocument,'DCollection_ID,DCollection_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDCollectionAllInfo,vhDPaySel,'DPaySel_ID,DPaySel_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDDocument,vhDCDebtor,'Debtor_ID,Debtor_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDDocument,vhPaymentCurrency,'Currency_ID,Currency_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDDocument,vhDInvoice,'DDocument_ID,tiDDocumentID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDCDebtor, vhDebtorBusRel,'BusinessRelation_ID,BusinessRelation_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDDocument, vhDebtorGLBankNumber,'BankNumber_ID,BankNumber_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDebtorGLBankNumber,vhDebtorBankBusRel,'BankBusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDebtorBankBusRel,vhDebtorBankAddress,'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDebtorBankBusRel,vhDebtorBankContact,'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDebtorBankAddress,vhDebtorBankCountry,'Country_ID,Country_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDebtorBankAddress,vhDebtorBankState,'State_ID,State_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDebtorBusRel, vhDebtorAddress,'BusinessRelation_ID,BusinessRelation_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDebtorAddress, vhDebtorCountry,'Country_ID,Country_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDebtorAddress, vhDebtorState,'State_ID,State_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDCollectionCompany,vhDCollCompProperty,'Company_ID,Company_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhDCollCompProperty,vhCompBusRel,'BusinessRelation_ID,BusinessRelation_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhCompBusRel,vhCompanyAddress,'BusinessRelation_ID,BusinessRelation_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhCompanyAddress,vhCompanyCountry,'Country_ID,Country_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhCompanyAddress,vhCompanyState,'State_ID,State_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhGL,vhGLCurrency,'Currency_ID,Currency_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhGL,vhGLBankNumber,'GL_ID,ParentObject_ID':U, yes, yes).
vhDCollectionDataSet:add-relation(vhGLBanknumber,vhGLBankNumberBusRel,'BankBusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhGLBankNumberBusRel,vhGLBankNumberContact,'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhGLBankNumberBusRel,vhGLBankNumberAddress,'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhGLBankNumberAddress,vhGLBankNumberCountry,'Country_ID,Country_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhGLBankNumberAddress,vhGLBankNumberState,'State_ID,State_ID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDCollectionAllInfo,vhHeaderAttribute,'DCollection_ID,tiDCollectionID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDDocument,vhPaymentAttribute,'DDocument_ID,tiDDocumentID':U,yes,yes).
vhDCollectionDataSet:add-relation(vhDInvoice,vhDInvoiceAttribute,'DInvoice_ID,tiDInvoiceID,tiDDocumentID,tiDDocumentID':U,yes,yes).
/* only add the stage table to the dataset if we are using Aplication defintion ARBankPaymentInitial*/
if vlARBankPaymentInitial
then do:
assign vhDCollectionDataSet:name = "ARBankPaymentInitial".
create buffer vhDInvoiceStage for table temp-table tDInvoiceStage:default-buffer-handle in widget-pool "non-persistent".
vhDCollectionDataSet:add-buffer(vhDInvoiceStage).
vhDCollectionDataSet:add-relation(vhDInvoice,vhDInvoiceStage,'DInvoice_ID,DInvoice_ID':U,yes,yes).
end.
assign ohDSet = vhDCollectionDataSet.
/*
vcTempFile = replace(string(today),"/","")
+ "-" + string(etime)
+ "-" + string(random(1,1000),"999")
+ "." + "ARBankPayment.xml":U.
vhDCollectiondataSet:WRITE-XML("FILE",
vcTempFile,
YES,
?,
?,
NO,
NO,
NO).
*/
if oiReturnStatus = -98 then
assign
oiReturnStatus = 0.