Data Provider Subgroup statement

Official Content

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. 

Syntax 

<subgroupStatement>::=   subgroup <subgroupName>( [<ParameterList>)
           <mainGroupList>
  endsubgroup

where:

<mainGroupList> ::= <group> | <mainGroupList> <group>

is a list of subsequent group statements.

The subgroups should be defined all together at the end of the Data Provider source, that is: after all the group statements.  

Example

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 we 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 
}

We 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.






Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.