Function Promoted_Write_Record_Action(Action, Reserved1, FSList, Handle, Name, FMC, Record, Status, OrigRecord, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10)
/***********************************************************************************************************************

    This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
    permission from SRP Computer Solutions, Inc.

    Name        :   Promoted_Write_Record_Action

    Description :   Promoted (e.g. generic) handler for WRITE_RECORD action.

    Notes       :   Typically called by BASE_MFS

    Parameters  :
        Action          [in] -- Name of the action to be taken.
        Reserved1       [in] -- Currently being reserved.
        FSList          [in] -- The list of MFSs and the BFS name for the current file or volume. This is an @SVM
                                delimited array, with the current MFS name as the first value in the array, and the BFS
                                name as the last value. Normally set by a calling MFS.
        Handle          [in] -- The file handle of the file or media map being accessed. Note, this does contain the
                                entire handle structure that the Basic+ Open statement would provide. Normally set by a
                                calling MFS.
        Name            [in] -- The name (key) of the record or file being accessed. Normally set by a calling MFS.
        FMC             [in] -- Various functions. Normally set by a calling MFS.
        Record          [in] -- The entire record (for record-oriented functions) or a newly-created handle (for
                                "get handle" functions). Normally set by a calling MFS.
        Status      [in/out] -- Indicator of the success or failure of an action. Normally set by the calling MFS but
                                for some actions can be set by the action handler to indicate failure.
        OrigRecord      [in] -- Original content of the record being processed by the current action. This is
                                automatically being assigned by the WRITE_RECORD and DELETE_RECORD actions within
                                BASE_MFS.
        Param1-10   [in/out] -- Additional request parameter holders
        ActionFlow     [out] -- Used to control the action chain (see the ACTION_SETUP insert for more information.)
                                Can also be used to return a special value, such as the results of the CalcField
                                method.

    History     :   (Date, Initials, Notes)
        03/07/20    dmb     Original programmer.
        09/09/20    dmb     Update the Post gosub logic to call the IsReplicationTable and IsTableAllowedToQueue
                            services before calling the AddToReplicationQueueTable service.

***********************************************************************************************************************/

#pragma precomp SRP_PreCompiler

$insert LOGICAL
$insert FILE.SYSTEM.EQUATES
$insert ACTION_SETUP

Declare function    Replication_Services, Environment_Services, Logging_Services
Declare subroutine  Replication_Services, Environment_Services, Logging_Services

If Action[-3, 3] EQ "PRE" then
	// This is a pre-BFS handler promoted action.
	GoSub Pre
end else
	// This is a post-BFS handler promoted action.
	GoSub Post
end

// If ActionFlow hasn't already been assigned then assume it should continue
If Assigned(ActionFlow) else ActionFlow = ACTION_CONTINUE$

Return ActionFlow


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actions
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//----------------------------------------------------------------------------------------------------------------------
// Pre
//
// All pre-BFS action handler logic.
//----------------------------------------------------------------------------------------------------------------------
Pre:

return


//----------------------------------------------------------------------------------------------------------------------
// Post
//
// All post-BFS action handler logic.
//----------------------------------------------------------------------------------------------------------------------
Post:

    If Replication_Services('IsReplicationTable', Tablename, AccountName) then
        If Replication_Services('IsTableAllowedToQueue', Tablename, AccountName) then
            TransactionID = 'WRITE' : @FM : AccountName : @FM : Volume : @FM : Tablename : @FM : Name
            Replication_Services('AddToReplicationQueueTable', TransactionID)
        end
    end
    
return
