project QadFinancials > class BAPMatching > 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
BAPMatchinginputdatasetclass dataset
oiReturnStatusoutputintegererror status


program code (program/bapmatching.p)

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

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

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

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

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

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

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

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

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

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