using OpenEdge.DataAdmin.* from propath.
define variable service as DataAdminService no-undo. define variable myCdcTablePolicy as ICdcTablePolicy no-undo. define variable myCdcFieldPolicy as ICdcFieldPolicy no-undo. define variable tbl as ITable no-undo. define variable tablePolicySet as ICdcTablePolicySet no-undo. service = new DataAdminService(ldbname(1)). /* this is used to create collection of policies */ tablePolicySet = service:NewCdcTablePolicies(). myCdcTablePolicy = service:newCdcTablePolicy("ItemQuantity"). tbl = service:GetTable("Item","PUB"). ASSIGN myCdcTablePolicy:Table = tbl myCdcTablePolicy:Description = "Records item quantity changes" myCdcTablePolicy:DataArea = service:GetArea("customer index area") myCdcTablePolicy:IndexArea = service:GetArea("customer index area") myCdcTablePolicy:Level = CdcTablePolicyLevelEnum:Medium myCdcTablePolicy:IdentifyingField = YES myCdcTablePolicy:ChangeTableOwner = "PUB" myCdcTablePolicy:EncryptPolicy = NO myCdcTablePolicy:State = CdcTablePolicyStateEnum:inActive. . /* identifying field ItemNum */ myCdcFieldPolicy = service:NewCdcFieldPolicy(). myCdcTablePolicy:FieldPolicies:Add(myCdcFieldpolicy). myCdcFieldPolicy:Field = tbl:Fields:Find("Item-Num"). myCdcFieldPolicy:IdentifyingField = 1. /* Track OnHand field */ myCdcFieldPolicy = service:NewCdcFieldPolicy(). myCdcTablePolicy:FieldPolicies:Add(myCdcFieldpolicy). myCdcFieldPolicy:Field = tbl:Fields:Find("On-Hand"). /* add policy to the collection */ tablePolicySet:Add(myCdcTablePolicy). /* create a CDC policy for the orderline table */ myCdcTablePolicy = service:newCdcTablePolicy("OrderlineQuantity"). tbl = service:GetTable("Order-Line","PUB"). ASSIGN myCdcTablePolicy:Table = tbl myCdcTablePolicy:Description = "Records ordered items" myCdcTablePolicy:DataArea = service:GetArea("customer index area") myCdcTablePolicy:IndexArea = service:GetArea("customer index area") myCdcTablePolicy:Level = CdcTablePolicyLevelEnum:Medium myCdcTablePolicy:IdentifyingField = YES myCdcTablePolicy:ChangeTableOwner = "PUB" myCdcTablePolicy:EncryptPolicy = NO myCdcTablePolicy:State = CdcTablePolicyStateEnum:inActive. . /* identifying field ItemNum */ myCdcFieldPolicy = service:NewCdcFieldPolicy(). myCdcTablePolicy:FieldPolicies:Add(myCdcFieldpolicy). myCdcFieldPolicy:Field = tbl:Fields:Find("Item-Num"). myCdcFieldPolicy:IdentifyingField = 1. /* Track Qty field */ myCdcFieldPolicy = service:NewCdcFieldPolicy(). myCdcTablePolicy:FieldPolicies:Add(myCdcFieldpolicy). myCdcFieldPolicy:Field = tbl:Fields:Find("Qty"). tablePolicySet:Add(myCdcTablePolicy). /* This create method creates the collection of policies */ service:CreateCdcTablePolicies(tablePolicyset). |