project BLF > class BUDCConfiguration > method AdditionalUpdates

Description

This method is part of the SetPublicTables flow.
When executed, data in the input class tables (prefix t_s) is validated and found correct, and copied into the class tables (prefix t_o).
This method can be extended to do updates that do not require a validation or that involve running business methods of other business classes. These classes should be started with ADD-TO-TRANSACTION = 'true'. Also make sure to add these classes in method StopExternalInstances.


Parameters


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/budcconfiguration.p)

<ANCESTOR-CODE>

/* Initialize */
assign vhDataset = ?
       viRowid   = 0.

/* Assemble info to send to BBusinessComponent */
for each tUDCConfig where
         tUDCConfig.tc_Status <> ""
         on error undo, throw:
    /* Initialize the dataset if necessary */
    if vhDataset = ?
    then do:
        create dataset vhDataset in widget-pool "non-persistent".
        assign vhDataset:name = "BBusinessComponentDataset".
        create temp-table vhTableComp in widget-pool "non-persistent".
        vhTableComp:add-new-field("BusComponentCode"         , "character", ?, "x(26)" , "?").
        vhTableComp:add-new-field("BusComponentLabel"        , "character", ?, "x(40)" , "?").
        vhTableComp:add-new-field("BusComponentHasCustomFlds", "logical"  , ?, "yes/no", "?").
        vhTableComp:add-new-field("BusComponentIsUserDefined", "logical"  , ?, "yes/no", "?").
        vhTableComp:add-new-field("tc_Rowid"                 , "character", ?, "x(8)"  , "").
        vhTableComp:add-new-field("tc_ParentRowid"           , "character", ?, "x(8)"  , "").
        vhTableComp:add-new-field("tc_Status"                , "character", ?, "x"     , "").
        vhTableComp:temp-table-prepare("tBusComponent").
        assign vhBufferComp = vhTableComp:default-buffer-handle.
        vhDataset:add-buffer(vhBufferComp).
        create temp-table vhTableAct in widget-pool "non-persistent".
        vhTableAct:add-new-field("BusActivityCode"       , "character", ?, "x(40)" , "?").
        vhTableAct:add-new-field("BusActivityLabel"      , "character", ?, "x(40)" , "?").
        vhTableAct:add-new-field("BusActivityIsInstDep"  , "logical"  , ?, "yes/no", "?").
        vhTableAct:add-new-field("BusActivitySequence"   , "integer"  , ?, ">>>9"  , "?").
        vhTableAct:add-new-field("BusActivityFormName"   , "character", ?, "x(40)" , "?").
        vhTableAct:add-new-field("BusActivityOpenForm"   , "logical"  , ?, "yes/no", "?").
        vhTableAct:add-new-field("BusActivityMethodName" , "character", ?, "x(200)", "?").
        vhTableAct:add-new-field("BusActivityButtonLabel", "character", ?, "x(40)" , "?").
        vhTableAct:add-new-field("tc_Rowid"              , "character", ?, "x(8)"  , "").
        vhTableAct:add-new-field("tc_ParentRowid"        , "character", ?, "x(8)"  , "").
        vhTableAct:add-new-field("tc_Status"             , "character", ?, "x"     , "").
        vhTableAct:temp-table-prepare("tBusActivity").
        assign vhBufferAct = vhTableAct:default-buffer-handle.
        vhDataset:add-buffer(vhBufferAct).
        create temp-table vhTableTrans in widget-pool "non-persistent".
        vhTableTrans:create-like(buffer tTransString:handle).
        vhTableTrans:temp-table-prepare("tTransString").
        assign vhBufferTrans = vhTableTrans:default-buffer-handle.
        vhDataset:add-buffer(vhBufferTrans).
    end.

    /* Handle deleted records */
    if tUDCConfig.tc_Status = "D"
    then do:
        vhBufferComp:buffer-create().

        assign viRowid                                                    = viRowid - 1
               vhBufferComp:buffer-field("BusComponentCode"):buffer-value = "BCustom[" + tUDCConfig.UDCConfigCode + "]"
               vhBufferComp:buffer-field("tc_Rowid"):buffer-value         = string(viRowid)
               vhBufferComp:buffer-field("tc_Status"):buffer-value        = "D".

        next.
    end.

    /* Handle new and modified records */
    if tUDCConfig.tc_Status = "C"
    then do:
        find t_iUDCConfig where
             t_iUDCConfig.tc_Rowid = tUDCConfig.tc_Rowid
             no-error.

        if not available t_iUDCConfig
        then do:
            <M-11 run SetMessage
               (input  trim(#T-12'Failed to set read response procedure on socket object.':255(998716606)t-12#) (icMessage), 
                input  '' (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E' (icType), 
                input  3 (iiSeverity), 
                input  tUDCConfig.tc_Rowid (icRowid), 
                input  'BLF-733760882':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BUDCConfiguration>
            assign oiReturnStatus = -3.
            return.
        end.
    end.

    /* Add BusComponent record */
    vhBufferComp:buffer-create().

    assign viRowid                                                    = viRowid - 1
           vhBufferComp:buffer-field("BusComponentCode"):buffer-value = "BCustom[" + tUDCConfig.UDCConfigCode + "]"
           vhBufferComp:buffer-field("tc_Rowid"):buffer-value         = string(viRowid)
           vhBufferComp:buffer-field("tc_Status"):buffer-value        = tUDCConfig.tc_Status.

    if tUDCConfig.tc_Status              = "N" or
       tUDCConfig.UDCConfigLabel <> t_iUDCConfig.UDCConfigLabel
    then assign vhBufferComp:buffer-field("BusComponentLabel"):buffer-value = tUDCConfig.UDCConfigLabel.

    if tUDCConfig.tc_Status = "N"
    then assign vhBufferComp:buffer-field("BusComponentHasCustomFlds"):buffer-value = true
                vhBufferComp:buffer-field("BusComponentIsUserDefined"):buffer-value = true.

    for each tTransString where
             tTransString.tc_ParentRowid = tUDCConfig.tc_Rowid
             on error undo, throw:
        vhBufferTrans:buffer-create().
        vhBufferTrans:buffer-copy(buffer tTransString:handle, "tiParentObject_ID,tc_ParentRowid").
        vhBufferTrans:buffer-field("tc_ParentRowid"):buffer-value = string(viRowid).
    end.
    
    /* Add BusActivity record for Create */
    if tUDCConfig.tc_Status           = "N" and
       tUDCConfig.UDCConfigHasCreate        or
       tUDCConfig.tc_Status           = "C" and
       tUDCConfig.UDCConfigHasCreate <> t_iUDCConfig.UDCConfigHasCreate
    then do:
        vhBufferAct:buffer-create().

        assign viRowid                                                  = viRowid - 1
               vhBufferAct:buffer-field("BusActivityCode"):buffer-value = "Create"
               vhBufferAct:buffer-field("tc_Rowid"):buffer-value        = string(viRowid)
               vhBufferAct:buffer-field("tc_ParentRowid"):buffer-value  = vhBufferComp:buffer-field("tc_Rowid"):buffer-value.

        if tUDCConfig.UDCConfigHasCreate
        then assign vhBufferAct:buffer-field("BusActivityLabel"):buffer-value       = "Create"
                    vhBufferAct:buffer-field("BusActivityIsInstDep"):buffer-value   = false
                    vhBufferAct:buffer-field("BusActivitySequence"):buffer-value    = 10
                    vhBufferAct:buffer-field("BusActivityFormName"):buffer-value    = "BCustom"
                    vhBufferAct:buffer-field("BusActivityOpenForm"):buffer-value    = true
                    vhBufferAct:buffer-field("BusActivityMethodName"):buffer-value  = "CREATE_ACTIVITY"
                    vhBufferAct:buffer-field("BusActivityButtonLabel"):buffer-value = ""
                    vhBufferAct:buffer-field("tc_Status"):buffer-value              = "N".
        else assign vhBufferAct:buffer-field("tc_Status"):buffer-value = "D".
    end.

    /* Add BusActivity record for View */
    if tUDCConfig.tc_Status         = "N" and
       tUDCConfig.UDCConfigHasView        or
       tUDCConfig.tc_Status         = "C" and
       tUDCConfig.UDCConfigHasView <> t_iUDCConfig.UDCConfigHasView
    then do:
        vhBufferAct:buffer-create().

        assign viRowid                                                  = viRowid - 1
               vhBufferAct:buffer-field("BusActivityCode"):buffer-value = "View"
               vhBufferAct:buffer-field("tc_Rowid"):buffer-value        = string(viRowid)
               vhBufferAct:buffer-field("tc_ParentRowid"):buffer-value  = vhBufferComp:buffer-field("tc_Rowid"):buffer-value.

        if tUDCConfig.UDCConfigHasView
        then assign vhBufferAct:buffer-field("BusActivityLabel"):buffer-value       = "View"
                    vhBufferAct:buffer-field("BusActivityIsInstDep"):buffer-value   = true
                    vhBufferAct:buffer-field("BusActivitySequence"):buffer-value    = 20
                    vhBufferAct:buffer-field("BusActivityFormName"):buffer-value    = "BCustom"
                    vhBufferAct:buffer-field("BusActivityOpenForm"):buffer-value    = true
                    vhBufferAct:buffer-field("BusActivityMethodName"):buffer-value  = "VIEW_ACTIVITY"
                    vhBufferAct:buffer-field("BusActivityButtonLabel"):buffer-value = ""
                    vhBufferAct:buffer-field("tc_Status"):buffer-value              = "N".
        else assign vhBufferAct:buffer-field("tc_Status"):buffer-value = "D".
    end.

    /* Add BusActivity record for Modify */
    if tUDCConfig.tc_Status           = "N" and
       tUDCConfig.UDCConfigHasModify        or
       tUDCConfig.tc_Status           = "C" and
       tUDCConfig.UDCConfigHasModify <> t_iUDCConfig.UDCConfigHasModify
    then do:
        vhBufferAct:buffer-create().

        assign viRowid                                                  = viRowid - 1
               vhBufferAct:buffer-field("BusActivityCode"):buffer-value = "Modify"
               vhBufferAct:buffer-field("tc_Rowid"):buffer-value        = string(viRowid)
               vhBufferAct:buffer-field("tc_ParentRowid"):buffer-value  = vhBufferComp:buffer-field("tc_Rowid"):buffer-value.

        if tUDCConfig.UDCConfigHasModify
        then assign vhBufferAct:buffer-field("BusActivityLabel"):buffer-value       = "Modify"
                    vhBufferAct:buffer-field("BusActivityIsInstDep"):buffer-value   = true
                    vhBufferAct:buffer-field("BusActivitySequence"):buffer-value    = 30
                    vhBufferAct:buffer-field("BusActivityFormName"):buffer-value    = "BCustom"
                    vhBufferAct:buffer-field("BusActivityOpenForm"):buffer-value    = true
                    vhBufferAct:buffer-field("BusActivityMethodName"):buffer-value  = "MODIFY_ACTIVITY"
                    vhBufferAct:buffer-field("BusActivityButtonLabel"):buffer-value = ""
                    vhBufferAct:buffer-field("tc_Status"):buffer-value              = "N".
        else assign vhBufferAct:buffer-field("tc_Status"):buffer-value = "D".
    end.

    /* Add BusActivity record for Delete */
    if tUDCConfig.tc_Status           = "N" and
       tUDCConfig.UDCConfigHasDelete        or
       tUDCConfig.tc_Status           = "C" and
       tUDCConfig.UDCConfigHasDelete <> t_iUDCConfig.UDCConfigHasDelete
    then do:
        vhBufferAct:buffer-create().

        assign viRowid                                                  = viRowid - 1
               vhBufferAct:buffer-field("BusActivityCode"):buffer-value = "Delete"
               vhBufferAct:buffer-field("tc_Rowid"):buffer-value        = string(viRowid)
               vhBufferAct:buffer-field("tc_ParentRowid"):buffer-value  = vhBufferComp:buffer-field("tc_Rowid"):buffer-value.

        if tUDCConfig.UDCConfigHasDelete
        then assign vhBufferAct:buffer-field("BusActivityLabel"):buffer-value       = "Delete"
                    vhBufferAct:buffer-field("BusActivityIsInstDep"):buffer-value   = true
                    vhBufferAct:buffer-field("BusActivitySequence"):buffer-value    = 40
                    vhBufferAct:buffer-field("BusActivityFormName"):buffer-value    = "BCustom"
                    vhBufferAct:buffer-field("BusActivityOpenForm"):buffer-value    = true
                    vhBufferAct:buffer-field("BusActivityMethodName"):buffer-value  = "DELETE_ACTIVITY"
                    vhBufferAct:buffer-field("BusActivityButtonLabel"):buffer-value = "Delete"
                    vhBufferAct:buffer-field("tc_Status"):buffer-value              = "N".
        else assign vhBufferAct:buffer-field("tc_Status"):buffer-value = "D".
    end.

    /* Add BusActivity record for Maintain */
    if tUDCConfig.tc_Status             = "N" and
       tUDCConfig.UDCConfigHasMaintain        or
       tUDCConfig.tc_Status             = "C" and
       tUDCConfig.UDCConfigHasMaintain <> t_iUDCConfig.UDCConfigHasMaintain
    then do:
        vhBufferAct:buffer-create().

        assign viRowid                                                  = viRowid - 1
               vhBufferAct:buffer-field("BusActivityCode"):buffer-value = "Maintain"
               vhBufferAct:buffer-field("tc_Rowid"):buffer-value        = string(viRowid)
               vhBufferAct:buffer-field("tc_ParentRowid"):buffer-value  = vhBufferComp:buffer-field("tc_Rowid"):buffer-value.

        if tUDCConfig.UDCConfigHasMaintain
        then assign vhBufferAct:buffer-field("BusActivityLabel"):buffer-value       = "Maintain"
                    vhBufferAct:buffer-field("BusActivityIsInstDep"):buffer-value   = false
                    vhBufferAct:buffer-field("BusActivitySequence"):buffer-value    = 50
                    vhBufferAct:buffer-field("BusActivityFormName"):buffer-value    = "BCustom"
                    vhBufferAct:buffer-field("BusActivityOpenForm"):buffer-value    = true
                    vhBufferAct:buffer-field("BusActivityMethodName"):buffer-value  = "MAINTAIN_ACTIVITY"
                    vhBufferAct:buffer-field("BusActivityButtonLabel"):buffer-value = ""
                    vhBufferAct:buffer-field("tc_Status"):buffer-value              = "N".
        else assign vhBufferAct:buffer-field("tc_Status"):buffer-value = "D".
    end.
end.

/* Send info to BBusinessComponent */
if vhDataset <> ?
then do:
    if viBBusinessComponent5ID = 0 or
       viBBusinessComponent5ID = ?
    then do:
        <I-1 {bFcStartAndOpenInstance
             &ADD-TO-TRANSACTION   = "true"
             &CLASS                = "BBusinessComponent"}>

        assign vlBBusinessComponentStarted = true.
    end.
    else do:
        <I-4 {bFcOpenInstance
             &CLASS           = "BBusinessComponent"}>
    end.

    <M-9 run PartialSetSTables
       (input  vhDataset by-reference (izDatasetHandle), 
        input  true (ilIsPartialUpdate), 
        output viLocalReturnStatus (oiReturnStatus)) in BBusinessComponent>

    delete object vhDataset.
    assign vhDataset = ?.

    if viLocalReturnStatus >= 0
    then do:
        create dataset vhDataset in widget-pool "non-persistent".

        <M-10 run MaintainByDatasetWithOutput
           (input  'SAVE' (icAction), 
            input  false (ilReturnDataset), 
            input  true (ilPartialUpdate), 
            input  '' (icPartialUpdateExceptionList), 
            output vpPrimaryKey (opPrimaryKey), 
            output vpRowid (opRowid), 
            output viDraftInstance (oiDraftInstance), 
            output vcPrimaryKeyName (ocPrimaryKeyName), 
            output vhDataset by-reference (ozObjectRepresentation), 
            output viLocalReturnStatus (oiReturnStatus)) in BBusinessComponent>
    end.

    <I-3 {bFcCloseInstance
         &CLASS           = "BBusinessComponent"}>

    if viLocalReturnStatus <> 0
    then assign oiReturnStatus = viLocalReturnStatus.

    if viLocalReturnStatus < 0
    then do:
        <M-5 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BUDCConfiguration>
        return.
    end.
end.

finally:
    if vhDataset <> ? and
       valid-handle(vhDataset)
    then delete object vhDataset.

    if vhTableComp <> ? and
       valid-handle(vhTableComp)
    then delete object vhTableComp.

    if vhTableAct <> ? and
       valid-handle(vhTableAct)
    then delete object vhTableAct.

    if vhTableTrans <> ? and
       valid-handle(vhTableTrans)
    then delete object vhTableTrans.
end finally.