project QadFinancials > class BBusinessRelation > 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
BBusinessRelationinputdatasetclass dataset
oiReturnStatusoutputintegererror status


program code (program/bbusinessrelation.p)

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

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

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

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

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

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

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

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

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

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