project QadFinancials > class BPaymentSelection > method BuildProDataSet


Parameters


iiPaySel_IDinputinteger
ohDSetoutputhandle
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.GenerateASCII


program code (program3/bpaymentselection.p)

/* ========================= */
/* step1. Clear all the records of the temp tables of the Prodataset.
   step3. Invoke the FillProdataSet method to prepare the data of temp tables.
   step3. Create a dynamic prodataset and add the buffer handle of the temp tables to the prodataset.
   step4. Add the Relationship of the temp tables in the Prodataset */
/* ========================= */

if oiReturnStatus = 0 
then assign oiReturnStatus = -98.

if not can-find (first tPaySel where tPaySel.PaySel_ID = iiPaySel_ID) then do:
    <M-6 run DataLoad
       (input  '':U (icRowids), 
        input  string(iiPaySel_ID) (icPkeys), 
        input  '':U (icObjectIds), 
        input  '':U (icFreeform), 
        input  false (ilKeepPrevious), 
        output oiReturnStatus (oiReturnStatus)) in BPaymentSelection>
end.
    
/* clear the temp-tables and prodataset */               
<M-8 run ClearProdatasetTables
   (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>

if valid-handle(vhPaySelProDataSet)
then do:
    vhPaySelProDataSet:clear().
end.

/* invoke the FillProDataSet to prepare the data of ProdataSet */
<M-7 run FillProDataSet (input  iiPaySel_ID (iiPaySel_ID), 
                     output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
/* catch error */
if viFcReturnSuper <> 0 
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return. 
/* Create the ProDataSet */

create dataset vhPaySelProDataSet in widget-pool "non-persistent".


vhPaySelProDataSet:name = <M-68 GetPaySelDataProName
                             (input  iiPaySel_ID (iiPaySelID), 
                              output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>.
/* catch error */
if viFcReturnSuper <> 0 
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.                               

create buffer vhPaymentPaySel for table temp-table tPaymentPaySel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPayment       for table temp-table tPayment:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaySelCompany for table temp-table tPaySelCompany:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaySelCCollection for table temp-table tPaySelCCollection:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPropertyOfCompany for table temp-table tPropertyOfCompany:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCompanyBusRel for table temp-table tCompanyBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhAddressOfCompany for table temp-table tAddressOfCompany:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentCInvoice for table temp-table tPaymentCInvoice:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCountryOfCompany for table temp-table tCountryOfCompany:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentBankNumber for table temp-table tPaymentBankNumber:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCurrencyOfPayment for table temp-table tCurrencyOfPayment:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentCreditor for table temp-table tPaymentCreditor:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCreditorBusRel for table temp-table tCreditorBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhAddressOfCreditor for table temp-table tAddressOfCreditor:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCountryOfCreditor for table temp-table tCountryOfCreditor:default-buffer-handle in widget-pool "non-persistent".
create buffer vhStateOfCompany for table temp-table tStateOfCompany:default-buffer-handle in widget-pool "non-persistent".
create buffer vhStateOfCreditor for table temp-table tStateOfCreditor:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaySelGL for table temp-table tPaySelGL:default-buffer-handle in widget-pool "non-persistent".
create buffer vhCurrencyOfGL for table temp-table tCurrencyOfGL:default-buffer-handle in widget-pool "non-persistent".
create buffer vhBankNumberOfGL for table temp-table tBankNumberOfGL:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentBankBusRel for table temp-table tPaymentBankBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentBankAddress for table temp-table tPaymentBankAddress:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentBankCountry for table temp-table tPaymentBankCountry:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentBankState for table temp-table tPaymentBankState:default-buffer-handle in widget-pool "non-persistent".
create buffer vhPaymentBankContact for table temp-table tPaymentBankContact:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankBusRel for table temp-table tGLBankBusRel:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankAddress for table temp-table tGLBankAddress:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankCountry for table temp-table tGLBankCountry:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankState for table temp-table tGLBankState:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankContact for table temp-table tGLBankContact:default-buffer-handle in widget-pool "non-persistent".
create buffer vhGLBankCurrency for table temp-table tGLBankCurrency:default-buffer-handle in widget-pool "non-persistent".
create buffer vhAPHeaderAttribute for table temp-table tAPHeaderAttribute:default-buffer-handle in widget-pool "non-persistent".
create buffer vhAPPaymentAttribute for table temp-table tAPPaymentAttribute:default-buffer-handle in widget-pool "non-persistent".
create buffer vhAPCInvoiceAttribute for table temp-table tAPCInvoiceAttribute:default-buffer-handle in widget-pool "non-persistent".


/* Set buffers of the ProDataSet */

vhPaySelProDataSet:set-buffers(vhPaymentPaySel,vhPayment,vhPaySelCompany,vhPaySelCCollection,vhPropertyOfCompany,vhCompanyBusRel,
                               vhAddressOfCompany,vhPaymentCInvoice,vhCountryOfCompany,vhPaymentBankNumber,vhCurrencyOfPayment, vhPaymentCreditor, 
                               vhCreditorBusRel,vhAddressOfCreditor,vhCountryOfCreditor,vhStateOfCompany,vhStateOfCreditor,vhPaySelGL).

vhPaySelProDataSet:add-buffer(vhCurrencyOfGL).
vhPaySelProDataSet:add-buffer(vhBankNumberOfGL).
vhPaySelProDataSet:add-buffer(vhPaymentBankBusRel).
vhPaySelProDataSet:add-buffer(vhPaymentBankAddress).
vhPaySelProDataSet:add-buffer(vhPaymentBankCountry).
vhPaySelProDataSet:add-buffer(vhPaymentBankState).
vhPaySelProDataSet:add-buffer(vhPaymentBankContact).
vhPaySelProDataSet:add-buffer(vhGLBankBusRel).
vhPaySelProDataSet:add-buffer(vhGLBankAddress).
vhPaySelProDataSet:add-buffer(vhGLBankCountry).
vhPaySelProDataSet:add-buffer(vhGLBankState).
vhPaySelProDataSet:add-buffer(vhGLBankContact).
vhPaySelProDataSet:add-buffer(vhGLBankCurrency).
vhPaySelProDataset:add-buffer(vhAPHeaderAttribute).
vhPaySelProDataSet:add-buffer(vhAPPaymentAttribute).
vhPaySelProDataSet:add-buffer(vhAPCInvoiceAttribute).

/*Add Relations of the ProDataSet */

vhPaySelProDataSet:add-relation(vhPaymentPaySel,vhPayment,
                               'PaySel_ID,PaySel_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentPaySel,vhPaySelCCollection,
                               'tiPaySelCCollection_ID,CCollection_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentPaySel,vhPaySelCompany,
                               'Company_ID,Company_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaySelCompany,vhPropertyOfCompany,
                               'Company_ID,Company_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPropertyOfCompany,vhCompanyBusRel,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhCompanyBusRel,vhAddressOfCompany,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhAddressOfCompany,vhCountryOfCompany,
                               'Country_ID,Country_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhAddressOfCompany,vhStateOfCompany,
                               'State_ID,State_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPayment, vhPaymentBankNumber,
                               'BankNumber_ID,BankNumber_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentBankNumber:handle,vhPaymentBankBusRel:handle,
                               'BankBusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentBankBusRel:handle,vhPaymentBankAddress:handle,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentBankBusRel:handle,vhPaymentBankContact:handle,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentBankAddress:handle,vhPaymentBankCountry:handle,
                               'Country_ID,Country_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentBankAddress:handle,vhPaymentBankState:handle,
                               'State_ID,State_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPayment:handle,vhPaymentCreditor:handle,
                               'Creditor_ID,Creditor_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentCreditor:handle,vhCreditorBusRel:handle,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhCreditorBusRel:handle,vhAddressOfCreditor:handle,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhAddressOfCreditor:handle,vhCountryOfCreditor:handle,
                               'Country_ID,Country_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhAddressOfCreditor:handle,vhStateOfCreditor:handle,
                               'State_ID,State_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPayment:handle,vhCurrencyOfPayment:handle,
                               'Currency_ID,Currency_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPayment:handle,vhPaymentCInvoice:handle,
                               'CDocument_ID,tiCDocument_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentPaySel:handle,vhPaySelGL:handle,
                               'GL_ID,GL_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaySelGL:handle,vhCurrencyOfGL:handle,
                               'Currency_ID,Currency_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaySelGL:handle,vhBankNumberOfGL:handle,
                               'GL_ID,ParentObject_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhGLBankBusRel:handle,vhGLBankAddress:handle,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhGLBankAddress:handle,vhGLBankCountry:handle,
                               'Country_ID,Country_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhGLBankAddress:handle,vhGLBankState:handle,
                               'State_ID,State_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhGLBankBusRel:handle,vhGLBankContact:handle,
                               'BusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhBankNumberOfGL:handle,vhGLBankBusRel:handle,
                               'BankBusinessRelation_ID,BusinessRelation_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhBankNumberofGL:handle,vhGLBankCurrency:handle,
                                'Currency_ID,Currency_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentPaySel:handle,vhAPHeaderAttribute:handle,
                                'PaySel_ID,tiPaySel_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPayment:handle,vhAPPaymentAttribute:handle,
                               'CDocument_ID,tiCDocument_ID':U,yes,yes).
vhPaySelProDataSet:add-relation(vhPaymentCInvoice:handle,vhAPCInvoiceAttribute:handle,
                                'CInvoice_iD,tiCInvoiceId,tiCDocument_ID,tiCDocument_ID':U,yes,yes).

/* only add the stage table to the dataset if we are using Aplication defintion ARBankPaymentInitial*/            
if vhPaySelProDataSet:name = {&APBANKPAYMENTSTAGE}
then do:        
    create buffer vhCInvoiceStage for table temp-table tPaymentCInvoiceStage:default-buffer-handle in widget-pool "non-persistent".
    vhPaySelProDataSet:add-buffer(vhCInvoiceStage).
    vhPaySelProDataSet:add-relation(vhPaymentCInvoice,vhCInvoiceStage,'CInvoice_ID,CInvoice_ID':U,yes,yes).    
end.


assign 
    ohDSet = vhPaySelProDataSet. 
 
/* ========================= */
/* Set default return status */
/* ========================= */
if oiReturnStatus = -98 
then assign oiReturnstatus = 0.