SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Download any table in html format



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Fri May 22, 2009 3:03 pm    Post subject: Download any table in html format Reply with quote

Download di una tabella in formato html

Code:
REPORT zhrrphtml.
***********************************************************
* Developer : Luciano Cantaro
* Location : Italy
* Date : 28/05/2003.
***********************************************************
* Colonna type P non supportata
***********************************************************
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(500) 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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.