Skip to end of metadata
Go to start of metadata

There is always needed to add a nice and pretty header no our OO ALV reports, It took me a while to figure it out, so I describe how I did it.

1. Create a normal SCREEN.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
CALL SCREEN 0100.

2. On the Flow Logic, as usual create both modules

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100. "-->Double click on it.
*
PROCESS AFTER INPUT.
  MODULE USER_COMMAND_0100.

3.  Here is the good part.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
PROCESS BEFORE OUTPUT.
 MODULE STATUS_0100. "-->Double click on it.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0100.

4. Take a look on this: I just create a docking control with a splitter divided in 2, the upper container will have the header, and the lower will have the alv!!

Declare the following as global:

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
DATA: gr_alvgrid    TYPE REF TO cl_gui_alv_grid,
      gr_docking    TYPE REF TO cl_gui_docking_container,
      gt_fieldcat   TYPE lvc_t_fcat,
      gs_layout     TYPE lvc_s_layo,
      g_splitter    TYPE REF TO cl_gui_splitter_container,
      g_container_1 TYPE REF TO cl_gui_container,
      g_container_2 TYPE REF TO cl_gui_container.

FORM split_screen.

  CLEAR: gr_docking, g_splitter, g_container_1, g_container_2.
  CREATE OBJECT gr_docking
                 EXPORTING repid     = sy-repid
                           dynnr     = sy-dynnr
                           ratio     = '95'.

* Create a splitter with 2 rows and 1 column
  CREATE OBJECT g_splitter
  EXPORTING parent  = gr_docking
  rows    = 2
  columns = 1.

** Upper Container
  CALL METHOD g_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = g_container_1.

** Lower Container
  CALL METHOD g_splitter->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = g_container_2.

** Upper Container height

  CALL METHOD g_splitter->set_row_height
    EXPORTING
      id     = 1
      height = 20.
*
  PERFORM header.

ENDFORM.                    "split_screen

5. Here will create the header, add graphics and text

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
FORM header.

  DATA: l_document TYPE REF TO cl_dd_document,
        l_doctable TYPE REF TO cl_dd_table_element,
        l_column1  TYPE REF TO cl_dd_area,
        l_column2  TYPE REF TO cl_dd_area.

  CREATE OBJECT l_document.
  CALL METHOD l_document->add_text
    EXPORTING
      text      = text-001
      sap_style = cl_dd_area=>heading.

  CALL METHOD l_document->add_table
    EXPORTING
      no_of_columns               = 5
      cell_background_transparent = 'X'
      border                      = '0'
    IMPORTING
      table                       = l_doctable.

  CALL METHOD l_doctable->add_column
    IMPORTING
      column = l_column1.

  PERFORM TITLES CHANGING l_column1.

  CALL METHOD l_doctable->add_column
    IMPORTING
      column = l_column2.

  CALL METHOD l_column2->add_gap
    EXPORTING
      width = 150.

  CALL METHOD l_column2->add_picture
    EXPORTING
      picture_id = 'ZPICTURE'. "WHAT EVER GRAPHIC YOU NEED

  CALL METHOD l_document->merge_document.
  CALL METHOD l_document->display_document
    EXPORTING
      parent = g_container_1.

ENDFORM.                    "header

6. Titles will be added

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
FORM TITLES CHANGING dg_dyndoc_id TYPE REF TO cl_dd_area.

  DATA : dl_text(255) TYPE c.  "Text
  dl_text = sy-title.

  CONDENSE dl_text.
  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_fontsize = cl_dd_area=>large.

  CALL METHOD dg_dyndoc_id->new_line.
  CLEAR : dl_text.

  dl_text = 'Date :'.

  CALL METHOD dg_dyndoc_id->add_gap.

  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text = dl_text.

  CLEAR dl_text.

  WRITE sy-datum TO dl_text.

  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text = dl_text.

  CALL METHOD dg_dyndoc_id->new_line.

  CLEAR : dl_text.

  dl_text = 'Time :'.

  CALL METHOD dg_dyndoc_id->add_gap.

  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text = dl_text.

  CLEAR dl_text.

  WRITE sy-uzeit TO dl_text.

  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text = dl_text.

  CALL METHOD dg_dyndoc_id->new_line.

  dl_text = 'User :'.

  CALL METHOD dg_dyndoc_id->add_gap.

  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text = dl_text.

  CLEAR dl_text.

  dl_text = sy-uname.
  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text = dl_text.

ENDFORM.

7. Finally on the form DisplayALV add the rest of the ALV*

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
FORM display_alv.

  DATA: ls_variant  TYPE disvariant,
         l_save.

  ls_variant-report = sy-repid.
  l_save = 'A'.

  IF gr_alvgrid IS INITIAL .

*   Add the ALV to the lower container

    CREATE OBJECT gr_alvgrid
    EXPORTING
    i_parent = g_container_2
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    OTHERS = 5 .

    PERFORM prepare_field_catalog CHANGING gt_fieldcat .

    PERFORM prepare_layout CHANGING gs_layout .

    CALL METHOD gr_alvgrid->set_table_for_first_display
      EXPORTING
        is_layout                     = gs_layout
        is_variant                    = ls_variant
        i_save                        = l_save
      CHANGING
        it_outtab                     = gt_data[]
        it_fieldcatalog               = gt_fieldcat
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.

  ELSE .
    CALL METHOD gr_alvgrid->refresh_table_display
      EXCEPTIONS
        finished = 1
        OTHERS   = 2.

  ENDIF .

ENDFORM.                    "display_alv