Entering content frame

Lines in Lists Locate the document in its SAP Library structure

ABAP offers several possibilities to create horizontal and vertical lines. For a list of the corresponding statements, see Lines and Blank Lines.

The system automatically joins lines that meet to united lines or frames. Lines meet if in the direction of at least one of the lines no blank characters or blank lines separate the lines. Depending on the type and number of lines meeting at a certain point, you can draw various line sections. To exceptionally prevent the system from joining lines, you can use special lines:

Note

Note in this context that page header and page footer occupy lines of the page. This may lead to undesired joined lines if you forget to create enough blank lines. For example, outputting vertical lines '|' in the first line after the standard page header automatically joins these lines to the underline of the page header.

For a demonstration of automatically joined lines, call the executable program SHOWLINE in any system.

Straight Lines

The example below shows how to create horizontal and vertical straight lines.

Example

REPORT demo_list_straight_lines NO STANDARD PAGE HEADING.

SKIP TO LINE 3.
ULINE AT 2(1).

WRITE 4  '-'.
WRITE 6  '--'.
WRITE 9  '---'.
ULINE AT 12(4).

SKIP TO LINE 1.
POSITION 18.
WRITE '|'.

SKIP TO LINE 3.
DO 4 TIMES.

  NEW-LINE.
  POSITION 18.
  WRITE '|'.

ENDDO.

The output appears as follows:

This graphic is explained in the accompanying text

The first ULINEstatement creates a horizontal line that covers one column. The hyphen in the first WRITE statement appears as a normal output field. The two hyphens of the second WRITEstatement create a straight line that covers two columns. The next three hyphens together with the ULINE statement create a straight line that cover seven columns.

Outputting the first '|' character creates a vertical line in the first line. The other four '|' characters are joined to a vertical straight line that covers four lines, starting at line 3.

Corners

The example below shows how to create different corners.

Example

REPORT demo_list_edges NO STANDARD PAGE HEADING.

WRITE   '--'.
WRITE / '|'.

SKIP TO LINE 1.
ULINE AT 5(6).

NEW-LINE.
WRITE 10 '|'.

SKIP TO LINE 4.
WRITE: '|        |',
     / '----------'.

This produces the following output:

This graphic is explained in the accompanying text

Wherever the ends of vertical lines meet the ends of horizontal lines, corners appear.

T Sections

The example below shows how to create different T sections.

Example

REPORT demo_list_t_pieces NO STANDARD PAGE HEADING.

WRITE '---'.
WRITE /2 '|     |'.
ULINE AT /5(8).

SKIP TO LINE 4.
DO 3 TIMES.

  WRITE '|'.
  NEW-LINE.
ENDDO.
SKIP TO LINE 5.
WRITE '---------'.

SKIP TO LINE 4.

ULINE AT 6(10).
WRITE 15 '|' .

The display looks like this:

This graphic is explained in the accompanying text

Wherever line ends meet lines at a right angle, T sections appear.

Crosses

The example below shows how to create crosses.

Example

REPORT demo_list_crosses NO STANDARD PAGE HEADING.

WRITE   '   |'.
WRITE  /'-------'.
WRITE  /'   |'.

SKIP TO LINE 1.
DO 3 TIMES.

  WRITE 12 sy-vline.
  NEW-LINE.
ENDDO.
SKIP TO LINE 2.
ULINE AT 12(1).

This produces the following output:

This graphic is explained in the accompanying text

If two lines intersect, a cross appears.

Using Special Lines

If you use tightly nested frames or tight hierarchy representations, you might want to keep certain line sections apart, even though there is no space left for inserting a blank character or blank line between them.

In this case, you can use special lines defined as system-defined constants in the INCLUDE program <LINE>:

Syntax

WRITE lin AS LINE.

To be able to use special lines in your program, you must include the INCLUDE program <LINE> or the more comprehensive INCLUDE program <LIST> into your program. The INCLUDE program <LINE> contains a short description of the special lines.

The system displays special lines in the output list exactly the way they are defined. Lines are joined only where they really meet. The system does not automatically make special lines longer to make them meet.

The easiest way to output special lines is to use a statement structure (see Using WRITE via a Statement Structure). From the screen Assemble a WRITE Statement, select the radio button Line and then choose Display. The following dialog box appears:

This graphic is explained in the accompanying text

It contains all available special lines which you can easily include into your program code.

Example

The following program shows on one hand how to use special lines to create a tight pattern. On the other hand, it also demonstrates how you can program lines in lists dynamically.

REPORT demo_list_special_lines NO STANDARD PAGE HEADING LINE-SIZE 60.

