project QadFinancials > class BCInvoice > 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
BCInvoiceinputdatasetclass dataset
oiReturnStatusoutputintegererror status


program code (program/bcinvoice.p)

    for each t_sCInvoice:
        if t_sCInvoice.tc_Status = "D":U
        then do:
            run gipr_Delete_sCInvoiceBank (input t_sCInvoice.tc_Rowid).
            run gipr_Delete_sCInvoiceMovement (input t_sCInvoice.tc_Rowid).
            run gipr_Delete_sCInvoicePO (input t_sCInvoice.tc_Rowid).
            run gipr_Delete_sCInvoicePosting (input t_sCInvoice.tc_Rowid).
            run gipr_Delete_sCInvoiceStage (input t_sCInvoice.tc_Rowid).
            run gipr_Delete_sCInvoiceVat (input t_sCInvoice.tc_Rowid).
            run gipr_Delete_sCInvoiceWHT (input t_sCInvoice.tc_Rowid).
        end.
        find first tFcRowidConvert where
                   tFcRowidConvert.tcFcOldRowid = t_sCInvoice.tc_Rowid and
                   tFcRowidConvert.tlFcOk       no-error.
        if available tFcRowidConvert
        then assign t_sCInvoice.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
    end.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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