project QadFinancials > class BSafDefault > method GetSafDefaults

Description

Method contains a Case that runs query calls on source components that have the SafDefault table and query.


Parameters


icComponentListinputcharacterComponentList - chr(2) separated list with component-shortnames. Ex. BItem + <Chr(2)> + BItem + <Chr(2)> + BEmployee,....
icComponentValueListinputcharacterComponentValueList - chr(2) separated list with prim-key component. Ex. ItemCode1 + <Chr(2)> + ItemCode2 + <Chr(2)> + EmployeeCode1,...
icSafConceptListinputcharacterSafConceptList - chr(2) separated list with saf-concepts. Ex.SafConcept1 + <Chr(2)> + SafConcept2 + <Chr(2)> + SafConcept3,...
ocSafListoutputcharacterSafList - Chr(2) separated list with saf-values. Ex.Saf1 + <Chr(2)> + Saf2+ <Chr(2)> + <Chr(2)> +SafX,..
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.AddDefaultSaf
method BPosting.ApiStdMaintainTTSub11
method BPosting.DataLoadByInputSafDefaulting
method BPosting.StdMaintainTTSub11
method BJournalEntry.PostingLineSafs
method BSafDefault.ApiGetSafDefaults


program code (program3/bsafdefault.p)

/* <Validation: icComponentList and icComponentValueList should have the same number of entries> */
if num-entries(icComponentList,chr(2)) < 1 or
   num-entries(icComponentList,chr(2)) <> num-entries(icComponentValueList,chr(2))
