project QadFinancials > class BPosting > method GetSafStructureForProject

Description

Returns the SAF structure ID and code for the specified project.


Parameters


iiCompanyIdinputinteger
iiGLIdinputinteger
icGLCodeinputcharacter
iiProjectIdinputinteger
icProjectCodeinputcharacter
oiSafStructureIdoutputinteger
ocSafStructureCodeoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


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


program code (program1/bposting.p)

/* Normalize input parameters */
if iiCompanyId = ? or iiCompanyId = 0 then assign iiCompanyId = viCompanyId.
    
/* Validate input parameters */
if (iiProjectId = ? or iiProjectId = 0) and
   (icProjectCode = ? or icProjectCode = '':U) then
    return.

<Q-1 run ProjectPrim (all) (Read) (Cache)
   (input iiCompanyId, (CompanyId)
    input iiProjectId, (ProjectID)
    input icProjectCode, (ProjectCode)
    output dataset tqProjectPrim) in BProject >

find first tqProjectPrim no-error.

if available tqProjectPrim 
then do:

    if tqProjectPrim.tlProjectIsStructFromGL = true 
    then do:

        assign viGLId = iiGLId.

        if viGLId = ? or viGLId = 0 
        then do:

            if icGLCode = ? or icGLCode = '':U 
            then return.

            <Q-2 run GLPrim (all) (Read) (Cache)
               (input iiCompanyId, (CompanyId)
                input icGLCode, (GLCode)
                input ?, (GLId)
                output dataset tqGLPrim) in BGL >

            for first tqGLPrim:
                assign
                    viGLId = tqGLPrim.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.  /* tqProjectPrim.tlProjectIsStructFromGL = true */

    else do:
        <Q-4 run GetSafStructureLinkForProject (all) (Read) (Cache)
           (input tqProjectPrim.tiProject_ID, (Project_ID)
            input tqProjectPrim.tcProjectCode, (ProjectCode)
            input iiCompanyId, (CompanyId)
            input ?, (SafStructureCode)
            output dataset tqGetSafStructureLinkForProject) in BSafStructureLink>
 
        for first tqGetSafStructureLinkForProject:
            assign oiSafStructureId   = tqGetSafStructureLinkForProject.tiSafStructure_ID
                   ocSafStructureCode = tqGetSafStructureLinkForProject.tcSafStructureCode.
        end.
    end. 

end.  /* if available tqProjectPrim */