D365FFO – AX – SET Class

Set consist of a data set that contains values of the same type, where value is unique.

A Set is alway sorted on the value.


How to use[edit]


<xpp> Set s = new Set(Types::STRING); </xpp>

Insert a value[edit]

<xpp> s.add(“Wassini”); s.add(“Eric”); </xpp>

Exists value[edit]

To see if a value already is added, use the in method: <xpp> if (s.in(“Wassini”))

  print "Yes!";


  print "No!";


Getting values[edit]

There are several ways to get the values in the set.

  1. Using a SetIterator
  2. Using a SetEnumerator


The SetIterator loops throug the complete set:

<xpp> SetIterator si;

si = new SetIterator(s);

while (si.more()) {

 print si.value();

} </xpp>


SetEnumerator class is like SetIterator class, but does not allows the deletion of elements during enumeration and SetIterator does. <xpp> SetEnumerator se=s.getEnumerator();

while (se.moveNext()) {

 print se.current();

} </xpp>

Removing values[edit]

Just use the remove method to remove the active value.

<xpp> s.remove(“Wassini”); </xpp>

Other methods[edit]

<xpp> // Get number of elements: print s.elements();

// Determines whether the set is empty: print s.empty();

// Get the type of the values print s.typeId();

// Get a description of the type of the elements: print s.definitionString();

// Dump the whole set as a string: print s.toString(); </xpp>

Passing across tiers[edit]

The Set can be passed across tiers by converting it to a container.

The pack method converts it to a container: <xpp> container packedSet = s.pack(); </xpp> To convert the packed container back to a Set, call the static create method of the Set class: <xpp> Set s = Set:create(packedSet); </xpp>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s