Creating a new partition detail

The following code shows the creation of a policy with detail values:

USING OpenEdge.DataAdmin.Error.DataAdminErrorHandler.
USING OpenEdge.DataAdmin.IPartitionPolicy.
USING OpenEdge.DataAdmin.IPartitionPolicyDetail.
USING OpenEdge.DataAdmin.ITable.
USING OpenEdge.DataAdmin.DataAdminService.

define variable policy as IPartitionPolicy no-undo. 
define variable detail as IPartitionPolicyDetail no-undo. 
define variable tbl as ITable no-undo. 
define variable errorHandler as DataAdminErrorHandler no-undo.
define variable service as DataAdminService no-undo.

service = new DataAdminService(LDBNAME(1)).

assign
    /* get a new empty policy from the service  */
    policy = Service:NewPartitionPolicy("OrderDate")
    policy:Description = "Orderline date partition"
    policy:DefaultDataArea = service:GetArea("Customer/Order Area")
    policy:DefaultIndexArea = service:GetArea("Order Index Area")
    policy:DefaultLobArea = service:GetArea("Customer/Order Area")
    policy:DefaultAllocation = "IMMEDIATE"
    /* get the table from the service */
    Tbl = service:GetTable("Order")  
    policy:Table = tbl
    policy:HasRange = YES.
    
/* add the field to the policy - found on the table */
policy:Fields:Add(tbl:Fields:Find("Order-Date")).

/* get a new empty policy detail from the service  */
detail = Service:NewPartitionPolicyDetail("Data2012").    
detail:SetValue(12/31/2012).
policy:Details:Add(detail).

/* get another empty policy detail from the service  */
detail = Service:NewPartitionPolicyDetail("Data2013").
detail:SetValue(12/31/2013).
policy:Details:Add(detail).

service:CreatePartitionPolicy(policy).   

catch e as Progress.Lang.Error :
     errorHandler = new DataAdminErrorHandler().
     errorHandler:Error(e).      
 end catch.
finally:
     delete object service no-error.     
 end finally.

The above example partitions the Order table on order date, sets the HasRange property to TRUE, and adds two ranges so that all data less than the specified values are added to the corresponding partitions. This example assumes there is a table called Order, with no records, and an index on a field named Order-Date.