SAP Named Collection 

Named collections are derived from SAP Standard Collections and may always work with strings as indexing parameters for methods like Item, Insert, Remove and UnLoad. Objects within a named collection always have a Name property which stores the indexing name. The name describing an object in a named collection does not have to be unique. If a name is used frequently, Item, Insert, Remove and UnLoad always use the first object with the given name.

Further features of named collections are dynamic properties, created as a result of the objects’ names. Instead of invoking the Item property, an object may also be returned if the name of the object is used as property.

Dim oObj as Object

‘ Add a new empty object

Set oObj = NamedCollectionObject.Add ()

‘ Assign name

oObj.Name = " ItemB "

‘ Add object an pass name as parameter.

Set oObj = NamedCollectionObject.Add ( " ItemC " )

‘ Insert object in prior to object " ItemB "

Set oObj = NamedCollectionObject.Insert ( " ItemB " , " ItemA " )

 

‘ Accessing the object

‘ Retrieve second object through index

Set oObj = NamedCollectionObject.Item(2)

‘ Retrieve second object through name

Set oObj = NamedCollectionObject.Item( " ItemB " )

‘ Retrieve second object through dynamic property

Set oObj = NamedCollectionObject.ItemB

For more information about collection objects, see Using Collection Objects.