Supplying Master Data as Variables

In the case of an order with the relevant order details, it could be desirable to offer the "master" data, i.e. in this example the data of the table orders, as variables. So the addressee could e.g. be displayed in a text object and the order details in a table object. Therefore, at the root level of the table object you need to have access to the sub-tables of the master table. In order to achieve this, call LlDbSetMasterTable(). The necessary calls are

LlDbAddTable(hJob, "Orders", "");
LlDbAddTable(hJob, "OrderDetails", "");
LlDbAddTableRelation(hJob, "OrderDetails", "Orders",
       "Orders2OrderDetails", NULL);
LlDbSetMasterTable(hJob, "Orders");

The print loop is analogous to the description above, but you have to make the appropriate child table available on the top level (see chapter Multiple Independent Tables on the Same Level):

<repeat>
{
       <get current table name>
                (LlPrintDbGetCurrentTable)
       <get current sorting>
                (LlPrintDbGetCurrentTableSortOrder)
       <get current relation>
                (LlPrintDbGetCurrentTableRelation)
       <if relation empty>
                <generate an appropriate DataTable object>
       <else>
                <generate an appropriate child DataTable object>
       <Ret = PrintTable(DataTable)>
}
<until Ret <> LL_WRN_TABLECHANGE>

<close printing>
       (LlPrintEnd)