Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Sample Code arrow ABAP Reports arrow Display table in HTML
Display table in HTML PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Anon.   
Sunday, 18 February 2007

Display an ABAP table in HTML.

 

REPORT zhtmltable.

***********************************************************

* Column type P not supported.

***********************************************************

TABLES dd02l.

DATA: zx030l LIKE x030l,

      p_number TYPE i,

      tablefound TYPE i.

DATA: colorval TYPE i.

DATA: packval TYPE p, totalrows TYPE n.

DATA: w_area1(5000) TYPE c,charval(20) TYPE c.

DATA: tablen TYPE i VALUE 255.

DATA: BEGIN OF htmlview OCCURS 0,

htmlcode(500) TYPE c,

END OF htmlview.

DATA BEGIN OF zdfies OCCURS 1000.

        INCLUDE STRUCTURE dfies.

DATA END OF zdfies.

DATA: BEGIN OF flditab OCCURS 0,

fldname(11) TYPE c,

END OF flditab.

**************

PARAMETERS: tabname LIKE dd02l-tabname OBLIGATORY.

**************

htmlview-htmlcode = '<HTML><HEAD><TITLE>Table Browser</TITLE>'.

APPEND htmlview.

htmlview-htmlcode = '<BODY BGCOLOR="#404040"><FONT COLOR="#00FFFF"

face="Arial Black"> Table View : '.

APPEND htmlview.

htmlview-htmlcode = tabname. APPEND htmlview.

htmlview-htmlcode = '</FONT> <p> </p>'. APPEND htmlview.

***********************************************

PERFORM check-table-class.

PERFORM read-direct-table.

PERFORM downloadhtml.

PERFORM showhtml.

********************************************

FORM check-table-class.

  tablefound = -1.

  SELECT * FROM dd02l

  WHERE tabname EQ tabname.

    IF dd02l-tabclass CS 'TRANSP' OR

    dd02l-tabclass CS 'POOL' OR

    dd02l-tabclass CS 'CLUSTER '.

      tablefound = 1.

      EXIT.

    ENDIF.

  ENDSELECT.

  IF tablefound < 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH 'Table Not Found.... or Table Class Not in "TRANSP","POOL",

"CLUSTER"'.

    STOP.

  ENDIF.

ENDFORM.

************************************************************************

 

FORM read-direct-table.

  DATA: offs TYPE i.

  DATA: len2(5) TYPE n.

  DATA: anz_numb TYPE i.

  PERFORM gettableinfo USING tabname.

 htmlview-htmlcode = '<table border="0" width="100%">'. APPEND htmlview.

  htmlview-htmlcode = '<tr valign="middle" BGCOLOR="#5F5F5F">'.

  APPEND htmlview.

htmlview-htmlcode = '<FONT SIZE="3" COLOR="#FFBF18" FACE= "Courier

new">'.

  APPEND htmlview.

  LOOP AT zdfies.

    PERFORM htmlheader USING zdfies-fieldname.

    flditab-fldname = zdfies-fieldname.

    APPEND flditab.

  ENDLOOP.

  htmlview-htmlcode = '</B></tr>'. APPEND htmlview.

  colorval = 1.

  SELECT COUNT(*) FROM (tabname) INTO totalrows.

  WRITE :/ totalrows.

  anz_numb = 0.

  SELECT * FROM (tabname) INTO w_area1.

    ADD 1 TO anz_numb.

    IF anz_numb GT 100. " U can alter the Hits, now Max. is 100

      EXIT.

    ENDIF.

    IF colorval > 0 .

htmlview-htmlcode = '<tr valign="middle" BGCOLOR="#F7F7F7"><FONT

size="1" COLOR="#008080" FACE="Arial Narrow">'.

      APPEND htmlview.

    ELSE.

htmlview-htmlcode = '<tr valign="middle"

bgcolor="#D2D2D2"><FONT SIZE="1" COLOR="#9F000F" FACE="Arial Narrow">'.

      APPEND htmlview.

    ENDIF.

    colorval = colorval * -1 .

*************

    LOOP AT zdfies.

      charval = w_area1+zdfies-offset(zdfies-intlen).

      CASE zdfies-inttype.

        WHEN 'P'.

* PACKVAL = W_AREA1+ZDFIES-OFFSET(ZDFIES-INTLEN).

* CHARVAL = PACKVAL.

      ENDCASE.

      PERFORM htmlfield USING w_area1+zdfies-offset(zdfies-intlen).

    ENDLOOP.

*************

    htmlview-htmlcode = '</FONT></tr>'. APPEND htmlview.

    CLEAR: w_area1.

  ENDSELECT.

  htmlview-htmlcode = '</body></html>'. APPEND htmlview.

ENDFORM.

****************************************************************

FORM downloadhtml.

  CALL FUNCTION 'WS_DOWNLOAD'

       EXPORTING

            filename = 'C:\TABLEVIEW.HTM'

       TABLES

            data_tab = htmlview.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

ENDFORM.

***************************************************************

FORM showhtml.

  CALL FUNCTION 'WS_EXECUTE'

       EXPORTING

            commandline = 'c:\tableview.htm'

            program     = 'C:\PROGRA~1\INTERN~1\IEXPLORE.EXE'.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

ENDFORM.

************************************************************************

 

FORM gettableinfo USING tname.

  CALL FUNCTION 'GET_FIELDTAB'

       EXPORTING

            langu               = sy-langu

            only                = space

            tabname             = tname

            withtext            = 'X'

       IMPORTING

            header              = zx030l

       TABLES

            fieldtab            = zdfies

       EXCEPTIONS

            internal_error      = 01

            no_texts_found      = 02

            table_has_no_fields = 03

            table_not_activ     = 04.

  CASE sy-subrc.

    WHEN 0.

      LOOP AT zdfies.

      ENDLOOP.

    WHEN OTHERS.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

      WITH sy-subrc.

  ENDCASE.

ENDFORM.

********************************************************

FORM htmlfield USING name TYPE c.

  htmlview-htmlcode = '<td >'. APPEND htmlview.

  htmlview-htmlcode = name. APPEND htmlview.

  htmlview-htmlcode = '</td>'. APPEND htmlview.

ENDFORM.

********************************************************

FORM htmlheader USING name TYPE c.

  htmlview-htmlcode = '<td >'. APPEND htmlview.

  htmlview-htmlcode = name. APPEND htmlview.

  htmlview-htmlcode = '</td>'. APPEND htmlview.

ENDFORM.


Related Items:

 
< Prev   Next >

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 333
Sample Code: 164
Total Contributions: 550

Member Activity
Members: 6176 since 2/1/2007!
New: 3 since yesterday!
Visitors: 1009423
We have 2 guests online

Newest Members

Welcome our newest members:

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor