The MERGELIST() function combines two field mark delimited sorted lists, returning the intersection, union or difference as a result list.
MERGELIST(list1, list2, modes)
The MERGELIST() function provides an efficient way to merge two field mark delimited sorted lists. It is intended for use with lists of record ids such as select lists but can combine other lists where the elements are no more than 255 characters.
The modes argument must be one of the following token that are defined in the SYSCOM KEYS.H include record:
In addition, one of the following tokens may be added to the modes value to indicate how the data in list1 and list2 is sorted:
For more information on the different sort modes, see the SORT() function. Note that the sort mode tokens identify how the data in list1 and list2 is sorted and also how the result list will be sorted. The result of using MERGELIST() where the input lists are not sorted in the manner specified is indeterminate.
SELECTINDEXV 'CUSTNO', CUSTOMER FROM ORDERS.F TO CUST.ORDERS
SELECTINDEXV 'MONTH', ORDER.MONTH FROM ORDERS.F TO MONTHLY.ORDERS
JULY.ORDERS = MERGELIST(CUST.ORDERS, MONTHLY.ORDERS, ML$INTER)
The above example extracts data from two indices; one for all orders placed by a specific customer, the other for all orders placed in a specific month. It then uses MERGELIST() to combine these to give a list of all orders placed by that customer in the given month.