project QadFinancials > class BPosting > 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
BPostinginputdatasetclass dataset
oiReturnStatusoutputintegererror status


program code (program/bposting.p)

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

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

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

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

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

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

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

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

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

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

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

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