project QadFinancials > class BDCollection > method FillProDataSetCompany


Parameters


iiCompanyIDinputinteger
iiAddressTypeIDinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDCollection.FillProDataSet


program code (program1/bdcollection.p)

/* 
With a company ID, we can get the following records in sequence.
1. Company.
2. CompanyProperty.
3. BusinessRelation.
4. Company Address.
5. Company Country.
6. Company State.
*/

/* get the company record and create one record for temp table tDCollectionCompany */

<Q-38 run CompanyByIDAllInfo (all) (Read) (NoCache)
   (input iiCompanyID, (CompanyId)
    output dataset tqCompanyByIDAllInfo) in BCompany >

find first tqCompanyByIDAllInfo no-error.
if not available tqCompanyByIDAllInfo 
then do:
    <M-2 run SetMessage
       (input  #T-1'Entity with ID:$1 cannot be found.':100(49148)t-1# (icMessage), 
        input  iiCompanyID (icArguments), 
        input  'Company_ID':U (icFieldName), 
        input  iiCompanyID (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5317':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

assign vhBufferForProDataSet =  dataset tqCompanyByIDAllInfo:get-buffer-handle(1).
create tDCollectionCompany.
<M-3 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tDCollectionCompany: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 companyproperty record and create one record for temp table tDCollCompProperty */
<Q-4 run CompanyPropertyByIDAllInfo (all) (Read) (NoCache)
   (input iiCompanyID, (CompanyId)
    output dataset tqCompanyPropertyByIDAllInfo) in BCompanyProperty >
find first tqCompanyPropertyByIDAllInfo no-error.
if not available tqCompanyPropertyByIDAllInfo 
then do:
    <M-11 run SetMessage
       (input  trim(#T-12'The specified code $1 is not defined as an entity. ':100(49160)t-12#) (icMessage), 
        input  iiCompanyID (icArguments), 
        input  'Company_ID':U (icFieldName), 
        input  iiCompanyID (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5321':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

assign vhBufferForProDataSet =  dataset tqCompanyPropertyByIDAllInfo:get-buffer-handle(1).

create tDCollCompProperty.
<M-7 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tDCollCompProperty: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 businessRelation record and create one record for temp table tCompBusRel */
<Q-13 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
   (input tDCollCompProperty.BusinessRelation_ID, (BusinessRelation_ID)
    output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >
find first tqBusinessRelationByIDAllInfo no-error.
if not available tqBusinessRelationByIDAllInfo 
then do:
    <M-14 run SetMessage
       (input  trim(#T-16'The specified business relation $1 is not defined in the system.':100(49158)t-16#) (icMessage), 
        input  tDCollCompProperty.BusinessRelation_ID (icArguments), 
        input  'tDCollCompProperty.BusinessRelation_ID':U (icFieldName), 
        input  tDCollCompProperty.BusinessRelation_ID (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5322':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

assign vhBufferForProDataSet =  dataset tqBusinessRelationByIDAllInfo:get-buffer-handle(1).
create tCompBusRel.
<M-17 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tCompBusRel: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 address record and create one record for temp table tCompanyAddress */
<Q-18 run AddressByIDsAllInfo (all) (Read) (NoCache)
   (input tCompBusRel.BusinessRelation_ID, (BusinessRelation_ID)
    input iiAddressTypeID, (AddressType_ID)
    output dataset tqAddressByIDsAllInfo) in BBusinessRelation >
find first tqAddressByIDsAllInfo no-error.
if not available tqAddressByIDsAllInfo 
then do:
    <M-19 run SetMessage
       (input  trim(#T-21'The business relation with ID $1 does not have an address of address type: $2.':200(49161)t-21#) (icMessage), 
        input  string(tDCollCompProperty.BusinessRelation_ID) + chr(2) + string(iiAddressTypeID) (icArguments), 
        input  'tCompBusRel.BusinessRelation_ID':U (icFieldName), 
        input  tCompBusRel.BusinessRelation_ID (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5323':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDCollection>
    assign oiReturnStatus = -1.
    return.
end.

assign vhBufferForProDataSet =  dataset tqAddressByIDsAllInfo:get-buffer-handle(1).
create tCompanyAddress.
<M-20 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tCompanyAddress: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-36 run CountryByIDAllInfo (all) (Read) (NoCache)
   (input tCompanyAddress.Country_ID, (Country_ID)
    output dataset tqCountryByIDAllInfo) in BCountry >
find first tqCountryByIDAllInfo no-error.
if not available tqCountryByIDAllInfo 
then do:
    <M-23 run SetMessage
       (input  trim(#T-25'The address with ID $1 does not have a specified value for country.':200(49162)t-25#) (icMessage), 
        input  string(tCompanyAddress.Address_ID) (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-5324':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 tCompanyCountry.
<M-24 run BufferCopy
   (input  vhBufferForProDataSet (ihFrom), 
    input  buffer tCompanyCountry: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-79 run StateByIDAllInfo (all) (Read) (NoCache)
   (input tCompanyAddress.State_ID, (State_ID)
    output dataset tqStateByIDAllInfo) in BState >
find first tqStateByIDAllInfo no-error.
if available tqStateByIDAllInfo 
then do:

    assign vhBufferForProDataSet =  dataset tqStateByIDAllInfo:get-buffer-handle(1).
    create tCompanyState.

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

end. /* if available */