then do:
    assign vcMessage = trim(substitute(#T-26'The component list and component value list must contain the same number of elements (component list: &1, component value list &2).':200(3654)t-26#, trim(string(num-entries(icComponentList,chr(2)))), trim(string(num-entries(icComponentValueList,chr(2)))))).
    <M-1 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  2 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-1630':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BSafDefault>
    assign oiReturnStatus = -1.
    return.
end.

/* Getting requested SAF codes - passing through all available components */
assign ocSafList = fill(chr(2),num-entries(icSafConceptList,chr(2)) - 1).
component_block: do viComponentCounter = 1 to num-entries(icComponentList,chr(2)): 
    case entry(viComponentCounter,icComponentList,chr(2)): 
        when "BBusinessRelation":U
        then do:
             if vlIsStartedQBusRelationSafDefau <> true
             then do:
                  <Q-85 run BusRelationSafDefaultByBusRel  (Start) in BBusinessRelation >
                  assign vlIsStartedQBusRelationSafDefau = true.
             end. /* if vlIsStartedQBusRelationSafDefau <> true */

             <Q-8 run BusRelationSafDefaultByBusRel (all) (Read) (Cache)
                 (input entry(viComponentCounter,icComponentValueList,chr(2)), (BusinessRelationCode)
                  output dataset tqBusRelationSafDefaultByBusRel) in BBusinessRelation >        
             for each tqBusRelationSafDefaultByBusRel where
                      tqBusRelationSafDefaultByBusRel.tcBusinessRelationCode = entry(viComponentCounter,icComponentValueList,chr(2)):
                viIndex = lookup(tqBusRelationSafDefaultByBusRel.tcSafConceptCode,icSafConceptList,chr(2)).
                if viIndex <> 0 and entry(viIndex,ocSafList,chr(2)) = '':U
                then assign entry(viIndex,ocSafList,chr(2)) = tqBusRelationSafDefaultByBusRel.tcSafCode
                            viResolvedSafValues             = viResolvedSafValues + 1. 
             end. /* for each tqBusRelationSafDefaultByBusRel */
             if viResolvedSafValues = num-entries(icSafConceptList,chr(2)) 
             then leave component_block.
        end. /* when "BBusinessRelation" */

        when "BCostCentre":U
        then do:
            if vlIsStartedQCostCentreSafDefaul <> true
            then do:
                <Q-52 run CostCentreSafDefaultByCostCent  (Start) in BCostCentre >
                assign vlIsStartedQCostCentreSafDefaul = true.
            end. /* if vlIsStartedQCostCentreSafDefaul <> true */

            <Q-9 run CostCentreSafDefaultByCostCent (all) (Read) (Cache)
               (input viCompanyId, (CompanyId)
                input entry(viComponentCounter,icComponentValueList,chr(2)), (CostCentre)
                output dataset tqCostCentreSafDefaultByCostCent) in BCostCentre >
            for each tqCostCentreSafDefaultByCostCent where
                     tqCostCentreSafDefaultByCostCent.tcCostCentreCode = entry(viComponentCounter,icComponentValueList,chr(2)):
                viIndex = lookup(tqCostCentreSafDefaultByCostCent.tcSafConceptCode,icSafConceptList,chr(2)).
                if viIndex <> 0 and entry(viIndex,ocSafList,chr(2)) = '':U
                then assign entry(viIndex,ocSafList,chr(2)) = tqCostCentreSafDefaultByCostCent.tcSafCode
                            viResolvedSafValues             = viResolvedSafValues + 1. 
            end. /* for each tqCostCentreSafDefaultByCostCent */
            if viResolvedSafValues = num-entries(icSafConceptList,chr(2)) 
            then leave component_block.
        end. /* when "BCostCentre" */
        
        when "BCreditor":U
        then do:
             if vlIsStartedQCreditorSafDefaultB <> true
             then do:
                 <Q-84 run CreditorSafDefaultByCreditor  (Start) in BCreditor >
                 assign vlIsStartedQCreditorSafDefaultB = true.
             end. /* if vlIsStartedQCreditorSafDefaultB <> true */
             <Q-10 run CreditorSafDefaultByCreditor (all) (Read) (Cache)
                (input viCompanyId, (CompanyId)
                 input entry(viComponentCounter,icComponentValueList,chr(2)), (CreditorCode)
                 output dataset tqCreditorSafDefaultByCreditor) in BCreditor >
             for each tqCreditorSafDefaultByCreditor where
                      tqCreditorSafDefaultByCreditor.tcCreditorCode = entry(viComponentCounter,icComponentValueList,chr(2)):
                viIndex = lookup(tqCreditorSafDefaultByCreditor.tcSafConceptCode,icSafConceptList,chr(2)).
                if viIndex <> 0 and entry(viIndex,ocSafList,chr(2)) = '':U
                then assign entry(viIndex,ocSafList,chr(2)) = tqCreditorSafDefaultByCreditor.tcSafCode
                            viResolvedSafValues             = viResolvedSafValues + 1. 
             end. /* for each tqCreditorSafDefaultByCreditor */
             if viResolvedSafValues = num-entries(icSafConceptList,chr(2)) 
             then leave component_block.
        end. /* when "BCreditor" */
        
        when "BDebtor":U
        then do:
             if vlIsStartedQDebtorSafDefaultByD <> true
             then do:
                 <Q-54 run DebtorSafDefaultByDebtor  (Start) in BDebtor >
                 assign vlIsStartedQDebtorSafDefaultByD = true.
             end. /* if vlIsStartedQDebtorSafDefaultByD <> true */
             <Q-11 run DebtorSafDefaultByDebtor (all) (Read) (Cache)
                (input viCompanyId, (CompanyId)
                 input entry(viComponentCounter,icComponentValueList,chr(2)), (DebtorCode)
                 output dataset tqDebtorSafDefaultByDebtor) in BDebtor >
             for each tqDebtorSafDefaultByDebtor where
                      tqDebtorSafDefaultByDebtor.tcDebtorCode = entry(viComponentCounter,icComponentValueList,chr(2)):
                viIndex = lookup(tqDebtorSafDefaultByDebtor.tcSafConceptCode,icSafConceptList,chr(2)).
                if viIndex <> 0 and entry(viIndex,ocSafList,chr(2)) = '':U
                then assign entry(viIndex,ocSafList,chr(2)) = tqDebtorSafDefaultByDebtor.tcSafCode
                            viResolvedSafValues             = viResolvedSafValues + 1. 
             end. /* for each tqDebtorSafDefaultByDebtor */
             if viResolvedSafValues = num-entries(icSafConceptList,chr(2)) 
             then leave component_block.
        end. /* when "BDebtor" */
        
        when "BGL":U
        then do:
             if vlIsStartedQGLSafDefaultByGL <> true
             then do:
                  <Q-56 run GLSafDefaultByGL  (Start) in BGL >
                  assign vlIsStartedQGLSafDefaultByGL = true.
             end. /* if vlIsStartedQGLSafDefaultByGL <> true */
             <Q-12 run GLSafDefaultByGL (all) (Read) (Cache)
                (input viCompanyId, (CompanyId)
                 input entry(viComponentCounter,icComponentValueList,chr(2)), (GLCode)
                 input ?, (GLID)
                 output dataset tqGLSafDefaultByGL) in BGL >
             for each tqGLSafDefaultByGL where
                      tqGLSafDefaultByGL.tcGLCode = entry(viComponentCounter,icComponentValueList,chr(2)):
                viIndex = lookup(tqGLSafDefaultByGL.tcSafConceptCode,icSafConceptList,chr(2)).
                if viIndex  <> 0 and entry(viIndex,ocSafList,chr(2)) = '':U
                then assign entry(viIndex,ocSafList,chr(2)) = tqGLSafDefaultByGL.tcSafCode
                            viResolvedSafValues             = viResolvedSafValues + 1. 
             end. /* for each tqGLSafDefaultByGL */
             if viResolvedSafValues = num-entries(icSafConceptList,chr(2)) 
             then leave component_block.
        end. /* when "BGL" */
        
        when "BProject":U
        then do:
             if vlIsStartedQProjectSafDefaultBy <> true
             then do:
                 <Q-44 run ProjectSafDefaultByProject  (Start) in BProject >
                 assign vlIsStartedQProjectSafDefaultBy = true.
             end. /* if vlIsStartedQProjectSafDefaultBy <> true */
             <Q-13 run ProjectSafDefaultByProject (all) (Read) (Cache)
                (input entry(viComponentCounter,icComponentValueList,chr(2)), (ProjectCode)
                 input viCompanyId, (CompanyId)
                 output dataset tqProjectSafDefaultByProject) in BProject >
             for each tqProjectSafDefaultByProject where
                      tqProjectSafDefaultByProject.tcProjectCode = entry(viComponentCounter,icComponentValueList,chr(2)):
                viIndex = lookup(tqProjectSafDefaultByProject.tcSafConceptCode,icSafConceptList,chr(2)).
                if viIndex <> 0 and entry(viIndex,ocSafList,chr(2)) = '':U
                then assign entry(viIndex,ocSafList,chr(2)) = tqProjectSafDefaultByProject.tcSafCode
                            viResolvedSafValues             = viResolvedSafValues + 1. 
             end. /* for each tqProjectSafDefaultByProject */
             if viResolvedSafValues = num-entries(icSafConceptList,chr(2)) 
             then leave component_block.
        end. /* when "BProject" */
        
        when "BSafStructure":U
        then do:
             if vlIsStartedQSafStructureByDefau <> true
             then do:
                  <Q-91 run SafStructureByDefault  (Start) in BSafStructure >
                  assign  vlIsStartedQSafStructureByDefau = true.
             end. /* if vlIsStartedQSafStructureByDefau <> true */
             <Q-28 run SafStructureByDefault (all) (Read) (NoCache)
               (input entry(viComponentCounter,icComponentValueList,chr(2)), (SafStructureCode)
                output dataset tqSafStructureByDefault) in BSafStructure >            
             for each tqSafStructureByDefault where
                      tqSafStructureByDefault.tcSafStructureCode = entry(viComponentCounter,icComponentValueList,chr(2)):
                viIndex = lookup(tqSafStructureByDefault.tcSafConceptCode,icSafConceptList,chr(2)).
                if viIndex <> 0 and entry(viIndex,ocSafList,chr(2)) = '':U
                then assign entry(viIndex,ocSafList,chr(2)) = tqSafStructureByDefault.tcSafCode
                            viResolvedSafValues             = viResolvedSafValues + 1. 
             end. /* for each tqSafStructureByDefault */
             if viResolvedSafValues = num-entries(icSafConceptList,chr(2)) 
             then leave component_block.
        end. /* when "BSafStructure" */
    end case.
end.
if vlIsStartedQBusRelationSafDefau = true
then do:
    <Q-20 run BusRelationSafDefaultByBusRel (Stop) in BBusinessRelation >   
end.
if vlIsStartedQCostCentreSafDefaul = true
then do:
     <Q-21 run CostCentreSafDefaultByCostCent (Stop) in BCostCentre >
end.
if vlIsStartedQCreditorSafDefaultB = true
then do:
    <Q-22 run CreditorSafDefaultByCreditor (Stop) in BCreditor >
end.
if vlIsStartedQDebtorSafDefaultByD = true
then do:
    <Q-23 run DebtorSafDefaultByDebtor (Stop) in BDebtor >
end.
if vlIsStartedQGLSafDefaultByGL = true
then do:
    <Q-24 run GLSafDefaultByGL (Stop) in BGL >
end.
if vlIsStartedQProjectSafDefaultBy = true
then do:
    <Q-25 run ProjectSafDefaultByProject (Stop) in BProject >
end.
if vlIsStartedQSafStructureByDefau = true
then do:
    <Q-30 run SafStructureByDefault  (Stop) in BSafStructure >
end.