29 Flares Twitter 0 Facebook 29 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 29 Flares ×

A HTML table makes it extremely easy to visualize your data and you can access HTML files via web browsers.

Following function modules are used to download the internal table data as HTML format.

WWW_ITAB_TO_HTML_HEADERS – used Fill column heading of Internal Table Display in Internet

WWW_ITAB_TO_HTML_LAYOUT – Layout Parameters for Internal Table Display in Internet/Intranet

WWW_ITAB_TO_HTML – Convert Internal Table to HTML Table

Source Code:

Step 1: Go to SE38 create a program (Program name starts must with Z or Y).

Step 2: Copy and paste the below code in your program.

*&———————————————————————*
*& Report  ZITAB_TO__HTML
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT ZITAB_TO__HTML.

*//Type Pool Declaration
type-pools slis.

*//Tables Declaration
TABLES:MARA.

TYPES:BEGIN OF ty_material,
matnr TYPE matnr,            ” materil number
ersda TYPE ersda,            ” Created On
PSTAT TYPE PSTAT_d,            ” Last change on
mtart  TYPE mtart,           ” Material Type
END OF ty_material.

*//Internal Table Declaration
DATA:
it_material TYPE TABLE OF ty_material,    ” Material Details Internal table
it_fieldcat type slis_t_fieldcat_alv with header line. ” Internal Table for Fieldcatalog

DATA:
it_header TYPE STANDARD TABLE OF w3head WITH HEADER LINE,
it_fields TYPE STANDARD TABLE OF w3fields WITH HEADER LINE,
it_html TYPE STANDARD TABLE OF w3html,
wa_header TYPE w3head,
wa_head TYPE w3head,
lv_path type string.

*//Selection Screen Design
SELECTION-SCREEN begin of block blk with frame title text-001.
Select-OPTIONS s_matnr for mara-matnr.
parameters p_path type rlgrap-filename.
selection-screen end of block blk.

*// Providing F4 functionality
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

*// Call Function Module F4_FILENAME for getting F4 functionality
CALL FUNCTION ‘F4_FILENAME’
EXPORTING
program_name  = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name     = p_path.
*// Start of selection
START-OF-SELECTION.
lv_path = p_path.

*//Retrieving Data from MARA
START-OF-SELECTION.
SELECT matnr ersda pstat mtart FROM
mara
INTO TABLE it_material
where matnr in s_matnr.
END-OF-SELECTION.

*// Populate Fieldcatalog
it_fieldcat-seltext_m = ‘Material no’.
APPEND it_fieldcat.
it_fieldcat-seltext_m = ‘Created On’.
APPEND it_fieldcat.
it_fieldcat-seltext_m = ‘Date of last change’.
APPEND it_fieldcat.
it_fieldcat-seltext_m = ‘Material Type’.
APPEND it_fieldcat.

*// Fill the Column headings and Properties
LOOP AT it_fieldcat.
wa_head-text = it_fieldcat-seltext_m.

*//Populating the Column Headings
CALL FUNCTION ‘WWW_ITAB_TO_HTML_HEADERS’
EXPORTING
field_nr = sy-tabix
text     = wa_head-text
fgcolor  = ‘black’
bgcolor  = ‘red’
TABLES
header   = it_header.
*//Populating Column Properties
CALL FUNCTION ‘WWW_ITAB_TO_HTML_LAYOUT’
EXPORTING
field_nr = sy-tabix
fgcolor  = ‘black’
size     = ‘3’
TABLES
fields   = it_fields.
ENDLOOP.
*//Title of HTML Output
wa_header-text = ‘Material Details’ .
wa_header-font = ‘Courier New’.
wa_header-size = ‘3’.

*//Converting Internal Table into HTML
REFRESH it_html.
CALL FUNCTION ‘WWW_ITAB_TO_HTML’
EXPORTING
table_header = wa_header
TABLES
html         = it_html
fields       = it_fields
row_header   = it_header
itable       = it_material.

*//Downloading the HTML into your system
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename                = lv_path
TABLES
data_tab                = it_html.

Output:

Click on execute(F8) button.

Provide input values (Material number and download path)

Downloading ITAB data as HTMLClick on execute button. Then you will get as success message as shown below.

Downloading ITAB data as HTML1Your data will be downloaded into above give path as HTML formats as shown below.

Downloading ITAB data as HTML2That’s it.

Enjoy 🙂

Also Read:

How to Create Transaction Code for Table Maintenance Generator in SAP.

Blocked ALV in SAP ABAP.

29 Flares Twitter 0 Facebook 29 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 29 Flares ×