project QadFinancials > class BFRWAnalysisCode > 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
BFRWAnalysisCodeinputdatasetclass dataset
oiReturnStatusoutputintegererror status


program code (program/bfrwanalysiscode.p)

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

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

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

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

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

    for each t_oFRWAnCodeElemDet where
        not can-find (t_sFRWAnCodeElemDet where t_sFRWAnCodeElemDet.tc_Rowid = t_oFRWAnCodeElemDet.tc_Rowid) and
        not can-find (t_sFRWAnCodeElem where t_sFRWAnCodeElem.tc_Rowid = t_oFRWAnCodeElemDet.tc_ParentRowid and t_sFRWAnCodeElem.tc_Status = "D":U):
        create t_sFRWAnCodeElemDet.
        raw-transfer t_oFRWAnCodeElemDet to t_sFRWAnCodeElemDet.
    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.