project QadFinancials > class BBudget > method BudgetVersionCreate
Description
This method allows the creation of a single BudgetVersion record and returns the newly created record by using output paramater tables.
Parameters
icBudgetTcRowid | input | character | BudgetTcRowid |
icBudgetVersionCode | input | character | BudgetVersionCode |
icBudgetVersionDescription | input | character | BudgetVersionDescription |
tNewBudgetVersion | output | temp-table | output table containing the newly created BudgetVerison record |
tNewBudgetVersionFigure | output | temp-table | output table containing the newly created BudgetVerisonFigure records |
tNewBudgetVersionGLFig | output | temp-table | output table containing the newly created BudgetVerisonGLFig records |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program6/bbudget.p)
/* =========================================================================================== */
/* Replace unknown values // Check existance of the tBudget record */
/* =========================================================================================== */
if icBudgetVersionCode = ? then assign icBudgetVersionCode = "":U.
if icBudgetVersionDescription = ? then assign icBudgetVersionDescription = "":U.
if icBudgetTcRowid = "":U or icBudgetTcRowid = ?
then do :
assign oiReturnStatus = -3
vcMessage = trim(#T-8'You must enter the budget identification (row ID) for the creation of budget topics.':255(535)T-8#).
<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-561':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-9'Cannot find the budget based on its row ID (&1).':255(448)t-9#,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-562':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 */
/* ========================================================================== */
/* 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-4 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 = icBudgetVersionCode
tBudgetVersion.BudgetVersionDescription = (if icBudgetVersionDescription = "":U or icBudgetVersionDescription = ?
then tBudgetVersion.BudgetVersionCode
else icBudgetVersionDescription)
tBudgetVersion.BudgetVersionIsActive = false.
create tNewBudgetVersion.
buffer-copy tBudgetVersion to tNewBudgetVersion.
/* ================================================================================= */
/* Create new VersionFigure-records (for every WBS) for the new budgetVersion record */
/* Do the same for the corresponding output records */
/* ================================================================================= */
for each tBudgetWBS where
tBudgetWBS.tc_ParentRowid = tBudget.tc_Rowid and
tBudgetWBS.tc_Status <> "D":U
no-lock :
if (tBudget.tcProjectCode <> "":U and tBudget.tcProjectCode <> ?) or
(tBudget.tcCostCentreCode <> "":U and tBudget.tcCostCentreCode <> ?)
then do :
<M-5 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 */
assign tBudgetVersionFig.BudgetVersion_ID = tBudgetVersion.BudgetVersion_ID
tBudgetVersionFig.BudgetWBS_ID = tBudgetWBS.BudgetWBS_ID
tBudgetVersionFig.tiBudgetFDSSeq = tBudgetWBS.BudgetFDSSeq
tBudgetVersionFig.tcBudgetFDSType = tBudgetWBS.BudgetFDSType
tBudgetVersionFig.tcBudgetWBSSeq = tBudgetWBS.tcBudgetWBSSeqStr
tBudgetVersionFig.tcBudgetWBSCode = tBudgetWBS.BudgetWBSCode
tBudgetVersionFig.tiParentBudgetWBS_ID = tBudgetWBS.ParentBudgetWBS_ID.
create tNewBudgetVersionFigure.
buffer-copy tBudgetVersionFig to tNewBudgetVersionFigure.
end. /* Project or CC budget */
else do :
<M-7 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 */
assign tBudgetVersionGLFig.BudgetVersion_ID = tBudgetVersion.BudgetVersion_ID
tBudgetVersionGLFig.BudgetWBS_ID = tBudgetWBS.BudgetWBS_ID
tBudgetVersionGLFig.tiBudgetFDSSeq = tBudgetWBS.BudgetFDSSeq
tBudgetVersionGLFig.tcBudgetFDSType = tBudgetWBS.BudgetFDSType
tBudgetVersionGLFig.tcBudgetWBSSeq = tBudgetWBS.tcBudgetWBSSeqStr
tBudgetVersionGLFig.tcBudgetWBSCode = tBudgetWBS.BudgetWBSCode
tBudgetVersionGLFig.tiBudgetWBSLineNumber= tBudgetWBS.BudgetWBSLineNumber
tBudgetVersionGLFig.tiParentBudgetWBS_ID = tBudgetWBS.ParentBudgetWBS_ID.
create tNewBudgetVersionGLFig.
buffer-copy tBudgetVersionGLFig to tNewBudgetVersionGLFig.
end. /* not Project or CC budget */
end. /* for each */