project QadFinancials > class BCOACrossRef > method DefaultValuesTypeSeperate
Description
Completes the COA Cross Reference Detail records with defaults for type 'Seperate'. If the target domain has the same shared set as the source domain, then the target fields will be defaulted as well.
Parameters
ilRetrieveGL | input | logical | |
ilRetrieveDivision | input | logical | |
ilRetrieveCostCentre | input | logical | |
ilRetrieveProject | input | logical | |
tApiCOACrossRef | input | temp-table | Temp-table like COACrossRef. Input: The original temp-table filled by the user. |
tApiCOACrossRefDet | input-output | temp-table | Temp-table like COACrossRefDet. Input: The original temp-table filled by the user. Output: The completed temp-table for the missing defaults. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program6/bcoacrossref.p)
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
PROCESSBLOCK:
do:
/* =============================================== */
/* Check if only one tApiCOACrossRef record passed */
/* =============================================== */
find tApiCOACrossRef no-error.
if not available tApiCOACrossRef
then leave PROCESSBLOCK.
/* =============================================== */
/* Check if header record can be found in instance */
/* =============================================== */
find tCOACrossRef where
tCOACrossRef.tc_Rowid = tApiCOACrossRef.tc_Rowid
no-error.
if not available tCOACrossRef
then leave PROCESSBLOCK.
assign vlSameGLSS = false
vlSameDivisionSS = false
vlSameCostCentreSS = false
vlSameProjectSS = false.
if tApiCOACrossRef.tcTargetDomainCode <> ? and
tApiCOACrossRef.tcTargetDomainCode <> '':U
then do:
/* =================================== */
/* Check Shared Sets for Source Domain */
/* =================================== */
<M-3 run GetTargetSharedSets
(input vcDomainCode (icTargetDomainCode),
output viSourceGLSharedSetID (oiGLSharedSetID),
output viSourceDivisionSharedSetID (oiDivisionSharedSetID),
output viSourceCostCentreSharedSetID (oiCostCentreSharedSetID),
output viSourceProjectSharedSetID (oiProjectSharedSetID),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
/* =================================== */
/* Check Shared Sets for Target Domain */
/* =================================== */
<M-4 run GetTargetSharedSets
(input tApiCOACrossRef.tcTargetDomainCode (icTargetDomainCode),
output viTargetGLSharedSetID (oiGLSharedSetID),
output viTargetDivisionSharedSetID (oiDivisionSharedSetID),
output viTargetCostCentreSharedSetID (oiCostCentreSharedSetID),
output viTargetProjectSharedSetID (oiProjectSharedSetID),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
if viSourceGLSharedSetID = viTargetGLSharedSetID
then assign vlSameGLSS = true.
if viSourceDivisionSharedSetID = viTargetDivisionSharedSetID
then assign vlSameDivisionSS = true.
if viSourceCostCentreSharedSetID = viTargetCostCentreSharedSetID
then assign vlSameCostCentreSS = true.
if viSourceProjectSharedSetID = viTargetProjectSharedSetID
then assign vlSameProjectSS = true.
end. /* if tApiCOACrossRef.tcTargetDomainCode <> ? and */
/* ================================================ */
/* Retrieve all GL accounts for the current company */
/* ================================================ */
if ilRetrieveGL = true
then do:
<Q-2 run GLPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input '':U, (GLCode)
input 0, (GLId)
output dataset tqGLPrim) in BGL >
for each tqGLPrim:
/* ============================================================= */
/* Create missing records and fill missing targets when possible */
/* ============================================================= */
find tApiCOACrossRefDet where
tApiCOACrossRefDet.COACrossRefDetSrcGLFrom = tqGLPrim.tcGLCode
no-error.
if not available tApiCOACrossRefDet
then do:
/* ==================================================== */
/* Create records in the instance and copy to resultset */
/* ==================================================== */
<M-5 run AddDetailLine
(input 'COACrossRefDet':U (icTable),
input tCOACrossRef.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
assign tCOACrossRefDet.COACrossRefDetSrcGLFrom = tqGLPrim.tcGLCode.
create tApiCOACrossRefDet.
<M-6 run BufferCopy
(input buffer tCOACrossRefDet:handle (ihFrom),
input buffer tApiCOACrossRefDet:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
end. /* if available tApiCOACrossRefDet */
if vlSameGLSS and
(tApiCOACrossRefDet.tcTargetGLCode = '':U or
tApiCOACrossRefDet.tcTargetGLCode = ?)
then assign tApiCOACrossRefDet.tcTargetGLCode = tApiCOACrossRefDet.COACrossRefDetSrcGLFrom.
end. /* for each tqGLPrim: */
end. /* if ilRetrieveGL = true */
/* ====================================================== */
/* Retrieve all Division accounts for the current company */
/* ====================================================== */
if ilRetrieveDivision = true
then do:
<Q-10 run DivisionPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input 0, (DivisionID)
input '':U, (DivisionCode)
output dataset tqDivisionPrim) in BDivision >
for each tqDivisionPrim:
/* ============================================================= */
/* Create missing records and fill missing targets when possible */
/* ============================================================= */
find tApiCOACrossRefDet where
tApiCOACrossRefDet.COACrossRefDetSrcDivFrom = tqDivisionPrim.tcDivisionCode
no-error.
if not available tApiCOACrossRefDet
then do:
/* ==================================================== */
/* Create records in the instance and copy to resultset */
/* ==================================================== */
<M-8 run AddDetailLine
(input 'COACrossRefDet':U (icTable),
input tCOACrossRef.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
assign tCOACrossRefDet.COACrossRefDetSrcDivFrom = tqDivisionPrim.tcDivisionCode.
create tApiCOACrossRefDet.
<M-9 run BufferCopy
(input buffer tCOACrossRefDet:handle (ihFrom),
input buffer tApiCOACrossRefDet:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
end. /* if available tApiCOACrossRefDet */
if vlSameDivisionSS and
(tApiCOACrossRefDet.tcTargetDivisionCode = '':U or
tApiCOACrossRefDet.tcTargetDivisionCode = ?)
then assign tApiCOACrossRefDet.tcTargetDivisionCode = tApiCOACrossRefDet.COACrossRefDetSrcDivFrom.
end. /* for each tqDivisionPrim: */
end. /* if ilRetrieveDivision = true */
/* ========================================================= */
/* Retrieve all Cost Centre accounts for the current company */
/* ========================================================= */
if ilRetrieveCostCentre = true
then do:
<Q-17 run CostCentrePrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input 0, (CostCentreID)
input '':U, (CostCentreCode)
output dataset tqCostCentrePrim) in BCostCentre >
for each tqCostCentrePrim:
/* ============================================================= */
/* Create missing records and fill missing targets when possible */
/* ============================================================= */
find tApiCOACrossRefDet where
tApiCOACrossRefDet.COACrossRefDetSrcCCFrom = tqCostCentrePrim.tcCostCentreCode
no-error.
if not available tApiCOACrossRefDet
then do:
/* ==================================================== */
/* Create records in the instance and copy to resultset */
/* ==================================================== */
<M-12 run AddDetailLine
(input 'COACrossRefDet':U (icTable),
input tCOACrossRef.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
assign tCOACrossRefDet.COACrossRefDetSrcCCFrom = tqCostCentrePrim.tcCostCentreCode.
create tApiCOACrossRefDet.
<M-13 run BufferCopy
(input buffer tCOACrossRefDet:handle (ihFrom),
input buffer tApiCOACrossRefDet:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
end. /* if available tApiCOACrossRefDet */
if vlSameCostCentreSS and
(tApiCOACrossRefDet.tcTargetCostCentreCode = '':U or
tApiCOACrossRefDet.tcTargetCostCentreCode = ?)
then assign tApiCOACrossRefDet.tcTargetCostCentreCode = tApiCOACrossRefDet.COACrossRefDetSrcCCFrom.
end. /* for each tqCostCentrePrim: */
end. /* if ilRetrieveCostCentre = true */
/* ===================================================== */
/* Retrieve all Project accounts for the current company */
/* ===================================================== */
if ilRetrieveProject = true
then do:
<Q-18 run ProjectPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input 0, (ProjectID)
input '':U, (ProjectCode)
output dataset tqProjectPrim) in BProject >
for each tqProjectPrim:
/* ============================================================= */
/* Create missing records and fill missing targets when possible */
/* ============================================================= */
find tApiCOACrossRefDet where
tApiCOACrossRefDet.COACrossRefDetSrcProjFrom = tqProjectPrim.tcProjectCode
no-error.
if not available tApiCOACrossRefDet
then do:
/* ==================================================== */
/* Create records in the instance and copy to resultset */
/* ==================================================== */
<M-15 run AddDetailLine
(input 'COACrossRefDet':U (icTable),
input tCOACrossRef.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
assign tCOACrossRefDet.COACrossRefDetSrcProjFrom = tqProjectPrim.tcProjectCode.
create tApiCOACrossRefDet.
<M-16 run BufferCopy
(input buffer tCOACrossRefDet:handle (ihFrom),
input buffer tApiCOACrossRefDet:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
end. /* if available tApiCOACrossRefDet */
if vlSameProjectSS and
(tApiCOACrossRefDet.tcTargetProjectCode = '':U or
tApiCOACrossRefDet.tcTargetProjectCode = ?)
then assign tApiCOACrossRefDet.tcTargetProjectCode = tApiCOACrossRefDet.COACrossRefDetSrcProjFrom.
end. /* for each tqProjectPrim: */
end. /* if ilRetrieveProject = true */
end. /* PROCESSBLOCK */
assign oiReturnStatus = viLocalReturnStatus.