The following code samples demonstrate the use of the CDCTrackingHelper class in ETL programs.

Parsing potentially split change table rows for the Order change table

USING OpenEdge.DataAdmin.Util.CDCOperation.
USING OpenEdge.DataAdmin.Util.CDCTrackingHelper.

DEF VAR hbuf   AS HANDLE NO-UNDO.
DEF VAR hbuf2  AS HANDLE NO-UNDO.
DEF VAR ohelper AS CDCTrackingHelper NO-UNDO.

/* Get a CDCTrackingHelper for the Order table, using the default buffer
 * of the _Cdc-Change-Tracking table */
ohelper = NEW CDCTrackingHelper("Order", BUFFER _Cdc-Change-Tracking:Handle).

/* get a buffer to help process any split records */
hbuf = ohelper:CreateChangeBuffer().
/* create a new buffer for the BEFORE change data */
CREATE BUFFER hbuf2 FOR TABLE hbuf. 

/* Iterate through the change table rows */
FOR EACH _Cdc-Change-Tracking WHERE
    _Cdc-Change-Tracking._Source-Table-Number = ohelper:SourceTableNumber
    /* Rows are sorted in _Change-Sequence order */ :

    /* Is this an update row? */
    IF (ohelper:IsUpdate()) THEN
    DO:
        /* We only want to process if the order total changed */
        IF (ohelper:FieldChanged("OrderTotal")) THEN
        DO:
            /* Get the BEFORE change table row */
            ohelper:FetchChangeRecord(hbuf2, TRUE).
            /* Get the AFTER change table row. 
             * We can use the other overload, as the _Operation in the 
             * _Cdc-Change-Tracking and change table rows is the same for
             * AFTER  */
            ohelper:FetchChangeRecord(hbuf).
            /* perform whatever logic needs to occur for the ETL */
        END.
    END.

    /* purge rows in the _Cdc-Change-Tracking and change table, 
     * we have finished with them */
    ohelper:DeleteChangeTrackingRecord().
END.
/* delete objects we created */
DELETE OBJECT hbuf2.
/* ohelper can be garbage collected */

Parsing change table row for the Order table, when it is known they do not split.

USING OpenEdge.DataAdmin.Util.CDCOperation.
USING OpenEdge.DataAdmin.Util.CDCTrackingHelper.

DEF BUFFER buf FOR CDC_Order.
DEF BUFFER buf2 FOR CDC_Order.
DEF VAR oCDCUtil AS CDCUtility NO-UNDO.
DEF VAR ohelper AS CDCTrackingHelper NO-UNDO.

/* Get a CDCTrackingHelper for the Order table, using the default buffer
 * of the _Cdc-Change-Tracking table */
ohelper = NEW CDCTrackingHelper("Order", BUFFER _Cdc-Change-Tracking:Handle).

/* Iterate through the change table rows */
FOR EACH _Cdc-Change-Tracking WHERE
    _Cdc-Change-Tracking._Source-Table-Number = ohelper:SourceTableNumber
    /* Rows are sorted in _Change-Sequence order */ :

    IF (ohelper:IsUpdate()) THEN
    DO:
        /* We only want to process if the order total changed */
        IF (ohelper:FieldChanged("OrderTotal")) THEN
        DO:
            /* Get the BEFORE change table row.
             * We are not using the convenience FetchChangeRecord
             * method, so we need to use the integer _Operation values */
            FIND FIRST buf2 WHERE 
                buf2._Change-Sequence = _Cdc-Change-Tracking._Change-Sequence AND 
                buf2._Operation = INT(CDCOperation:BeforeUpdate) NO-ERROR.
            /* Get the AFTER change table row. */
            FIND FIRST buf WHERE 
                buf._Change-Sequence = _Cdc-Change-Tracking._Change-Sequence AND 
                buf._Operation = INT(CDCOperation:AfterUpdate) NO-ERROR.
            /* perform whatever logic needs to occur for the ETL */
        END.
    END.
    /* purge rows in the _Cdc-Change-Tracking and change table, 
     * we have finished with them */
    ohelper:DeleteChangeTrackingRecord().
END.
/* ohelper can be garbage collected */