Parameters
| iiDebtorID | input | integer | |
| iiAddressTypeID | input | integer | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdcollection.p)
if oiReturnStatus = 0 then assign oiReturnStatus = -98.
<Q-23 run DebtorByIDAllInfo (all) (Read) (NoCache)
(input ?, (CompanyId)
input iiDebtorID, (DebtorID)
output dataset tqDebtorByIDAllInfo) in BDebtor >
find first tqDebtorByIDAllInfo no-error.
if not available tqDebtorByIDAllInfo
then do:
<M-2 run SetMessage
(input trim(#T-1'The specified customer $1 is not defined in the system.':100(49176)t-1#) (icMessage),
input string(iiDebtorID) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-5357':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign oiReturnStatus = -1.
return.
end.
assign vhBufferForProDataSet = dataset tqDebtorByIDAllInfo:get-buffer-handle(1).
find first tDCDebtor where
tDCDebtor.Debtor_ID = iiDebtorID no-error.
if not available tDCDebtor
then do:
create tDCDebtor.
<M-3 run BufferCopy
(input vhBufferForProDataSet (ihFrom),
input buffer tDCDebtor: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-24 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
(input tDCDebtor.BusinessRelation_ID, (BusinessRelation_ID)
output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >
find first tqBusinessRelationByIDAllInfo no-error.
if not available tqBusinessRelationByIDAllInfo
then do:
<M-25 run SetMessage
(input #T-27'The business relation $1 cannot be found.':100(49180)t-27# (icMessage),
input string(tDCDebtor.BusinessRelation_ID) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6689':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).
find first tDebtorBusRel where
tDebtorBusRel.BusinessRelation_ID = tDCDebtor.BusinessRelation_ID no-error.
if not available tDebtorBusRel and
tDCDebtor.BusinessRelation_ID <> 0 and
tDCDebtor.BusinessRelation_ID <> ?
then do:
create tDebtorBusRel.
<M-26 run BufferCopy
(input vhBufferForProDataSet (ihFrom),
input buffer tDebtorBusRel: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-40 run AddressByIDsAllInfo (all) (Read) (NoCache)
(input tDebtorBusRel.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-41 run SetMessage
(input #T-43'The address with the business relation $1 and of type $2 cannot be found.':100(49184)t-43# (icMessage),
input string(tDebtorBusRel.BusinessRelation_ID) + chr(2) + string(iiAddressTypeID) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6693':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).
find first tDebtorAddress where
tDebtorAddress.BusinessRelation_ID = tDebtorBusRel.BusinessRelation_ID
no-error.
if not available tDebtorAddress and
tDebtorBusRel.BusinessRelation_ID <> 0 and
tDebtorBusRel.BusinessRelation_ID <> ?
then do:
create tDebtorAddress.
<M-42 run BufferCopy
(input vhBufferForProDataSet (ihFrom),
input buffer tDebtorAddress:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper < 0
then do:
assign oiReturnStatus = viFcReturnSuper.
return.
end.
else do:
if viFcReturnSuper > 0
then do:
if oiReturnStatus = -98 or oiReturnStatus >= 0
then assign oiReturnStatus = viFcReturnSuper.
end.
end.
end. /* if not available tDebtorAddress */
end. /* if not available tDebtorbusrel */
/* get the country record and create one record for temp table tCompanyCountry */
find first tDebtorCountry where
tDebtorCountry.Country_ID = tDebtorAddress.Country_ID
no-error.
if not available tDebtorCountry and
tDebtorAddress.Country_ID <> 0 and
tDebtorAddress.Country_ID <> ?
then do:
<Q-31 run CountryByIDAllInfo (all) (Read) (NoCache)
(input tDebtorAddress.Country_ID, (Country_ID)
output dataset tqCountryByIDAllInfo) in BCountry >
find first tqCountryByIDAllInfo no-error.
if not available tqCountryByIDAllInfo
then do:
<M-32 run SetMessage
(input #T-38'The address with ID $1 does not have a specified value for country.':200(49162)t-38# (icMessage),
input string(tDebtorAddress.Address_ID) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6691':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 tDebtorCountry.
<M-33 run BufferCopy
(input vhBufferForProDataSet (ihFrom),
input buffer tDebtorCountry: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 not available tDebtorCountry*/
/* get the state record and create one record for temp table tCompanyState */
find first tDebtorState where
tDebtorState.State_ID = tDebtorAddress.State_ID
no-error.
if not available tDebtorState and
tDebtorAddress.State_ID <> 0 and
tDebtorAddress.State_ID<> ?
then do:
<Q-34 run StateByIDAllInfo (all) (Read) (NoCache)
(input tDebtorAddress.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 tDebtorState.
<M-47 run BufferCopy
(input vhBufferForProDataSet (ihFrom),
input buffer tDebtorState: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 */
end.
end.
if oiReturnStatus = -98 then assign oiReturnStatus = 0.