project QadFinancials > class BBudget > method BudgetVersionCopy

Description

This method will create a single budgetVersion-record with the same properties as the source-BudgetVersion and return temp-tables that contain the newly created records.


Parameters


icBudgetTcRowidinputcharacterBudget; BudgetTcRowid
icSourceBudgetVersionTcRowidinputcharacterRowid of the source BudgetVersion
tNewBudgetVersionoutputtemp-tableTemp-table containing the new BudgetVersion-record
tNewBudgetVersionFigureoutputtemp-tableTemp-table containing the new BudgetVersionFigure-records
tNewBudgetVersionGLFigoutputtemp-tableNewBudgetVersionGLFig
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program6/bbudget.p)

/* =========================================================================================== */
    /* Replace unknown values // Check existance of the tBudget record and the tBudgetVersion rec  */
    /* =========================================================================================== */
    if icSourceBudgetVersionTcRowid = ?
    then assign icSourceBudgetVersionTcRowid = "":U.
    if icBudgetTcRowid = "":U or icBudgetTcRowid = ?
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-9'You must enter the budget identification (row ID) for the creation of budget topics.':255(535)T-9#).
        <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-558':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 and 
             tBudget.tc_Status <> "D":U
             no-lock no-error.
        if not available tBudget
        then do :
            assign oiReturnStatus = -3
                   vcMessage      = trim(substitute(#T-10'Cannot find the budget based on its row ID (&1).':255(448)t-10#,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-559':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 */
    find bSourceBudgetVersion where 
         bSourceBudgetVersion.tc_Rowid   = icSourceBudgetVersionTcRowid and 
         bSourceBudgetVersion.tc_Status <> "D":U
         no-lock no-error.
    if not available bSourceBudgetVersion
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(substitute(#T-11'The system cannot locate the source budget version based on its row ID (&1).':255(714)t-11#,string(icSourceBudgetVersionTcRowid))).
        <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-560':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not available bSourceBudgetVersion */
    
    /* ========================================================================== */
    /* Reset the output temp-table                                                */
    /* ========================================================================== */
    empty temp-table tNewBudgetVersion.
    empty temp-table tNewBudgetVersionFigure.
    empty temp-table tNewBudgetVersionGLFig.
    
    /* =============================================================== */
    /* Create the new Version-record and a corresponding output record */
    /* =============================================================== */
    <M-6 run AddDetailLine (input  'BudgetVersion':U (icTable), 
                        input  tBudget.tc_Rowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if viFcReturnSuper < 0 
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end. /* if viFcReturnSuper < 0  */
    assign tBudgetVersion.BudgetVersionCode         = trim(substitute(#T-12'Copy of &1':20(715)t-12#,bSourceBudgetVersion.BudgetVersionCode))
           tBudgetVersion.BudgetVersionDescription  = trim(substitute(#T-13'Copy of &1':20(715)t-13#,bSourceBudgetVersion.BudgetVersionDescription))
           tBudgetVersion.BudgetVersionIsActive     = false.
    create tNewBudgetVersion.
    buffer-copy tBudgetVersion to tNewBudgetVersion.
    
    /* ================================================================= */
    /* Create new VersionFigure-records for the new budgetVersion record */
    /* Do the same for the corresponding output records                  */
    /* ================================================================= */
    for each bSourceBudgetVersionFigure where 
             bSourceBudgetVersionFigure.tc_ParentRowid  = bSourceBudgetVersion.tc_Rowid and 
             bSourceBudgetVersionFigure.tc_Status      <> "D":U
             no-lock :
        <M-7 run AddDetailLine (input  'BudgetVersionFigure':U (icTable), 
                        input  tBudgetVersion.tc_Rowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BBudget>
        if viFcReturnSuper < 0 
        then do :
            assign oiReturnStatus = viFcReturnSuper.
            return.
        end. /* if viFcReturnSuper < 0  */
        buffer-copy bSourceBudgetVersionFigure
                    Except tc_status tc_rowid tc_parentrowid BudgetVersion_ID BudgetVersionFig_ID
                    TO tBudgetVersionFig.
        assign tBudgetVersionFig.BudgetVersion_ID = tBudgetVersion.BudgetVersion_ID.
        create tNewBudgetVersionFigure.
        buffer-copy tBudgetVersionFig to tNewBudgetVersionFigure.
    end. /* for each */
    
    /* ================================================================= */
    /* Create new VersionGLFig-records for the new budgetVersion record  */
    /* Do the same for the corresponding output records                  */
    /* ================================================================= */
    for each bSourceBudgetVersionGLFig where 
             bSourceBudgetVersionGLFig.tc_ParentRowid  = bSourceBudgetVersion.tc_Rowid and 
             bSourceBudgetVersionGLFig.tc_Status      <> "D":U
             no-lock :
        <M-8 run AddDetailLine (input  'BudgetVersionGLFig':U (icTable), 
                        input  tBudgetVersion.tc_Rowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BBudget>
        if viFcReturnSuper < 0 
        then do :
            assign oiReturnStatus = viFcReturnSuper.
            return.
        end. /* if viFcReturnSuper < 0  */
        buffer-copy bSourceBudgetVersionGLFig 
                    Except tc_status tc_rowid tc_parentrowid BudgetVersion_ID BudgetVersionGLFig_ID
                    TO tBudgetVersionGLFig.
        assign tBudgetVersionGLFig.BudgetVersion_ID = tBudgetVersion.BudgetVersion_ID.
        create tNewBudgetVersionGLFig.
        buffer-copy tBudgetVersionGLFig to tNewBudgetVersionGLFig.
    end. /* for each */