*&---------------------------------------------------------------------*
*& Report ZSS_CODE_2_HTML (Version 1.0)
*& by Stefan Schmöcker (1999)
*& emails:
* privat: unter der Woche mit Weiterleitung an privat
" [email protected][email protected]
" [email protected]
*&---------------------------------------------------------------------*
* Momentan realisiert: - Quellcode in HTML
* - Include-Quellcodes in HTML
* - Gesammelte Textelemente in Tabellen
* - Links zu den Untersektionen
* geplant: - feinere Linkaufteilung zu den einzelnen Includes
* - Links innerhalb des Quellcodes zu entsprechenden Punkten
* - GUI-Status,
* - Dokumentation,
* - Dynpro-ablauflogik und Fullscreen-Anzeige
*&---------------------------------------------------------------------*
REPORT ZSS_CODE_2_HTML LINE-SIZE 255.
TABLES: D010INC.
* Tabelle für die aufzunehmenden ABAP-Texte
DATA: BEGIN OF SOURCECODE OCCURS 0,
LINE(200),
END OF SOURCECODE.
* Tabelle für den erzeugten HTMLCode
DATA: BEGIN OF HTMLCODE OCCURS 5000,
LINE(256),
END OF HTMLCODE.
DATA: BEGIN OF INCLUDETAB OCCURS 0,
NAME LIKE D010INC-INCLUDE,
END OF INCLUDETAB.
DATA: TEXTELEMENTETAB LIKE TEXTPOOL OCCURS 50 WITH HEADER LINE.
DATA: EINRUECK TYPE I, " Soweit im HTML einrücken
CHAR2(2).
*----------- Selektionsbild und Verarbeitung --------------------------
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME.
PARAMETERS: PROGNAME LIKE D010SINF-PROG.
PARAMETERS: HTMLFILE LIKE RLGRAP-FILENAME
DEFAULT 'c:\temp\test.html'.
PARAMETERS: MITINCLD AS CHECKBOX DEFAULT 'X',
MITTEXTL AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME.
PARAMETERS: MITZEILE AS CHECKBOX DEFAULT 'X',
ONSCREEN AS CHECKBOX DEFAULT 'X',
SAPINCLD AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK BL2.
* Ein subtrivialer Tests
AT SELECTION-SCREEN.
READ REPORT PROGNAME INTO SOURCECODE.
IF SY-SUBRC <> 0.
MESSAGE E159(AT) WITH 'Programm konnte nicht eingelesen werden'.
ENDIF.
*----------- Programmanfang --------------------------------------------
END-OF-SELECTION.
* In der Tabelle sourcecode sollte hier schon der Quelltext stehen.
PERFORM ERZEUGE_KOPF.
PERFORM WRITE_SOURCE.
* Includes falls erwünscht
IF MITINCLD = 'X'.
PERFORM WRITE_INCLUDES.
ENDIF.
* Textelemente falls erwünscht
* Includes falls erwünscht
IF MITTEXTL = 'X'.
PERFORM WRITE_TEXTELEMENTE.
ENDIF.
* Und abschließen des Files
PERFORM ERZEUGE_SCHWANZ.
PERFORM ABSPEICHERN TABLES HTMLCODE
USING HTMLFILE.
*----------- Unterroutinen --------------------------------------------
* include zcd_ss_debugroutinen.
*---------------------------------------------------------------------*
* FORM ABSPEICHERN *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> FILENAME *
*---------------------------------------------------------------------*
FORM ABSPEICHERN TABLES TEXT_ZU_SCHREIBEN
USING FILENAME LIKE RLGRAP-FILENAME.
*&---------------------------------------------------------------------*
*& Form ERZEUGE_SCHWANZ
*&---------------------------------------------------------------------*
* Erzeugt die abschließenden HTML-Befehle
*----------------------------------------------------------------------*
FORM ERZEUGE_SCHWANZ.
HTMLCODE-LINE = ' </body>'.APPEND HTMLCODE.
HTMLCODE-LINE = '</html>'.APPEND HTMLCODE.
ENDFORM. " ERZEUGE_SCHWANZ
*&---------------------------------------------------------------------*
*& Form WRITE_SOURCE
*&---------------------------------------------------------------------*
* Schreibt den Sourcecode
*----------------------------------------------------------------------*
FORM WRITE_SOURCE.
DATA: ROT.
* Erstmal die Überschrift hinstellen
PERFORM ADDZEILE USING '>+' '<h1 align=center>'.
PERFORM ZEILEUMB USING '' PROGNAME.
PERFORM ADDZEILE USING '->' '</h1>'.
CLEAR HTMLCODE-LINE.APPEND HTMLCODE.
* Link auf Includes
IF MITINCLD = 'X'.
PERFORM ADDZEILE USING '>+' '<h2 align=left>'.
PERFORM ZEILEUMB USING '' '<a href="#Includes">Includes</a>'.
PERFORM ADDZEILE USING '->' '</h2>'.
ENDIF.
* Link auf Textelemente
IF MITTEXTL = 'X'.
PERFORM ADDZEILE USING '>+' '<h2 align=left>'.
PERFORM ZEILEUMB USING ''
'<a href="#Textelemente">Elementos de texto</a>'.
PERFORM ADDZEILE USING '->' '</h2>'.
ENDIF.
* Und Linie zum Trennen gegen den Quellcode
PERFORM ADDZEILE USING '>+' '<h2 align=left>'.
PERFORM ZEILEUMB USING '' '<hr>'.
PERFORM ADDZEILE USING '->' '</h2>'.
* Und jetzt der Quellcode
PERFORM CODELINES.
ENDFORM. " WRITE_SOURCE
*&---------------------------------------------------------------------*
*& Form ADDZEILE
*&---------------------------------------------------------------------*
* Fügt eine Zeile in den HTML-Code ein und korrigiert Einrücktiefe
*----------------------------------------------------------------------*
FORM ADDZEILE USING VALUE(EINRUECKEN) LIKE CHAR2
VALUE(TEXT).
DATA: ER.
ER = EINRUECKEN(1).
IF ER = '+'.
EINRUECK = EINRUECK + 1.
ELSEIF ER = '-'.
EINRUECK = EINRUECK - 1.
ENDIF.
ER = EINRUECKEN+1(1).
IF ER = '+'.
EINRUECK = EINRUECK + 1.
ELSEIF ER = '-'.
EINRUECK = EINRUECK - 1.
ENDIF.
ENDFORM. " ADDZEILE
*&---------------------------------------------------------------------*
*& Form SONDERZEICHEN
*&---------------------------------------------------------------------*
* Sonderzeichen in HTML darstellen
*----------------------------------------------------------------------*
FORM SONDERZEICHEN CHANGING ZEILE.
DATA: S LIKE SY-SUBRC,
LASTHIT LIKE SY-FDPOS,
DUMMY(256).
* &
LASTHIT = 0.
DO.
DUMMY = ZEILE+LASTHIT.
IF DUMMY CA '&'.
REPLACE '&' WITH '&' INTO DUMMY.
ZEILE+LASTHIT = DUMMY.
LASTHIT = SY-FDPOS + LASTHIT + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.
* ÄÖÜäöüß<>"
DO.
S = 1.
REPLACE 'é' WITH 'e' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'á' WITH 'a' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'í' WITH 'i' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'ó' WITH 'o' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'ú' WITH 'u' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'Ä' WITH 'Ä' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'Ö' WITH 'Ö' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'Ü' WITH 'Ü' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'ä' WITH 'ä' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'ö' WITH 'ö' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'ü' WITH 'ü' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE 'ß' WITH 'ß' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE '<' WITH '<' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE '>' WITH '>' INTO ZEILE. S = S * SY-SUBRC / 4.
REPLACE '"' WITH '"' INTO ZEILE. S = S * SY-SUBRC / 4.
IF S = 1.EXIT.ENDIF.
ENDDO.
ENDFORM. " SONDERZEICHEN
*&---------------------------------------------------------------------*
*& Form ZEILEUMB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM ZEILEUMB USING VALUE(EINRUECKEN) LIKE CHAR2
VALUE(TEXT).
CONCATENATE TEXT '<br>' INTO TEXT.
PERFORM ADDZEILE USING EINRUECKEN TEXT.
ENDFORM. " ZEILEUMB
*&---------------------------------------------------------------------*
*& Form CODELINES
*&---------------------------------------------------------------------*
* Schiebt die Zeilen aus sourcecode ins HTML-Format
*----------------------------------------------------------------------*
FORM CODELINES.
DATA ZEILE(5).
PERFORM ADDZEILE USING '>+' '<p><pre>'.
LOOP AT SOURCECODE.
* Erst mal die Sonderzeichen ersetzen
PERFORM SONDERZEICHEN CHANGING SOURCECODE-LINE.
* Bei einem Kommentar diesen Rot und kursiv darstellen
IF SOURCECODE-LINE(1) = '*'. " roter Kommentar
CONCATENATE '<font color=red><i>'
SOURCECODE-LINE
'</i></font>'
INTO SOURCECODE-LINE.
ENDIF.
* Bei Zeilennummerierung diese in dunkelblau dazustellen
IF MITZEILE = 'X'.
ZEILE = SY-TABIX.
SHIFT SOURCECODE-LINE RIGHT BY 35 PLACES.
CONCATENATE '<font color=blue>'
ZEILE
'</font> '
INTO SOURCECODE-LINE(35).
ENDIF.
PERFORM ADDZEILE USING '' SOURCECODE-LINE.
ENDLOOP.
PERFORM ADDZEILE USING '->' '</pre></p>'.
ENDFORM. " CODELINES
*&---------------------------------------------------------------------*
*& Form WRITE_INCLUDES
*&---------------------------------------------------------------------*
* Die ganzen Includesources anfügen
*----------------------------------------------------------------------*
FORM WRITE_INCLUDES.
DATA: FIRSTTIME.
FIRSTTIME = 'X'.
SELECT * FROM D010INC WHERE MASTER = PROGNAME.
IF SAPINCLD = 'X'
AND D010INC-INCLUDE(1) = '<'.
CONTINUE.
ENDIF.
IF FIRSTTIME = 'X'.
PERFORM ADD_INCLUDES_HEADER.
CLEAR FIRSTTIME.
ENDIF.
* Die Namen der Includes merken und nacher am Anfang in den Quellcode
* als Navigationspunkte hinzufügen
APPEND D010INC-INCLUDE TO INCLUDETAB.
* Namen und Quelltext schreiben
PERFORM ADD_INCLUDE_NAME USING D010INC.
READ REPORT D010INC-INCLUDE INTO SOURCECODE.
PERFORM CODELINES.
ENDSELECT.
ENDFORM. " WRITE_INCLUDES
*&---------------------------------------------------------------------*
*& Form ADD_INCLUDES_HEADER
*&---------------------------------------------------------------------*
* Für den 1. Include eine kleine Sonderbehandlung
*----------------------------------------------------------------------*
FORM ADD_INCLUDES_HEADER.
HTMLCODE-LINE = '<h1 align=center><font color=red>'. APPEND HTMLCODE.
HTMLCODE-LINE = '<hr>'. APPEND HTMLCODE.
HTMLCODE-LINE = '<a name="Includes">INCLUDES</a>'.APPEND HTMLCODE.
HTMLCODE-LINE = '</font></h1>'. APPEND HTMLCODE.
HTMLCODE-LINE = ' </font></h2>'. APPEND HTMLCODE.
ENDFORM. " ADD_INCLUDE_NAME
*&---------------------------------------------------------------------*
*& Form WRITE_TEXTELEMENTE
*&---------------------------------------------------------------------*
* Textelemente des Hauptprogramms auch noch ausgeben
*----------------------------------------------------------------------*
FORM WRITE_TEXTELEMENTE.
PERFORM TEXTELEMENTE_HEADER.
READ TEXTPOOL PROGNAME INTO TEXTELEMENTETAB.
PERFORM HTML_TEXTELEMENTE USING 'en programa principal'.
LOOP AT INCLUDETAB.
READ TEXTPOOL INCLUDETAB-NAME INTO TEXTELEMENTETAB.
CHECK SY-SUBRC = 0.
PERFORM HTML_TEXTELEMENTE USING INCLUDETAB-NAME.
ENDLOOP.
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.