project QadFinancials > class BSafStructure > method XGetSafStructure

Description

XGetSafStructure


Parameters


iiGLIdinputintegerGLId
iiJobIdinputintegerJobId
iiCostCentreinputinteger
tXSafStructureForActionLineoutputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bsafstructure.p)

/*
    /* ======== */
    /* Initiate */
    /* ======== */
    empty temp-table tXSafStructureForActionLine.
    
    /* ======================================= */
    /* Try to find the right saf-strust record */
    /* ======================================= */
    SafStructure_Block: do :
        
        /* ======= */    
        /* GL only */
        /* ======= */
        if iiGLId       <> 0 and
           iiGLId       <> ? and 
           (iiJobId      =  0 or
            iiJobId      =  ?) and 
           (iiCostCentre =  0 or
            iiCostCentre =  ?)
        then do:
            run GetSafStructure (input iiGLId, (GLId) 
                              input -999999, (JobId) 
                              input -999999, (CostCentreId)
                              output table tqGetSafStructure) in BSafStructure >
            find first tqGetSafStructure where 
                       tqGetSafStructure.tiGL_ID          = iiGLId and 
                       (tqGetSafStructure.tiJob_ID        = 0 or
                        tqGetSafStructure.tiJob_ID        = ?) and 
                       (tqGetSafStructure.tiCostCentre_ID = 0 or
                        tqGetSafStructure.tiCostCentre_ID = ?)
                       no-lock no-error.
            if available tqGetSafStructure
            then leave SafStructure_Block.
        end. /* GL only */ 
        
        /* =============== */
        /* GL + Job or Job */
        /* =============== */
        if iiGLId       <> 0 and
           iiGLId       <> ? and 
           iiJobId      <> 0 and
           iiJobId      <> ? and 
          (iiCostCentre =  0 or
           iiCostCentre =  ?)
        then do:
            /* GL + Job */
            run GetSafStructure (input iiGLId, (GLId) 
                          input iiJobId, (JobId) 
                          input -999999, (CostCentreId)
                          output table tqGetSafStructure) in BSafStructure >
            find first tqGetSafStructure where 
                       tqGetSafStructure.tiGL_ID          = iiGLId  and 
                       tqGetSafStructure.tiJob_ID         = iiJobId and  
                       (tqGetSafStructure.tiCostCentre_ID = 0 or
                        tqGetSafStructure.tiCostCentre_ID = ?)
                       no-lock no-error.
            if available tqGetSafStructure
            then leave SafStructure_Block.
            else do:
                /* Job */
                run GetSafStructure (input -999999, (GLId) 
                          input iiJobId, (JobId) 
                          input -999999, (CostCentreId)
                          output table tqGetSafStructure) in BSafStructure >
                find first tqGetSafStructure where 
                           (tqGetSafStructure.tiGL_ID         = 0 or
                            tqGetSafStructure.tiGL_ID         = ?) and
                           tqGetSafStructure.tiJob_ID         = iiJobId and 
                           (tqGetSafStructure.tiCostCentre_ID = 0 or
                            tqGetSafStructure.tiCostCentre_ID = ?)
                           no-lock no-error.
                if available tqGetSafStructure
                then leave SafStructure_Block.
            end. /* if not available tqGetSafStructure */
        end. /* GL + Job or Job */
        
        /* ============================= */
        /* GL + CostCentre or CostCentre */
        /* ============================= */
        if iiGLId       <> 0  and
           iiGLId       <> ?  and 
          (iiJobId      =  0 or
           iiJobId      =  ?) and 
           iiCostCentre <> 0  and
           iiCostCentre <> ?
        then do:
            /* GL + CostCentre */
            run GetSafStructure (input iiGLId, (GLId) 
                          input -999999, (JobId) 
                          input iiCostCentre, (CostCentreId)
                          output table tqGetSafStructure) in BSafStructure >
            find first tqGetSafStructure where 
                       tqGetSafStructure.tiGL_ID          = iiGLId  and 
                       (tqGetSafStructure.tiJob_ID        = 0 or
                        tqGetSafStructure.tiJob_ID        = ?)      and   
                       tqGetSafStructure.tiCostCentre_ID = iiCostCentre
                       no-lock no-error.
            if available tqGetSafStructure
            then leave SafStructure_Block.
            else do:
                /* CostCentre */
                run GetSafStructure (input -999999, (GLId) 
                          input -999999, (JobId) 
                          input iiCostCentre, (CostCentreId)
                          output table tqGetSafStructure) in BSafStructure >
                find first tqGetSafStructure where 
                           (tqGetSafStructure.tiGL_ID         = 0 or
                            tqGetSafStructure.tiGL_ID         = ?)  and 
                           (tqGetSafStructure.tiJob_ID        = 0 or
                            tqGetSafStructure.tiJob_ID        = ?)  and   
                           tqGetSafStructure.tiCostCentre_ID = iiCostCentre
                           no-lock no-error.
                if available tqGetSafStructure
                then leave SafStructure_Block.
            end. /* if not available tqGetSafStructure */
        end. /* GL + CostCentre or CostCentre */
        
    end. /* SafStructure_Block: do : */
    
    /* ================================================== */
    /* Now we have the right record (if available anyway) */
    /* ================================================== */
    if available tqGetSafStructure
    then do :
        create tXSafStructureForActionLine.
        buffer-copy tqGetSafStructure to tXSafStructureForActionLine.
        assign tXSafStructureForActionLine.tcSafConceptDescription1 = tqGetSafStructure.tcSafConceptDescription.
    end. /* if available tqGetSafStructure */
*/