project QadFinancials > class BBudget > method BudgetWBSCreateMultiple

Description

This method will creates multiple budgetWBS-records based on the input information and returns temp-tables that contain the newly created records.


Parameters


icBudgetTcRowidinputcharacterBudgetTcRowid
icBudgetWBSTcRowidinputcharacterBudgetWBSTcRowid; tc_rowid of the current node you are on
ilCreateChildinputlogicalCreateChild;
true if the new nodes should be a child of the current node
false if the new nodes should be on the same level as the current one
icSafStructureCodeinputcharacterSafStructureCode; this can only be passed in case the new records are on the highest saf-level in the fds-tree.
icBudgetWBSFDSFromCodeinputcharacterBudgetWBSFDSFromCode; From FDS Code
icBudgetWBSFDSToCodeinputcharacterBudgetWBSFDSToCode; From FDS Code
iiPositionForBreakGroupinputintegerPositionForBreakGroup
tNewMBudgetWBSoutputtemp-tableTemp-table containing the new BudgetWBS-records
tNewMBudgetVersionFigureoutputtemp-tableTemp-table containing the new BudgetVersionFigure-records
tNewMBudgetVersionGLFigoutputtemp-tableTemp-table containing the new BudgetVersionGLFig-records
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program6/bbudget.p)

/* ====================================== */
/* Clear the content of the output tables */
/* ====================================== */
empty temp-table tNewMBudgetWBS.
empty temp-table tNewMBudgetVersionFigure.
empty temp-table tNewMBudgetVersionGLFig.

