project QadFinancials > class BBudget > method SetPublicTables

Description

Updates the contents of the class dataset.
When requested, the input data will be validated first, and the class dataset will only be updated when the input data is correct.
When no validation is requested, the input data is written to the class dataset unconditionally, but this data cannot be written to the database (method DataSave will return an error). The data can only be saved as a draft instance.


Parameters


il_Validateinputlogicalvalidate input data
BBudgetinputdatasetclass dataset
oiReturnStatusoutputintegererror status


program code (program/bbudget.p)

    for each t_sBudget:
        if t_sBudget.tc_Status = "D":U
        then do:
            run gipr_Delete_sBudgetCompany (input t_sBudget.tc_Rowid).
            run gipr_Delete_sBudgetFDS (input t_sBudget.tc_Rowid).
            run gipr_Delete_sBudgetPeriod (input t_sBudget.tc_Rowid).
            run gipr_Delete_sBudgetVersion (input t_sBudget.tc_Rowid).
            run gipr_Delete_sBudgetWBS (input t_sBudget.tc_Rowid).
        end.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudget.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudget.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudget where
        not can-find (t_sBudget where t_sBudget.tc_Rowid = t_oBudget.tc_Rowid):
        create t_sBudget.
        raw-transfer t_oBudget to t_sBudget.
    end.

    for each t_sBudgetCompany:
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetCompany.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetCompany.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetCompany.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetCompany.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetCompany where
        not can-find (t_sBudgetCompany where t_sBudgetCompany.tc_Rowid = t_oBudgetCompany.tc_Rowid) and
        not can-find (t_sBudget where t_sBudget.tc_Rowid = t_oBudgetCompany.tc_ParentRowid and t_sBudget.tc_Status = "D":U):
        create t_sBudgetCompany.
        raw-transfer t_oBudgetCompany to t_sBudgetCompany.
    end.

    for each t_sBudgetFDS:
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetFDS.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetFDS.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetFDS.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetFDS.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetFDS where
        not can-find (t_sBudgetFDS where t_sBudgetFDS.tc_Rowid = t_oBudgetFDS.tc_Rowid) and
        not can-find (t_sBudget where t_sBudget.tc_Rowid = t_oBudgetFDS.tc_ParentRowid and t_sBudget.tc_Status = "D":U):
        create t_sBudgetFDS.
        raw-transfer t_oBudgetFDS to t_sBudgetFDS.
    end.

    for each t_sBudgetPeriod:
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetPeriod.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetPeriod.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetPeriod.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetPeriod.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetPeriod where
        not can-find (t_sBudgetPeriod where t_sBudgetPeriod.tc_Rowid = t_oBudgetPeriod.tc_Rowid) and
        not can-find (t_sBudget where t_sBudget.tc_Rowid = t_oBudgetPeriod.tc_ParentRowid and t_sBudget.tc_Status = "D":U):
        create t_sBudgetPeriod.
        raw-transfer t_oBudgetPeriod to t_sBudgetPeriod.
    end.

    for each t_sBudgetVersion:
        if t_sBudgetVersion.tc_Status = "D":U
        then do:
            run gipr_Delete_sBudgetVersionFig (input t_sBudgetVersion.tc_Rowid).
            run gipr_Delete_sBudgetVersionGLFig (input t_sBudgetVersion.tc_Rowid).
        end.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetVersion.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetVersion.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetVersion.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetVersion.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetVersion where
        not can-find (t_sBudgetVersion where t_sBudgetVersion.tc_Rowid = t_oBudgetVersion.tc_Rowid) and
        not can-find (t_sBudget where t_sBudget.tc_Rowid = t_oBudgetVersion.tc_ParentRowid and t_sBudget.tc_Status = "D":U):
        create t_sBudgetVersion.
        raw-transfer t_oBudgetVersion to t_sBudgetVersion.
    end.

    for each t_sBudgetVersionFig:
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetVersionFig.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetVersionFig.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetVersionFig.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetVersionFig.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetVersionFig where
        not can-find (t_sBudgetVersionFig where t_sBudgetVersionFig.tc_Rowid = t_oBudgetVersionFig.tc_Rowid) and
        not can-find (t_sBudgetVersion where t_sBudgetVersion.tc_Rowid = t_oBudgetVersionFig.tc_ParentRowid and t_sBudgetVersion.tc_Status = "D":U):
        create t_sBudgetVersionFig.
        raw-transfer t_oBudgetVersionFig to t_sBudgetVersionFig.
    end.

    for each t_sBudgetVersionGLFig:
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetVersionGLFig.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetVersionGLFig.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetVersionGLFig.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetVersionGLFig.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetVersionGLFig where
        not can-find (t_sBudgetVersionGLFig where t_sBudgetVersionGLFig.tc_Rowid = t_oBudgetVersionGLFig.tc_Rowid) and
        not can-find (t_sBudgetVersion where t_sBudgetVersion.tc_Rowid = t_oBudgetVersionGLFig.tc_ParentRowid and t_sBudgetVersion.tc_Status = "D":U):
        create t_sBudgetVersionGLFig.
        raw-transfer t_oBudgetVersionGLFig to t_sBudgetVersionGLFig.
    end.

    for each t_sBudgetWBS:
        if t_sBudgetWBS.tc_Status = "D":U
        then do:
            run gipr_Delete_sBudgetWBSBusComponent (input t_sBudgetWBS.tc_Rowid).
            run gipr_Delete_sBudgetWBSRoster (input t_sBudgetWBS.tc_Rowid).
        end.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetWBS.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetWBS.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetWBS.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetWBS.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetWBS where
        not can-find (t_sBudgetWBS where t_sBudgetWBS.tc_Rowid = t_oBudgetWBS.tc_Rowid) and
        not can-find (t_sBudget where t_sBudget.tc_Rowid = t_oBudgetWBS.tc_ParentRowid and t_sBudget.tc_Status = "D":U):
        create t_sBudgetWBS.
        raw-transfer t_oBudgetWBS to t_sBudgetWBS.
    end.

    for each t_sBudgetWBSBusComponent:
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetWBSBusComponent.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetWBSBusComponent.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetWBSBusComponent.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetWBSBusComponent.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetWBSBusComponent where
        not can-find (t_sBudgetWBSBusComponent where t_sBudgetWBSBusComponent.tc_Rowid = t_oBudgetWBSBusComponent.tc_Rowid) and
        not can-find (t_sBudgetWBS where t_sBudgetWBS.tc_Rowid = t_oBudgetWBSBusComponent.tc_ParentRowid and t_sBudgetWBS.tc_Status = "D":U):
        create t_sBudgetWBSBusComponent.
        raw-transfer t_oBudgetWBSBusComponent to t_sBudgetWBSBusComponent.
    end.

    for each t_sBudgetWBSRoster:
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetWBSRoster.tc_ParentRowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetWBSRoster.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sBudgetWBSRoster.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sBudgetWBSRoster.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

    for each t_oBudgetWBSRoster where
        not can-find (t_sBudgetWBSRoster where t_sBudgetWBSRoster.tc_Rowid = t_oBudgetWBSRoster.tc_Rowid) and
        not can-find (t_sBudgetWBS where t_sBudgetWBS.tc_Rowid = t_oBudgetWBSRoster.tc_ParentRowid and t_sBudgetWBS.tc_Status = "D":U):
        create t_sBudgetWBSRoster.
        raw-transfer t_oBudgetWBSRoster to t_sBudgetWBSRoster.
    end.

    if il_Validate
    then do:
        { includes/bfcrun.i
          &procedure  = "CheckValidationExceptionList"
          &parameters = "input true, output vl_validate" }
    end.

    if vl_Validate
    then do:
        { includes/bfcrun.i
          &procedure  = "gipr_CompleteSTables" }
        { includes/bfcrun.i
          &procedure  = "ValidateComponent"
          &parameters = "output oiReturnStatus" }
    end.

    if oiReturnStatus >= 0
    then do:
        { includes/bfcrun.i
          &procedure  = "gipr_SetTables"
          &parameters = "output viFcReturnSuper" }
        if viFcReturnSuper <> 0
        then assign oiReturnStatus = viFcReturnSuper.
    end.

    if  il_Validate
    and oiReturnStatus >= 0
    then do:
        { includes/bfcrun.i
          &procedure  = "AdditionalUpdates"
          &parameters = "output viFcReturnSuper" }
        if viFcReturnSuper <> 0
        then assign oiReturnStatus = viFcReturnSuper.
    end.

    if oiReturnStatus >= 0
    then assign vlFcDataValidated = il_Validate.