Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Alignment of ALV Report Title

Former Member
0 Kudos

Dear All,

I would like to display my ALV report title in different position.

For example, I wanna display the following as the ALV report title ('MATERIAL REPORT' in the center and 'Prepared By:' in the right).

MATERIAL REPORT Prepared By:

I am using function 'REUSE_ALV_COMMENTARY_WRITE' to put in the report title. However, I couldn't find a way to put the title in the center and on the left.

Is anyone know how could I do this?

Thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

To get adjust your alv heading at right hand side or center...you have to use 'HTML_TOP_OF_PAGE'..

Try like this....


 *&---------------------------------------------------------------------*
*&      Form  html_top_of_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->TOP        text
*----------------------------------------------------------------------*
FORM html_top_of_page USING top TYPE REF TO cl_dd_document.
 
  DATA: l_text(255) TYPE c.
  DATA: text1(255)  TYPE c.
  DATA: t_header TYPE REF TO cl_dd_table_element ,
        wa_header TYPE REF TO cl_dd_table_area.
 
  CALL METHOD top->add_gap " here give the gap after which you want to display the data...
    EXPORTING
      width = 10.
 
 
  CALL METHOD top->add_text
    EXPORTING
      text          = '<your text>'
*    text_table    = wa_header
*    fix_lines     =
      sap_style     = 'HEADING'
      sap_color     = cl_dd_document=>list_heading_int
      sap_fontsize  = 'MEDIUM'
      sap_fontstyle = 'ARIAL'
      sap_emphasis  = cl_dd_document=>strong.
*    style_class   =
*  CHANGING
*    document      =
  ENDFORM.
 



and pass it in REUSE_ALV_GRID_DISPLAY....

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
  i_callback_program                = sy-repid
   i_callback_pf_status_set          = 'SET_STANDARD'
   i_callback_user_command           = 'USER_COMMAND'
*   I_CALLBACK_TOP_OF_PAGE            = ' '
   i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'
 

Regards

Debarshi

6 REPLIES 6

Former Member
0 Kudos

Hi,

To get adjust your alv heading at right hand side or center...you have to use 'HTML_TOP_OF_PAGE'..

Try like this....


 *&---------------------------------------------------------------------*
*&      Form  html_top_of_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->TOP        text
*----------------------------------------------------------------------*
FORM html_top_of_page USING top TYPE REF TO cl_dd_document.
 
  DATA: l_text(255) TYPE c.
  DATA: text1(255)  TYPE c.
  DATA: t_header TYPE REF TO cl_dd_table_element ,
        wa_header TYPE REF TO cl_dd_table_area.
 
  CALL METHOD top->add_gap " here give the gap after which you want to display the data...
    EXPORTING
      width = 10.
 
 
  CALL METHOD top->add_text
    EXPORTING
      text          = '<your text>'
*    text_table    = wa_header
*    fix_lines     =
      sap_style     = 'HEADING'
      sap_color     = cl_dd_document=>list_heading_int
      sap_fontsize  = 'MEDIUM'
      sap_fontstyle = 'ARIAL'
      sap_emphasis  = cl_dd_document=>strong.
*    style_class   =
*  CHANGING
*    document      =
  ENDFORM.
 



and pass it in REUSE_ALV_GRID_DISPLAY....

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
  i_callback_program                = sy-repid
   i_callback_pf_status_set          = 'SET_STANDARD'
   i_callback_user_command           = 'USER_COMMAND'
*   I_CALLBACK_TOP_OF_PAGE            = ' '
   i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'
 

Regards

Debarshi

0 Kudos

Thank you very much, Debarshi. It works.

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

Using COMMENTARY_WRITE func. mod. you cannot align the header.

You can have a look a this [blog|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6480] [original link is broken] [original link is broken] [original link is broken]; by Chandra.

BR,

Suhas

Former Member
0 Kudos

Thank you for your help, Suhas.

Former Member
0 Kudos

Hi,

Refer the code below:-



  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program                = sy-repid
      i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'
      it_fieldcat                       = it_field
    TABLES
      t_outtab                          = it_final
    EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2.

  IF sy-subrc <> 0.
   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  html_top_of_page
*&---------------------------------------------------------------------*
*       TO WRITE THE HEADER AS HTML
*----------------------------------------------------------------------*
FORM html_top_of_page USING top TYPE REF TO cl_dd_document.
  DATA: l_text(255) TYPE c.
  DATA: l_url TYPE string VALUE 'http://www.google.com/'.
  DATA: l_txt TYPE sdydo_text_element VALUE 'Google'.
  DO 180 TIMES.

    l_text+sy-index(1) = '*'.
  ENDDO.

  CALL METHOD top->add_text
    EXPORTING
      text      = 'Hello world '
      sap_style = 'heading'.
  CALL METHOD top->add_gap
    EXPORTING
      width = 200.
  CALL METHOD top->add_picture
    EXPORTING
      picture_id = 'ENJOYSAP_LOGO'.
  CALL METHOD top->new_line( ).
  CALL METHOD top->add_text
    EXPORTING
      text = l_text.

  CALL METHOD top->add_link
    EXPORTING
      url  = l_url
      text = l_txt.
ENDFORM.                    "html_top_of_page


Hope it helps

Regards

Mansi

0 Kudos

Thank you for your help, Mansi.