The "Subfunctions" screen registers and changes subfunctions. Subfunctions compose reports from several report elements, such as the front page, the general conditions and a task overview. A subfunction can be set for each report function, for example for a report that can be requested through the user interface. This is especially possible with the custom reports `bubs_custom1` to `bubs_custom99`, see Building Reports. URL parameters can also be passed on subfunctions. The subfunction then passes these parameters to the report. When several parameters are used, the `&` symbol separates them. The parameters are unescaped, as in a URL. The escape function converts a parameter to a URL-encoded string, in which all non-alphanumeric characters are replaced by `%` followed by hexadecimal digits. The unescape function does the opposite. For example, unescape `%21` becomes an exclamation mark and unescape `%20` becomes a space. The following example shows two URL parameters separated by the `&` symbol: ```text P_TITEL=titel%20vof%20the%report&P_PJT_CODE=123456 ``` ## Loops Subfunctions can also build loops in reports. The system runs a report for each line of a query. URL parameters can pass values from the query on to the report. The `:` notation passes the value of a column, for example `P_GBR_NAAM=:GBR_NAAM`. The following query is an example of a looping query. For each of its lines, the system runs a report: ```sql select gbr_naam from bubs_gebruikers_v order by gbr_naam ``` The depth also determines the content of a loop. A loop can contain another loop. The depth of this inner loop is one. Within this nested loop, a further loop can be included. The depth of that loop is two. The maximum depth of a loop depends on the programming language and the program function in use. ## Documents The entry fields have the following meaning: - "Function": The name of the report function. - "Sort Order": The numeric value that sorts the subfunctions when a list box in a screen shows them. - "Active": When checked, the subfunction is activated. - "Depth": The depth of the subfunction in a loop. The depth also plays a role in the content of the loop. - "Description": The description of the subfunction. - "Code": The code that refers to the report. - "URL Parameters": The URL parameters, such as `A=B&...&Y=Z`. The application passes the parameters on to the subfunction when it executes. - "Document Number": The reference to a document number as registered in [[Invantive Estate/Subjects/CRM/Documents|Documents]]. A report can insert or attach a document. - "Looping Query": The SQL query that generates the loop of the report. A loop is a sequence of instructions that repeats for all rows in the query.