| **Navigation:**  [[templates.htm|Templates]] > Guide to all Templates > Extension Templates >====== ReportChildFiles ====== | [[tplextensionrecordvalidation.htm|{{btn_prev_n.gif|Previous page}}]][[templates.htm|{{btn_home_n.gif|Return to chapter overview}}]][[runcommandlineproc.htm|{{btn_next_n.gif|Next page}}]] | | || The ReportChildFiles template adds functionality to Process and Report procedures. This extension template provides a simpler, more efficient, more controllable alternative to setting a chain of related files in the Data / Tables Pad and having the Report or Process template produce a single multi-tiered VIEW. The ReportChildFiles template lets you name only the primary file and any lookup files in your procedure's **Data / Tables Pad**. The template generates code to read (and optionally print a separate DETAIL for) the related child-file records for each primary file record. We recommend the ReportChildFiles template for the typical invoice headers/invoice lines scenario. **Multi-tiered View** Suppose you have an invoice header file and an invoice detail file. You want to print out a header and then a line for each detail. This is somewhat tricky to do with a single view and there are some limitations and inefficiencies with this approach. You must populate each header (parent) file field into a group HEADER and each detail (child) field into a DETAIL. The limitation is there are no events and no embed points to use when the parent record prints (because it is simply a group break). The inefficiency is that additional GETs are done on parent file lookups for every child record even though the parent record is unchanged. Plus, for SQL you must use a left outer join (inefficient) to force parent headers to print when there are no associated detail lines. **ReportChildFiles** With the ReportChildFiles template you can simply populate the header (parent) as the primary file with its own DETAIL, then populate a second DETAIL for the detail (child) file. The primary view is then read record-by-record (lookups done only once for each parent record) and the child view is range-limited on the parent file linking fields. The Process Manager Method TakeRecord embed point provides an access point for //both //parent and child records. [[takerecord a virtual to process each report record .htm|ProcessClass.TakeRecord]] is called for each record (parent or child), and [[childread child record read .htm|ProcessClass.ChildRead]] indicates which file/record is active. See //ProcessClass //for more information. **Using the ReportChildFiles Template** The ReportChildFiles template provides the following options. **Parent File** Type the label of the parent file, or press the ellipsis button (...) to select the parent file from the **Select Table** dialog. **Detail** For Report procedures, select the USE attribute (field equate label) of the REPORT DETAIL structure to print for each child record. {{tipbox.jpg|TipBox.jpg}} The Detail drop-down list shows DETAIL structures with USE attributes, so populate the DETAIL first, and add a USE attribute. **Data / Tables Pad <;To Do>** Insert the //child //file to process for each parent file record. **Classes Tab** Use the Classes tab to override the global ViewManager setting. See //Template Overview--[[classes tab.htm|Classes Tab Options]]--Global// and //Local//.