Skip to Content

Objective

Create an ALV report and an HTML header for it.

Report

REPORT  ZALV_HEADER_HTML.

TABLES : sflight.
TYPEPOOLS: slis.

DATA : w_repid LIKE syrepid.

TYPES : BEGIN OF ty_comp.
         INCLUDE STRUCTURE sflight.
TYPES : END OF ty_comp.

DATA: wa_layout  TYPE slis_layout_alv.

DATA: t_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
       wa_fieldcat TYPE slis_fieldcat_alv.

DATA : it_comp TYPE TABLE OF ty_comp.

INITIALIZATION.
   w_repid = syrepid.

STARTOFSELECTION.

   SELECT * FROM sflight INTO TABLE it_comp.

ENDOFSELECTION.

*  CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
*    EXPORTING
*      i_program_name         = w_repid
*      i_internal_tabname     = ‘IT_COMP’
*      i_inclname             = w_repid
*    CHANGING
*      ct_fieldcat            = it_fieldcat
*    EXCEPTIONS
*      inconsistent_interface = 1
*      program_error          = 2
*      OTHERS                 = 3.

*    CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE’
*    EXPORTING
*      i_structure_name = ‘SPFLI’
*    CHANGING
*      ct_fieldcat = it_fieldcat[]
*    EXCEPTIONS
*      inconsistent_interface = 1
*      program_error = 2
*      others = 3.

PERFORM zf_monta_tabela_alv.

   CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
     EXPORTING
       i_callback_program          = w_repid
       i_callback_html_top_of_page = ‘HTML_TOP_OF_PAGE’
       is_layout                   = wa_layout
       it_fieldcat                 = t_fieldcat[]
     TABLES
       t_outtab                    = it_comp
     EXCEPTIONS
       program_error               = 1
       OTHERS                      = 2.

*&———————————————————————*
*&      Form  html_top_of_page
*&———————————————————————*

FORM html_top_of_page USING document TYPE REF TO cl_dd_document.

   DATA: text TYPE sdydo_text_element.

   CALL METHOD document->add_gap
     EXPORTING
       width = 100.
   text ‘Company Code Data’.
   CALL METHOD document->add_text
     EXPORTING
       text      = text
       sap_style = ‘HEADING’.

   CALL METHOD document->new_line.
   CALL METHOD document->new_line.
   CALL METHOD document->new_line.

   text = ‘User Name : ‘.
   CALL METHOD document->add_text
     EXPORTING
       text         = text
       sap_emphasis = ‘Strong’.

   CALL METHOD document->add_gap
     EXPORTING
       width = 6.

   text = syuname.
   CALL METHOD document->add_text
     EXPORTING
       text      = text
       sap_style = ‘Key’.

   CALL METHOD document->add_gap
     EXPORTING
       width = 50.

   text = ‘Date : ‘.
   CALL METHOD document->add_text
     EXPORTING
       text         = text
       sap_emphasis = ‘Strong’.

   CALL METHOD document->add_gap
     EXPORTING
       width = 6.

   text = sydatum.
   CALL METHOD document->add_text
     EXPORTING
       text      = text
       sap_style = ‘Key’.

   CALL METHOD document->add_gap
     EXPORTING
       width = 50.

   text = ‘Time : ‘.
   CALL METHOD document->add_text
     EXPORTING
       text         = text
       sap_emphasis = ‘Strong’.

   CALL METHOD document->add_gap
     EXPORTING
       width = 6.

   text = syuzeit.
   CALL METHOD document->add_text
     EXPORTING
       text      = text
       sap_style = ‘Key’.

   CALL METHOD document->new_line.
   CALL METHOD document->new_line.

ENDFORM.                    “HTML_TOP_OF_PAGE

form zf_monta_tabela_alv.

   clear t_fieldcat.
   t_fieldcatfieldname        = ‘CARRID’.
   t_fieldcattabname          = ‘it_comp’.
   t_fieldcatreptext_ddic     = ‘AIRLINE’.
   t_fieldcatinttype          = ‘C’.
   t_fieldcatoutputlen        = 5.
   append t_fieldcat.

   clear t_fieldcat.
   t_fieldcatfieldname     = ‘CONNID’.
   t_fieldcattabname       = ‘it_comp’.
   t_fieldcatreptext_ddic  = ‘CONNECTION’.
   t_fieldcatinttype       = ‘P’.
   t_fieldcatoutputlen     = 5.
   append t_fieldcat.

endform.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply