project QadFinancials > class BPosting > method GetSafStructureForCostCentre
Description
Get the SAF Structure associated with Cost Centre
Parameters
iiCompanyId | input | integer | |
iiGLId | input | integer | |
icGLCode | input | character | |
iiCostCentreId | input | integer | |
icCostCentreCode | input | character | |
oiSafStructureId | output | integer | |
ocSafStructureCode | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bposting.p)
/* normalize input paramters */
if iiCompanyId = ? or iiCompanyId = 0 then assign iiCompanyId = viCompanyId.
/* validate input paramters */
if (iiCostCentreId = ? or iiCostCentreId = 0) and
(icCostCentreCode = ? or icCostCentreCode = '':U)
then return.
<Q-6 run CostCentrePrim (all) (Read) (Cache)
(input iiCompanyId, (CompanyId)
input iiCostCentreId, (CostCentreID)
input icCostCentreCode, (CostCentreCode)
output dataset tqCostCentrePrim) in BCostCentre >
find first tqCostCentrePrim no-error.
if available tqCostCentrePrim
then do:
if tqCostCentrePrim.tlCostCentreIsStructFromGL = true
then do:
assign viGLId = iiGLId.
if viGLId = ? or viGLId = 0
then do:
if icGLCode = ? or icGLCode = '':U
then return.
<Q-5 run GLByCode (all) (Read) (Cache)
(input iiCompanyId, (CompanyId)
input icGLCode, (GLCode)
output dataset tqGLByCode) in BGL >
for first tqGLByCode:
viGLId = tqGLByCode.tiGL_ID.
end.
end. /* if viGLId = ? or viGLId = 0 */
if viGLId <> ? and viGLId <> 0
then do:
<Q-3 run GetSafStructureLinkForGL (all) (Read) (Cache)
(input viGLId, (GL_ID)
output dataset tqSafStructureLinkForGL) in BSafStructureLink >
for first tqSafStructureLinkForGL:
assign
oiSafStructureId = tqSafStructureLinkForGL.tiSafStructure_ID
ocSafStructureCode = tqSafStructureLinkForGL.tcSafStructureCode.
end.
end. /* if viGLId <> ? and viGLId <> 0 */
end. /* if tqCostCentrePrim.tlCostCentreIsStructFromGL = true */
else do:
<Q-4 run GetSafStructureLinkForCC (all) (Read) (Cache)
(input tqCostCentrePrim.tiCostCentre_ID, (CostCenter_ID)
input iiCompanyId, (CompanyId)
input tqCostCentrePrim.tcCostCentreCode, (CostCentreCode)
input ?, (SafStructureCode)
output dataset tqGetSafStructureLinkForCC) in BSafStructureLink>
for first tqGetSafStructureLinkForCC:
assign oiSafStructureId = tqGetSafStructureLinkForCC.tiSafStructure_ID
ocSafStructureCode = tqGetSafStructureLinkForCC.tcSafStructureCode.
end.
end.
end. /* if available tqCostCentreByCodeID */