INCLUDE <line>.

DATA: x0 TYPE i VALUE 10,
      y0 TYPE i VALUE 10,
      n TYPE i VALUE 16,
      i TYPE i VALUE 0,
      x TYPE i, y TYPE i.

x = x0. y = y0. PERFORM pos.

WHILE i LE n.
  WRITE line_bottom_left_corner AS LINE.

  x = x + 1. PERFORM pos.
  ULINE AT x(i).

  x = x + i. PERFORM pos.
  WRITE line_bottom_right_corner AS LINE.

  y = y - 1. PERFORM pos.
  DO i TIMES.

    WRITE '|'.
    y = y - 1. PERFORM pos.
  ENDDO.

  WRITE line_top_right_corner AS LINE.
  i = i + 1.
  x = x - i. PERFORM pos.
  ULINE AT x(i).

  x = x - 1. PERFORM pos.
  WRITE line_top_left_corner AS LINE.

  y = y + 1. PERFORM pos.
  DO i TIMES.

    WRITE '|'.
    y = y + 1. PERFORM pos.
  ENDDO.

  i = i + 1.
ENDWHILE.

FORM pos.
  SKIP TO LINE y.
  POSITION x.
ENDFORM.

In this program, the position X,Y is set for each output using the subroutine POS. The output appears as follows:

This graphic is explained in the accompanying text

The program creates a tight helix structure which cannot be generated without using special lines. You can set the number of coils using variable n.

Programming Frames

You can use the line types available in ABAP to program frames. The sample program below defines a macro WRITE_FRAME which you can use instead of the WRITE f statement. The system draws a frame around a field f specified in WRITE_FRAME that dynamically adapts to the length of the field.

Example

REPORT demo_list_write_frame NO STANDARD PAGE HEADING LINE-SIZE 60.

DATA: x TYPE i, y TYPE i, l TYPE i.

DEFINE write_frame.
  x = sy-colno. y = sy-linno.
  write: '|' no-gap, &1 no-gap, '|' no-gap.
  l = sy-colno - x.
  y = y - 1. skip to line y. position x.
  uline at x(l).

  y = y + 2. skip to line y. position x.
  uline at x(l).

  y = y - 1. x = sy-colno. skip to line y. position x.
END-OF-DEFINITION.

SKIP.
WRITE       'Demonstrating'.
write_frame 'dynamic frames'.

WRITE       'in'.
write_frame 'ABAP'.

WRITE       'output lists.'.

The function of the macro WRITE_FRAME defined in the above program is demonstrated in the output below. For more information on macros, see Defining and Calling Macros.

This graphic is explained in the accompanying text

Programming Grids

You can use the line types available in ABAP to program a grid for a table-type list. The sample program below defines two macros NEW_GRID and WRITE_GRID that belong together. NEW_GRID is used to initialize a grid and for line feeds within the grid. You can use WRITE_GRID instead of the WRITE f statement. For each field output using WRITE_GRID, the system draws a vertical grid line to the right of the field and a horizontal grid line below it. The horizontal line dynamically adapts to the length of the field. The lines of all output fields together form a grid.

Example

REPORT demo_list_grid LINE-SIZE 60 NO STANDARD PAGE HEADING.

TABLES spfli.
DATA:  x TYPE i, y TYPE i, l TYPE i.

TOP-OF-PAGE.
  WRITE 3 'List of Flights in a Dynamic Grid'
           COLOR COL_HEADING.

  ULINE.

START-OF-SELECTION.

  DEFINE new_grid.
    y = sy-linno. y = y + 2. skip to line y.
    x = sy-colno. position x. write '|'.

  END-OF-DEFINITION.

  DEFINE write_grid.
    x = sy-colno. y = sy-linno. position x.
    write:  &1, '|'.

    l = sy-colno - x + 1.
    x = x - 2. y = y + 1. skip to line y. position x.
    uline at x(l).

    y = y - 1. x = sy-colno. skip to line y. position x.
  END-OF-DEFINITION.

GET spfli.

  new_grid.
  write_grid: spfli-carrid,
              spfli-connid,
              spfli-cityfrom,
              spfli-cityto.

The functions of the macros NEW_GRID and WRITE_GRID defined in the above program are demonstrated in the output below. For information on macros, see Macros. The executable program is connected to the logical database F1S. After the user has entered the corresponding values on the selection screen, the output may appear as follows:

This graphic is explained in the accompanying text

Note that the topmost grid line comes from the ULINE statement in the statement block following TOP-OF-PAGE. The system automatically joins the vertical lines of the list body with this line.

 

 

 

Leaving content frame