Generate this example Choose a template and create a fresh report with the demo service.

xtt->merge( iv_block_name = 'R' is_block =

JSON
{"TITLE":"Document title","TEXT":"Just string","INT":3,"BOTTOM":"bottom"}

).


Generate demo 140

;type=block

Request preview

Purpose

Demo ZCL_XTT_DEMO_140 shows or removes an entire template region according to an ABAP condition. Use ;type=block when the condition affects a range of rows or a PDF subform, rather than a single value.

image

Choose the appropriate conditional feature

  • Use ;cond= to calculate one displayed value.
  • Use show_if or hide_if to select row layouts in a repeated tree.
  • Use ;type=block for an arbitrary, one-time template region.

;type=block


This example displays the block only in 2019: ;cond=sy-datum(4) EQ '2019'. image


The next block is displayed when TITLE in root R is not initial.

image

You could also write ;cond=value-title IS NOT INITIAL


For PDF, a subform defines the block boundary. In Excel and Word, table rows define it.

Table borders may not be visible in Word

image

To display the borders in the template
Table Tools -> Layout -> View Gridlines

image


The directive replaces the older workaround of passing a one-row table to show a region and an empty table to hide it.

Shorthand

{R-BL2;type=block;cond=strlen( value-TITLE ) GT 0} can be shortened to {R-BL2;=strlen( v-TITLE ) GT 0}.

*See templates 140