Reporting : Native reporting system : How to use subreports : Example 1: 1-level main with 1-level subreport
  
Example 1: 1-level main with 1-level subreport
Here is an example report on DoDAF2 Need Lines showing source and target without using subreports, as produced using the Report designer:
REPORT "Multi-level, no subreports: Need Line"
ID 22309
{
SETTING { DECIMALSEPARATOR "." }
SETTING { LISTSEPARATOR "," }
SETTING { MEASUREMENT METRIC }
SETTING { PAGESIZE -1", 0.00 }
SETTING { REPORTFORMAT 20 }
SETTING { EXTRACTFILE "test" }
SETTING { STYLESHEETFILE "Reports\StyleSht\default.xsl" }

TABULAR 1
{
SELECT "Name" LEGEND "Source"
WHERE Class = Definition
ORDERBY "Name"
JOIN
WHERE REFERENCEDBY = "performerSource"
JOIN
SELECT "Name" LEGEND "Need Line"
WHERE Class = Definition
WHERE "Type Number" = 1402
ORDERBY "Name"
JOIN
WHERE REFERENCES = "performerTarget"
JOIN
SELECT "Name" LEGEND "Target"
WHERE Class = Definition
ORDERBY "Name"
}
}
Note The 2nd row, the source is still ov-02_perf1.
Using subreports we have, minimally:
REPORT "main: 1 level with 2 subs (1 level, 1 level)"
ID 52510
{
FONT "Font4" { NAME "Courier" HEIGHT 12 }
SETTING { DECIMALSEPARATOR "." }
SETTING { LISTSEPARATOR "," }
SETTING { MEASUREMENT ENGLISH }
SETTING { PAGESIZE -1", 0.00 }
SETTING { HEADER 1 "OV-03 Need Line" }

TABULAR 1
{
SELECT "Name" LEGEND "Need Line"
WHERE Class = Definition
WHERE "Type Number" = 1402 REM "Need Line"
ORDERBY "Name"
SUBREPORT "Subreport: OV-03 Need Lines Working - PerformerSource" { }
SUBREPORT "Subreport: OV-03 Need Lines Working - PerformerTarget" { }
}
}
REPORT "Subreport: OV-03 Need Lines Working - PerformerSource"
ID 52514
{
FONT "Font4" { NAME "Courier" HEIGHT 12 }
SETTING { DECIMALSEPARATOR "." }
SETTING { LISTSEPARATOR "," }
SETTING { MEASUREMENT ENGLISH }
SETTING { PAGESIZE -1", 0.00 }

TABULAR 1
{
ORDERBY "Name"

JOIN
WHERE REFERENCES = "performerSource"
JOIN

SELECT "Name" LEGEND "Performer Source" LEGENDFONT Font4, "Type" LEGEND "Performer Type"
WHERE Class = Definition
WHERE "Type Number" = 1372, 1373, 1374, 1367, 1375, 1376, 1377 REM "Performer Source"
ORDERBY "Name"
}
}
REPORT "Subreport: OV-03 Need Lines Working - PerformerTarget"
ID 52514
{
FONT "Font4" { NAME "Courier" HEIGHT 12 }
SETTING { DECIMALSEPARATOR "." }
SETTING { LISTSEPARATOR "," }
SETTING { MEASUREMENT ENGLISH }
SETTING { PAGESIZE -1", 0.00 }

TABULAR 1
{
ORDERBY "Name"

JOIN
WHERE REFERENCES = "performerTarget"
JOIN

SELECT "Name" LEGEND "Performer Target" LEGENDFONT Font4, "Type" LEGEND "Performer Type"
WHERE Class = Definition
WHERE "Type Number" = 1372, 1373, 1374, 1367, 1375, 1376, 1377 REM "Performer Target"
ORDERBY "Name"
}
}
Note The difference in column sequence, and in this case ov-02_NL3 has no source reference.
Related topics
Report specification requirements
Example 2: Multi-level main with 1-Level subreport
Example 3: 1-level main with multi-level subreport
Example 4: Multi-level main with multi-level subreport
Example 5: Using subreports at multiple levels
Example 6: Pass DDID by parameter
Example 7: Subreport by property and class, type restriction
Report output differences
Sample subreport files
Parent topic
How to use subreports