project QadFinancials > class BDCollection > method FillProDataSetGL


Parameters


iiGL_IDinputinteger
iiDCollectionIdinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDCollection.FillProDataSet


program code (program1/bdcollection.p)

<Q-2 run GLByIDsAllInfo (all) (Read) (NoCache)
   (input ?, (CompanyId)
    input iiGL_ID, (GL_ID)
    output dataset tqGLByIDsAllInfo) in BGL >

find first tqGLByIDsAllInfo no-error.
if not available tqGLByIDsAllInfo 
then do:
    <M-3 run SetMessage
       (input  #T-1'An account $1 is not defined in the system.':100(49171)t-1# (icMessage), 
        input  string(iigL_ID) (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5349':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.
assign vhBufferForProDataSet = dataset tqGLByIDsAllInfo:get-buffer-handle(1).

create tGL.
<M-4 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tGL:handle (ihTo), 
    output oiReturnStatus (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.

<Q-5 run CurrencyByIDAllInfo (all) (Read) (NoCache)
   (input tGL.Currency_ID, (Currency_ID)
    output dataset tqCurrencyByIDAllInfo) in BCurrency >
find first tqCurrencyByIDAllInfo no-error.
if not available tqCurrencyByIDAllInfo 
then do:
    <M-6 run SetMessage
       (input  #T-7'An account $1 is not defined in the system.':100(49171)t-7# (icMessage), 
        input  string(tGL.Currency_ID) (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5353':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.
assign vhBufferForProDataSet = dataset tqCurrencyByIDAllInfo:get-buffer-handle(1).

create tGLCurrency.
<M-8 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tGLCurrency: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.

for each tDCollection:
  
      <Q-71 run DCollectionByDDocument (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input iiDCollectionId, (DCollectionId)
           output dataset tqDCollectionByDDocument) in BDCollection>    
      find first tqDCollectionByDDocument no-error.
      if available tqDCollectionByDDocument    
      then do:
            create tGLBankNumber.
            vhBufferForProDataSet = dataset tqDCollectionByDDocument:get-buffer-handle(1).
            <M-63 run BufferCopy
               (input  vhBufferForProDataSet (ihFrom), 
                input  buffer tGLBankNumber: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.
    
          <Q-42 run BankAccFormatPrim (all) (Read) (NoCache)
             (input tGLBankNumber.BankAccFormat_ID, (BankAcctFormatId)
              input ?, (BankAcctFormatCode)
              output dataset tqBankAccFormatPrim) in BBankAccountFormat>
          find first tqBankAccFormatPrim no-error.
          if available tqBankAccFormatPrim 
          then tGLBankNumber.tcBankAccFormatCode = tqBankAccFormatPrim.tcBankAccFormatCode.  
      end. /*if available tqDCollectionByDDocument */
   
end. /*for each tDCollection*/

<Q-9 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
   (input tGLBankNumber.BankBusinessRelation_ID, (BusinessRelation_ID)
    output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >

find first tqBusinessRelationByIDAllInfo no-error.
if not available tqBusinessRelationByIDAllInfo 
then do:
    <M-10 run SetMessage
       (input  #T-21'The business relation $1 cannot be found.':100(49180)t-21# (icMessage), 
        input  string(tDCDebtor.BusinessRelation_ID) (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5757':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

vhBufferForProDataSet = dataset tqBusinessRelationByIDAllInfo:get-buffer-handle(1).
create tGLBankNumberBusRel.
<M-11 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tGLBankNumberBusRel: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.

<Q-31 run ContactByIDAllInfo (all) (Read) (NoCache)
   (input tGLBankNumberBusRel.BusinessRelation_ID, (BusinessRelation_ID)
    output dataset tqContactByIDAllInfo) in BBusinessRelation >
vhBufferForProDataSet = dataset tqContactByIDAllInfo:get-buffer-handle(1).
create tGLBankNumberContact.
<M-32 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tGLBankNumberContact: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.

<Q-28 run AddressTypeByCode (all) (Read) (NoCache)
   (input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
    output dataset tqAddressTypeByCode) in BAddressType >

find first tqAddressTypeByCode no-error.
if not available tqAddressTypeByCode 
then do:
    <M-29 run SetMessage
       (input  #T-30'The Head Office address type is not defined in the system.':100(49190)t-30# (icMessage), 
        input  '' (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5761':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

<Q-12 run AddressByIDsAllInfo (all) (Read) (NoCache)
   (input tGLBankNumberBusRel.BusinessRelation_ID, (BusinessRelation_ID)
    input tqAddressTypeByCode.tiAddressType_ID, (AddressType_ID)
    output dataset tqAddressByIDsAllInfo) in BBusinessRelation >
find first tqAddressByIDsAllInfo no-error.
if not available tqAddressByIDsAllInfo 
then do:
    <M-13 run SetMessage
       (input  #T-22'The address with the business relation $1 and of type $2 cannot be found.':100(49184)t-22# (icMessage), 
        input  string(tGLBankNumberBusRel.BusinessRelation_ID) + chr(2) + string(tqAddressTypeByCode.tiAddressType_ID) (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5758':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

vhBufferForProDataSet = dataset tqAddressByIDsAllInfo:get-buffer-handle(1).
create tGLBankNumberAddress.
<M-14 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tGLBankNumberAddress: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.

/* get the country record and create one record for temp table tCompanyCountry */
<Q-15 run CountryByIDAllInfo (all) (Read) (NoCache)
   (input tGLBankNumberAddress.Country_ID, (Country_ID)
    output dataset tqCountryByIDAllInfo) in BCountry >
find first tqCountryByIDAllInfo no-error.
if not available tqCountryByIDAllInfo 
then do:
    <M-16 run SetMessage
       (input  #T-23'The address with ID $1 does not have a specified value for country.':200(49162)t-23# (icMessage), 
        input  string(tGLBankNumberAddress.Address_ID) (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5759':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

assign vhBufferForProDataSet =  dataset tqCountryByIDAllInfo:get-buffer-handle(1).
create tGLBankNumberCountry.
<M-17 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tGLBankNumberCountry: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.

/* get the state record and create one record for temp table tCompanyState */
<Q-18 run StateByIDAllInfo (all) (Read) (NoCache)
   (input tGLBankNumberAddress.State_ID, (State_ID)
    output dataset tqStateByIDAllInfo) in BState >

assign vhBufferForProDataSet =  dataset tqStateByIDAllInfo:get-buffer-handle(1).
create tGLBankNumberState.
<M-20 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tGLBankNumberState: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.