/* ==================================================================================================== */
/* Replace unknown values // Check existance of the tBudget record and the tBudgetWBS rec (conditional) */
/* Validation; when starting from the root-node it is not possible to create a node on the same level   */
/* ==================================================================================================== */
if icBudgetWBSTcRowid      = ? then assign icBudgetWBSTcRowid      = "":U.
if icSafStructureCode      = ? then assign icSafStructureCode      = "":U.
if icBudgetWBSFDSFromCode  = ? then assign icBudgetWBSFDSFromCode  = "":U.
if icBudgetWBSFDSToCode    = ? then assign icBudgetWBSFDSToCode    = "":U.
if iiPositionForBreakGroup = ? then assign iiPositionForBreakGroup = 0.
if icBudgetTcRowid = "":U or icBudgetTcRowid = ?
then do :
    assign oiReturnStatus = -3
           vcMessage      = trim(#T-24'You must enter the budget identification (row ID) for the creation of budget topics.':255(535)T-24#).
    <M-1 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-505':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
    Return.
end. /* if icBudgetTcRowid  = ? or */
else do :
    find tBudget where 
         tBudget.tc_Rowid = icBudgetTcRowid 
         no-lock no-error.
    if not available tBudget
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(substitute(#T-25'Cannot find the budget based on its row ID (&1).':255(448)t-25#,string(icBudgetTcRowid))).
        <M-2 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-506':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not available tBudget */
end. /* not if iiBudgetID = 0 or */
if icBudgetWBSTcRowid  = "":U and 
   ilCreateChild       = true
then do :
    assign oiReturnStatus = -3
           vcMessage      = trim(#T-26'Cannot create multiple child topics for the budget WBS without specifying the current topic.':255(666)t-26#).
    <M-3 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-507':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
    Return.
end. /* if icBudgetWBSTcRowid = 0 or icBudgetWBSTcRowid = ? */
if icBudgetWBSTcRowid <> "":U 
then do :
    find tBudgetWBS where 
         tBudgetWBS.tc_ParentRowid  = tBudget.tc_Rowid   and 
         tBudgetWBS.tc_Rowid        = icBudgetWBSTcRowid and 
         tBudgetWBS.tc_Status      <> "D":U
         no-lock no-error.
    if not available tBudgetWBS
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(substitute(#T-27'Cannot find the current budget WBS topic based on its row ID &1.':255(450)t-27#,string(icBudgetWBSTcRowid))).
        <M-4 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-508':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not available tBudgetWBS */
end. /* if icBudgetWBSTcRowid <> "":U */
if iiPositionForBreakGroup > 20
then do :
    assign oiReturnStatus = -3
           vcMessage      = trim(substitute(#T-28'The break position (&1) cannot exceed position 20.':255(667)T-28#,string(iiPositionForBreakGroup))).
    <M-12 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-556':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
    Return.
end. /* if iiPositionForBreakGroup > 20 */

/* ==================================================== */
/* No action allowed if the budget is not yet validated */
/* ==================================================== */
if tBudget.BudgetStatus = {&BUDGETSTATUS-INITIAL}
then do :
    assign oiReturnStatus = -3
           vcMessage      = trim(#T-29'You must validate the budget structure before maintaining the WBS.':255(451)t-29#).
    <M-5 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-509':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
    Return.
end. /* if tBudget.BudgetStatus = {&BUDGETSTATUS-INITIAL} */

/* ===================================================== */
/* State the BudgetWBS wherefor we want to create childs */
/* ===================================================== */
if icBudgetWBSTcRowid = "":U or 
    (available tBudgetWBS and 
     tBudgetWBS.BudgetFDSSeq = 1 and 
     ilCreateChild           = false)
then assign vcParentBudgetWBSTcRowid = "":U.
else if ilCreateChild = true
     then assign vcParentBudgetWBSTcRowid = tBudgetWBS.tc_Rowid.
     else do :
        find bParentBudgetWBS where 
             bParentBudgetWBS.tc_ParentRowid  = tBudget.tc_Rowid              and 
             bParentBudgetWBS.BudgetWBS_ID    = tBudgetWBS.ParentBudgetWBS_ID and 
             bParentBudgetWBS.tc_Status      <> "D":U
             no-lock no-error.
        if available bParentBudgetWBS
        then assign vcParentBudgetWBSTcRowid = bParentBudgetWBS.tc_Rowid.
        else assign vcParentBudgetWBSTcRowid = "XXX":U.
     end. /* if ilCreateChild = false */
     
/* ===================================================================================== */
/* Find out the FDS-type and FDS-Seq of these new records = FDS-level of the parent + 1  */
/* ===================================================================================== */
if vcParentBudgetWBSTcRowid = "":U 
then assign viFDSSeq = 1.
else do :
    find bParentBudgetWBS where 
         bParentBudgetWBS.tc_Rowid = vcParentBudgetWBSTcRowid
        no-lock no-error.
    if not available bParentBudgetWBS
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(substitute(#T-30'Cannot find the parent budget WBS topic based on its row ID &1.':255(668)t-30#,string(vcParentBudgetWBSTcRowid))).
        <M-6 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-551':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not available bParentBudgetWBS */
    assign viFDSSeq = bParentBudgetWBS.BudgetFDSSeq + 1.
end. /* if vcParentBudgetWBSTcRowid = "":U */
find tBudgetFDS where
     tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid and 
     tBudgetFDS.BudgetFDSSeq   = viFDSSeq
     NO-LOCK NO-ERROR.
if not available tBudgetFDS
then do :
    assign oiReturnStatus = -3
           vcMessage      = trim(substitute(#T-31'Cannot find the budget COA topic with sequence number &1.':255(669)t-31#,string(viFDSSeq))).
    <M-7 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-552':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
    Return.
end. /* if not available tBudgetFDS */
assign vcFDSType = tBudgetFDS.BudgetFDSType.

/* =============================================== */
/* We cannot create multiple nodes of type 'TOTAL' */
/* =============================================== */
if vcFDSType = {&BUDGETFDSTYPE-TOTAL}
then do :
    assign oiReturnStatus = -3
           vcMessage      = trim(substitute(#T-32'Cannot create multiple codes of type &1.':255(670)t-32#,trim({&BUDGETFDSTYPE-TOTAL-TR}))).
    <M-22 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-557':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
    Return.
end. /* if vcFDSType = {&BUDGETFDSTYPE-TOTAL} */

/* ========================================================================= */
/* If this is the highest SAF-level then SafStructure is mandatory           */
/* Find out the saf-structure of the highest SAF node and find the depth     */
/* Based on this SafStructure, we can state the SafConcept for the SafValues */
/* ========================================================================= */
if vcFDSType = {&BUDGETFDSTYPE-SAF}
then do :
    assign viSafStructureCodeDepth = 1
           vcSafStructureCodeTop   = icSafStructureCode.
    find tBudgetWBS where
         tBudgetWBS.tc_ParentRowid  = tBudget.tc_Rowid         and 
         tBudgetWBS.tc_Rowid        = vcParentBudgetWBSTcRowid and /* vcParentBudgetWBSTcRowid is the rowid of the parents to be created */
         tBudgetWBS.tc_Status      <> "D":U                    and
         (tBudgetWBS.BudgetFDSType  = {&BUDGETFDSTYPE-SAF} OR 
          tBudgetWBS.BudgetFDSType  = {&BUDGETFDSTYPE-TOTAL})
         no-lock no-error.
    if available tBudgetWBS
    then do :
        if tBudgetWBS.BudgetFDSType  = {&BUDGETFDSTYPE-SAF} 
        then assign viSafStructureCodeDepth = viSafStructureCodeDepth + 1.
        assign viParentBudgetWBSID = tBudgetWBS.ParentBudgetWBS_ID.    
        do while true :
            find tBudgetWBS where
                 tBudgetWBS.tc_ParentRowid  = tBudget.tc_Rowid    and 
                 tBudgetWBS.BudgetWBS_ID    = viParentBudgetWBSID and 
                 tBudgetWBS.tc_Status      <> "D":U               and
                 (tBudgetWBS.BudgetFDSType  = {&BUDGETFDSTYPE-SAF} OR 
                  tBudgetWBS.BudgetFDSType  = {&BUDGETFDSTYPE-TOTAL})
                 no-lock no-error.
            if available tBudgetWBS
            then DO :
                assign viParentBudgetWBSID     = tBudgetWBS.ParentBudgetWBS_ID.
                if tBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF}
                then assign viSafStructureCodeDepth = viSafStructureCodeDepth + 1
                            vcSafStructureCodeTop   = tBudgetWBS.tcSafStructureCode.
            end. /* if available tBudgetWBS */
            else leave.
        end. /* do while true */
    end. /* if available tBudgetWBS */
    /* If the new-one are on the top-saf level then the saf-structure is mandatory */
    if viSafStructureCodeDepth = 1 and 
       icSafStructureCode      = "":U
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-33'The SAF structure is mandatory for SAF information on the highest level of the COA tree.':255(671)T-33#).
        <M-9 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-554':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if icSafStructureCode = "":U */
    /* Get the SafConcept */
    <Q-10 run SafConceptCodeByLine (all) (Read) (NoCache)
          (input ?, (SafStructure_ID)
           input viSafStructureCodeDepth, (SafStructureLineNumber)
           input vcSafStructureCodeTop, (SafStructureCode)
           output dataset tqSafConceptCodeByLine) in BSafStructure >
    find first tqSafConceptCodeByLine where  
               tqSafConceptCodeByLine.tcSafStructureCode       = vcSafStructureCodeTop and 
               tqSafConceptCodeByLine.tiSafStructureLineNumber = viSafStructureCodeDepth 
               no-lock no-error.
    if not available tqSafConceptCodeByLine
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(substitute(#T-34'Cannot define level &1 of the SAF structure &2.':255(583)t-34#,string(viSafStructureCodeDepth),string(vcSafStructureCodeTop))).
        <M-11 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-555':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not av. tqSafConceptCodeByLine */
    assign vcSafConceptCode = tqSafConceptCodeByLine.tcSafConceptCode
           viSafConceptID   = tqSafConceptCodeByLine.tiSafConcept_ID
           viSafStructureID = tqSafConceptCodeByLine.tiSafStructure_ID.
end. /* if vcFDSType = {&BUDGETFDSTYPE-SAF} */

/* =============================================================================== */
/* Compose the list with the codes for the new records their FDS-Link information  */
/* =============================================================================== */
case vcFDSType :
when {&BUDGETFDSTYPE-GL}
then do :
    <Q-13 run GLBySSOthers (all) (Read) (NoCache)
          (input ?, (CompanyId)
           input icBudgetWBSFDSFromCode, (FromGLCode)
           input icBudgetWBSFDSToCode, (ToGLCode)
           input tBudget.GLSharedSet_ID, (GLSharedSetID)
           input ?, (MatchingGLCode)
           input ?, (GLCode)
           input ?, (BudgetGroupID)
           output dataset tqGLBySSOthers) in BGL >
    for each tqGLBySSOthers no-lock by tqGLBySSOthers.tcGLCode descending :
        if iiPositionForBreakGroup = 0
        then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + tqGLBySSOthers.tcGLCode.
        else do :
            if vcPreviousCode <> substring(tqGLBySSOthers.tcGLCode,1,iiPositionForBreakGroup,"CHARACTER":U)
            then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + substring(tqGLBySSOthers.tcGLCode,1,iiPositionForBreakGroup,"CHARACTER":U) + "*":U
                        vcPreviousCode         = substring(tqGLBySSOthers.tcGLCode,1,iiPositionForBreakGroup,"CHARACTER":U).
        end. /* if iiPositionForBreakGroup <> 0 */
    end. /* for each tqGLBySSOthers no-lock */
end. /* when {&BUDGETFDSTYPE-GL} */  
when {&BUDGETFDSTYPE-DIVISION}
then do :
    <Q-15 run DivisionBySSOthers (all) (Read) (NoCache)
          (input ?, (CompanyId)
           input tBudget.DivisionSharedSet_ID, (DivisionSharedSetID)
           input icBudgetWBSFDSFromCode, (FromDivisionCode)
           input icBudgetWBSFDSToCode, (ToDivisionCode)
           input ?, (MatchingDivisionCode)
           input ?, (DivisionCode)
           input ?, (BudgetGroupID)
           output dataset tqDivisionBySSOthers) in BDivision >
    for each tqDivisionBySSOthers no-lock by tqDivisionBySSOthers.tcDivisionCode descending :
        if iiPositionForBreakGroup = 0
        then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + tqDivisionBySSOthers.tcDivisionCode.
        else do :
            if vcPreviousCode <> substring(tqDivisionBySSOthers.tcDivisionCode,1,iiPositionForBreakGroup,"CHARACTER":U)
            then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + substring(tqDivisionBySSOthers.tcDivisionCode,1,iiPositionForBreakGroup,"CHARACTER":U) + "*":U
                        vcPreviousCode         = substring(tqDivisionBySSOthers.tcDivisionCode,1,iiPositionForBreakGroup,"CHARACTER":U).
        end. /* if iiPositionForBreakGroup <> 0 */
    end. /* for each tqDivisionBySSOthers no-lock */
end. /* when {&BUDGETFDSTYPE-DIVISION} */
when {&BUDGETFDSTYPE-PROJECT}
then do :
    <Q-17 run ProjectBySSOthers (all) (Read) (NoCache)
          (input ?, (CompanyId)
           input tBudget.ProjectSharedSet_ID, (ProjectSharedSetID)
           input icBudgetWBSFDSFromCode, (FromProjectCode)
           input icBudgetWBSFDSToCode, (ToProjectCode)
           input ?, (MatchingProjectCode)
           input ?, (ProjectCode)
           input ?, (BudgetGroupID)
           output dataset tqProjectBySSOthers) in BProject >
    for each tqProjectBySSOthers no-lock by tqProjectBySSOthers.tcProjectCode descending :
        if iiPositionForBreakGroup = 0
        then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + tqProjectBySSOthers.tcProjectCode.
        else do :
            if vcPreviousCode <> substring(tqProjectBySSOthers.tcProjectCode,1,iiPositionForBreakGroup,"CHARACTER":U)
            then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + substring(tqProjectBySSOthers.tcProjectCode,1,iiPositionForBreakGroup,"CHARACTER":U) + "*":U
                        vcPreviousCode         = substring(tqProjectBySSOthers.tcProjectCode,1,iiPositionForBreakGroup,"CHARACTER":U).
        end. /* if iiPositionForBreakGroup <> 0 */
    end. /* for each tqProjectBySSOthers no-lock */
end. /* when {&BUDGETFDSTYPE-PROJECT} */
when {&BUDGETFDSTYPE-COSTCENTRE}
then do :
    <Q-19 run CostCentreBySSOthers (all) (Read) (NoCache)
          (input ?, (CompanyId)
           input tBudget.CostCentreSharedSet_ID, (CostCentreSharedSetID)
           input icBudgetWBSFDSFromCode, (FromCostCentreCode)
           input icBudgetWBSFDSToCode, (ToCostCentreCode)
           input ?, (MatchingCostCentreCode)
           input ?, (CostCentreCode)
           input ?, (BudgetGroupID)
           output dataset tqCostCentreBySSOthers) in BCostCentre >
    for each tqCostCentreBySSOthers no-lock by tqCostCentreBySSOthers.tcCostCentreCode descending :
        if iiPositionForBreakGroup = 0
        then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + tqCostCentreBySSOthers.tcCostCentreCode.
        else do :
            if vcPreviousCode <> substring(tqCostCentreBySSOthers.tcCostCentreCode,1,iiPositionForBreakGroup,"CHARACTER":U)
            then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + substring(tqCostCentreBySSOthers.tcCostCentreCode,1,iiPositionForBreakGroup,"CHARACTER":U) + "*":U
                        vcPreviousCode         = substring(tqCostCentreBySSOthers.tcCostCentreCode,1,iiPositionForBreakGroup,"CHARACTER":U).
        end. /* if iiPositionForBreakGroup <> 0 */
    end. /* for each tqCostCentreBySSOthers no-lock */
end. /* when {&BUDGETFDSTYPE-COSTCENTRE}} */
when {&BUDGETFDSTYPE-SAF} 
then do :
    <Q-21 run SafBySSOthers (all) (Read) (NoCache)
          (input icBudgetWBSFDSFromCode, (FromSafCode)
           input icBudgetWBSFDSToCode, (ToSafCode)
           input vcSafConceptCode, (SafConceptCode)
           input ?, (SafConceptID)
           input ?, (MatchingSafCode)
           input ?, (SafCode)
           input ?, (BudgetGroupID)
           output dataset tqSafBySSOthers) in BSaf >
    for each tqSafBySSOthers no-lock by tqSafBySSOthers.tcSafCode descending :
        if iiPositionForBreakGroup = 0
        then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + tqSafBySSOthers.tcSafCode.
        else do :
            if vcPreviousCode <> substring(tqSafBySSOthers.tcSafCode,1,iiPositionForBreakGroup,"CHARACTER":U)
            then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + substring(tqSafBySSOthers.tcSafCode,1,iiPositionForBreakGroup,"CHARACTER":U) + "*":U
                        vcPreviousCode         = substring(tqSafBySSOthers.tcSafCode,1,iiPositionForBreakGroup,"CHARACTER":U).
        end. /* if iiPositionForBreakGroup <> 0 */
    end. /* for each tqSafBySSOthers no-lock */
end. /* when {&BUDGETFDSTYPE-SAF} */
when {&BUDGETFDSTYPE-REPORT}
then do: 
    <Q-46 run FRWAnCodeBySSOthers (all) (Read) (NoCache)
       (input ?, (AnCodeCode)
        input icBudgetWBSFDSFromCode, (FromAnCodeCode)
        input tBudget.tcFRWChartCode, (FRWChartCode)
        input ?, (MatchesAnCodeCode)
        input icBudgetWBSFDSToCode, (ToAnCodeCode)
        output dataset tqFRWAnCodeBySSOthers) in BFRWAnalysisCode>
    for each tqFRWAnCodeBySSOthers no-lock by tqFRWAnCodeBySSOthers.tcFRWAnCodeCode descending :
        if iiPositionForBreakGroup = 0
        then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + tqFRWAnCodeBySSOthers.tcFRWAnCodeCode.
        else do:
            if vcPreviousCode <> substring(tqFRWAnCodeBySSOthers.tcFRWAnCodeCode,1,iiPositionForBreakGroup,"CHARACTER":U)
            then assign vcMultipleCreationList = vcMultipleCreationList + ",":U + substring(tqFRWAnCodeBySSOthers.tcFRWAnCodeCode,1,iiPositionForBreakGroup,"CHARACTER":U) + "*":U
                        vcPreviousCode         = substring(tqFRWAnCodeBySSOthers.tcFRWAnCodeCode,1,iiPositionForBreakGroup,"CHARACTER":U).
        end. /* if iiPositionForBreakGroup <> 0 */
    end. /* for each tqFRWAnCodeBySSOthers no-lock */
end. /* when {&BUDGETFDSTYPE-REPORT} */
end case.
if vcMultipleCreationList <> "":U
then assign vcMultipleCreationList = SUBSTRING(vcMultipleCreationList,2,-1,"CHARACTER":U).
          
/* ==================================================== */
/* Call a submethod that will do the further processing */
/* ==================================================== */
<M-23 run BudgetWBSCreateMultipleSub (input  icBudgetTcRowid (icBudgetTcRowid), 
                                      input  vcParentBudgetWBSTcRowid (icBudgetWBSTcRowid), 
                                      input  vcMultipleCreationList (icMultipleCreationList), 
                                      output tNewMBudgetWBS (tNewMBudgetWBS), 
                                      output tNewMBudgetVersionFigure (tNewMBudgetVersionFigure), 
                                      output tNewMBudgetVersionGLFig (tNewMBudgetVersionGLFig), 
                                      output viFcReturnSuper (oiReturnStatus)) in BBudget>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.

/* ====================================================== */ 
/* State the SafStructure and SafConcept of the new nodes */
/* ====================================================== */                       
if vcFDSType = {&BUDGETFDSTYPE-SAF}
then do :
    for each tNewMBudgetWBS,
        each tBudgetWBS where 
             tBudgetWBS.BudgetWBS_ID = tNewMBudgetWBS.BudgetWBS_ID :
        assign tNewMBudgetWBS.tcSafStructureCode = icSafStructureCode
               tNewMBudgetWBS.tcSafConceptCode   = vcSafConceptCode
               tNewMBudgetWBS.SafConcept_ID      = viSafConceptID
               tNewMBudgetWBS.SafStructure_ID    = viSafStructureID
               tBudgetWBS.tcSafStructureCode     = icSafStructureCode
               tBudgetWBS.tcSafConceptCode       = vcSafConceptCode
               tBudgetWBS.SafConcept_ID          = viSafConceptID
               tBudgetWBS.SafStructure_ID        = viSafStructureID.
    end. /* for each tNewMBudgetWBS */
end. /* if vcFDSType = {&BUDGETFDSTYPE-SAF} */