project QadFinancials > class BPosting > method GetSafStructureForCostCentre

Description

Get the SAF Structure associated with Cost Centre


Parameters


iiCompanyIdinputinteger
iiGLIdinputinteger
icGLCodeinputcharacter
iiCostCentreIdinputinteger
icCostCentreCodeinputcharacter
oiSafStructureIdoutputinteger
ocSafStructureCodeoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.AddDefaultSaf
method BPosting.ApiGetSafStructuresForPosting
method BJournalEntry.PostingLineGLUpdate
method BJournalEntry.UpdateManualPostingCostcentre


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 */