The following sample shows the logical flow of a data load execution and how Ecosystem Manager API calls are used.
#include <tmsmapi.h> /* TMSM initialization */ TM_Context* pCtx=TM_Init(); // initialize Messaging interface MSM_UOW* pUOW=MSM_OCreateUOW(pCtx); // let API generate a unit of work ... /* after logon processed */ MSM_WSendStart( pCtx, pUOW, szTDPID, TMSM_WRESOURCETYPE_FLOAD, TMSM_WRESOURCETYPE_FLOAD,L"Logon"); /* verify success */ if (MSM_OGetLastError(pCtx != ERROR_OK){ /* Handle error situation */ fwprintf(stderr, L"Start failed with error code %d", MSM_OGetLastError(pCtx)); fwprintf(stderr, L"Failed to send start %ls", MSM_WGetLastErrorMessage(pCtx)); /* Clear erorr information */ MSM_OClearLastError(pCtx); } ... /* Acquisition phase finished */ MSM_WSendStep( pCtx, // TM Context pUOW, // Unit of Work szTDPID, // TDPID of target load system TMSM_WRESOURCETYPE_FLOAD,// Default name for the TMSM Process TMSM_WRESOURCETYPE_FLOAD,// TMSM Process Type ( UTILITY NAME) L"AcquisitionComplete", // Unique Step Identifier TMSM_WDMLMODE_INSERT, // DML affecting the table NULL, // Database names where the affected table resides 0, // Number of databases entered NULL, // Names of the affected table 0, // Number of tables affected NULL, // Number of affected rows 0 // Number of row counts affected ); /* verify success */ if (MSM_OGetLastError(pCtx != ERROR_OK){ /* Handle error situation */ fwprintf(stderr, L"Send failed with error code %d", MSM_OGetLastError(pCtx)); fwprintf(stderr, L"Failed to send step %ls", MSM_WGetLastErrorMessage(pCtx)); /* Clear erorr information */ MSM_OClearLastError(pCtx); } if (acquisitionFailed){ MSM_WSendAlert(pCtx, // TM Context pUOW, // Unit of Work szTDPID, // TDPID of target load system TMSM_WRESOURCETYPE_FLOAD,// Default name for the TMSM Process TMSM_WRESOURCETYPE_FLOAD,// TMSM Process Type ( UTILITY NAME) L"AcquisitionComplete", // Unique Step Identifier 100000+nErrorCode , // TMSM AlertCode TMSM_SEVERITY_CRITICAL, // TMSM Severity szErrorMsg // Error Message ); /* verify success */ if (MSM_OGetLastError(pCtx != ERROR_OK){ /* Handle error situation */ fwprintf(stderr, L"Alert failed with error code %d", MSM_OGetLastError(pCtx)); fwprintf(stderr, L"Failed to send alert %ls", MSM_WGetLastErrorMessage(pCtx)); /* Clear erorr information */ MSM_OClearLastError(pCtx); } } /* Apply phase completed (table has been loaded) */ MSM_WSendStep( pCtx, // TM Context pUOW, // Unit of Work szTDPID, // TDPID of target load system TMSM_RESOURCETYPE_FLOAD, // Default name for the TMSM Process TMSM_RESOURCETYPE_FLOAD, // TMSM Process Type ( UTILITY NAME) L"ApplyComplete", // Unique Step Identifier szDMLModes, // DML affecting the table 1, // Number of DML Mode(s) szDatabaseNames, // Database(s) where the affected table resides 1, // Number of Database Names szTableNames, // Name of the affected table(2) 1, // Number of tables lActivityCounts // List of number(s) of affected rows 1, // Number of row counts ); /* verify success */ if (MSM_OGetLastError(pCtx != ERROR_OK){ /* Handle error situation */ fwprintf(stderr, L"Send failed with error code %d", MSM_OGetLastError(pCtx)); fwprintf(stderr, L"Failed to send step %ls", MSM_WGetLastErrorMessage(pCtx)); /* Clear erorr information */ MSM_OClearLastError(pCtx); } ... if (applyFailed){ MSM_WSendAlert(pCtx, // TM Context pUOW, // Unit of Work szTDPID, // TDPID of target load system TMSM_WRESOURCETYPE_FLOAD, // Default name for the TMSM Process TMSM_WRESOURCETYPE_FLOAD, // TMSM Process Type ( UTILITY NAME) L"ApplyComplete", // Unique Step Identifier 100000+nErrorCode , // TMSM AlertCode TMSM_SEVERITY_CRITICAL, // TMSM Severity szErrorMsg // Error Message ); /* verify success */ if (MSM_OGetLastError(pCtx != ERROR_OK){ /* Handle error situation */ fwprintf(stderr, L"Alert failed with error code %d", MSM_OGetLastError(pCtx)); fwprintf(stderr, L"Failed to send alert %ls", MSM_WGetLastErrorMessage(pCtx)); /* Clear erorr information */ MSM_OClearLastError(pCtx); } } /* end of process */ MSM_WSendEnd( pCtx, // TM Context pUOW, // Unit of Work szTDPID, // TDPID of target load system TMSM_WRESOURCETYPE_FLOAD, // Default name for the TMSM Process TMSM_WRESOURCETYPE_FLOAD, // TMSM Process Type ( UTILITY NAME) L"EndLoading", // Unique Step Identifier lActivityCount // Total Number of affected rows ); /* verify success */ if (MSM_OGetLastError(pCtx != ERROR_OK){ /* Handle error situation */ fwprintf(stderr, L"End failed with error code %d", MSM_OGetLastError(pCtx)); fwprintf(stderr, L"Failed to end step %ls", MSM_WGetLastErrorMessage(pCtx)); /* Clear erorr information */ MSM_OClearLastError(pCtx); } ... /* do TMSM API cleanup */ MSM_FreeUOW(pUOW); TM_Free(pCtx);