It is one of the components of the Data Provider output-based declarative language. A subgroup is the declarative equivalent of a subroutine in a procedural language. Once declared, could be invoked instead of an element statement by means of a Subgroup element insertion.
subgroup <subgroupName>([<parm1>,…,<parmN>])
<mainGroupList>
endsubgroup
View Syntax conventions
Where:
subgroupName
It is the name of the subgroup.
parm1, …, parmN
It is a list of variables that will be used as a parameter for the subgroup.
mainGroupList
Is a list of subsequent Group statements.
Note: The subgroups should be defined all together at the end of the Data Provider source, that is: after all the
Group statements.
Customers
{
Customer
{
Code = CustomerId
Name = CustomerName
AddressGroup.Insert(CustomerAddress, CityName)
}
}
SubGroup AddressGroup(&Street, &City)
Address
{
Street = &Street
City = &City
}
EndSubGroup
A Subgroup can be internal (like this one) or external (defined as another Data Provider). For example, if you have an 'Address' SDT with Street and City as its members, and a Data Provider 'GetAddress' :
Output: Address
Collection: False
Rules: parm( &Street, &City );
Address
{
Street = &street
City = &city
}
You can declare the previous 'GetCustomers' Data Provider like:
Customers
{
Customer
{
Code = CustomerId
Name = CustomerName
Address = GetAddress( CustomerAddress, CityName )
}
}
The Address member of the 'Customer' output SDT must have the 'Address' SDT data type (the output of 'GetAddress'). Otherwise, an error will appear.
Note the difference between 'inserting' a subgroup and 'assigning' an element calling a Data Provider.
One interesting use of this is the recursive one.