Download von Programmen

Mit diesem Programm kannst du ABAP-Programme auf deinen PC speichern. Es werden dabei die Texte als auch die Dokumentation berücksichtigt. Jeder Report wird in einer Datei mit der Endung “ABAP” gespeichert. Zudem wird eine Übersichtsdatei erstellt, in der alle heruntergeladenen Programme mit Bezeichnung aufgeführt sind. Die Auswahl der Programme erfolgt nach Programmname, Autor oder Entwicklungsklasse.

[notice type=’info’]

Tipp:
Du kannst einen Report per Drag and Drop direkt aus dem Explorer in das TextEditControl des ABAP-Editors ziehen![/notice]

*---------------------------------------------------------------------*
* Author: Harald Werft                                                *
* Datum.: 15.11.1995                                                  *
*---------------------------------------------------------------------*
* Download von Objekten (Reports/Includes/Modulpool                   *
*---------------------------------------------------------------------*
* Angepasst von Enno Wulff                                            *
* https://tricktresor.com
*---------------------------------------------------------------------*
REPORT  zsysrep1.

TABLES: dokil,                         "Index Doku-Tabelle
        tadir.                         "Tabelle mit Entwicklungsklasse

DATA:
* Ausgewählte Elemente
  prog      LIKE tadir    OCCURS 0 WITH HEADER LINE,

* Inhalt
  BEGIN OF inhalt OCCURS 0,
    report TYPE syrepid,
    bezei(200),
  END OF inhalt,

* Report
  BEGIN OF t OCCURS 0,
    line(72),
  END OF t,

* Texelemente für Report
  te        LIKE textpool OCCURS 0 WITH HEADER LINE,

* Variablen Textverarbeitung
  texthead  LIKE thead,
  textlines LIKE tline    OCCURS 0 WITH HEADER LINE,

* Download
  BEGIN OF tab OCCURS 0,
    line(400),
  END OF tab,

  BEGIN OF name,
    pfad(500),
    datei(500),
    erweit(5),
  END OF name,
  filename  LIKE rlgrap-filename.

*** Selektionsbild
PARAMETER: i_pfad(200) DEFAULT 'C:/DATENREPORT'.
SELECT-OPTIONS i_objnam FOR tadir-obj_name.
SELECT-OPTIONS i_devcla FOR tadir-devclass.
SELECT-OPTIONS i_author FOR tadir-author.
PARAMETER: i_doku AS CHECKBOX DEFAULT 'X'.

************************************************************************
START-OF-SELECTION.
************************************************************************

*** Alle Programme laut Selektionskriterium ermitteln
  SELECT * FROM  tadir INTO TABLE prog
   WHERE pgmid       = 'R3TR'
     AND object      = 'PROG'
     AND obj_name   IN i_objnam
     AND devclass   IN i_devcla
     AND author     IN i_author.

  REFRESH inhalt.

  LOOP AT prog.
    REFRESH t.
*** Einlesen der Reportssource
    READ REPORT prog-obj_name INTO t.
    IF sy-subrc = 0.
*** Einlesen des Textpools
      REFRESH te.
      READ TEXTPOOL prog-obj_name INTO te LANGUAGE sy-langu.
*** Inhaltsdatei aufbauen
      inhalt-report = prog-obj_name.
      inhalt-bezei  = space.
*** Lesen der Reportbezeichnung
      READ TABLE te WITH KEY id = 'R'.
      IF sy-subrc = 0.
        inhalt-bezei = te-entry.
      ENDIF.
      APPEND inhalt.
*** Übergabe der Texte an die Downloadtabelle
      LOOP AT te.
        APPEND te(254) TO tab.
      ENDLOOP.
      REFRESH textlines.
      CLEAR: textlines, texthead.
      IF NOT i_doku IS INITIAL.
*** Lesen Index DOKU-Tabelle
        SELECT SINGLE * FROM  dokil
           WHERE  id      = 'RE'
           AND    object  = prog-obj_name
           AND    langu   = 'D'
           AND    typ     = 'E'.
        IF sy-subrc = 0.
*** Lesen der Doku falls gewünscht
          CALL FUNCTION 'DOCU_GET'
               EXPORTING
                    id     = dokil-id
                    langu  = dokil-langu
                    object = dokil-object
                    typ    = dokil-typ
               IMPORTING
                    head   = texthead
               TABLES
                    line   = textlines
               EXCEPTIONS
                    OTHERS = 1.
          REFRESH te.
          CLEAR te.
*** Übertragen der Dokumentation in die Downloadtabelle
          APPEND LINES OF textlines TO tab.
        ENDIF.
      ENDIF.
      APPEND sy-uline(70) TO tab.
      APPEND LINES OF t   TO tab.
*** Download des Reports
      name-pfad   = i_pfad.
      name-datei  = prog-obj_name.
      name-erweit = '.ABAP'.
      CONDENSE name NO-GAPS.
      filename    = name.
      CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
                filename            = filename
                filetype            = 'ASC'
                mode                = ' '
           TABLES
                data_tab            = tab
           EXCEPTIONS
                file_open_error     = 01
                file_write_error    = 02
                invalid_filesize    = 03
                invalid_table_width = 04
                invalid_type        = 05
                no_batch            = 06
                unknown_error       = 07.
      PERFORM fehler_download.
    ENDIF.

  ENDLOOP.

*** Ausgabe des Inhaltsverzeichnis in Datei
  name-pfad   = i_pfad.
  name-datei  = 'Inhalt'.
  name-erweit = '.TXT'.
  CONDENSE name NO-GAPS.
  filename    = name.
  CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
            filename            = filename
            filetype            = 'ASC'
            mode                = ' '
       TABLES
            data_tab            = inhalt
       EXCEPTIONS
            file_open_error     = 01
            file_write_error    = 02
            invalid_filesize    = 03
            invalid_table_width = 04
            invalid_type        = 05
            no_batch            = 06
            unknown_error       = 07.
  PERFORM fehler_download.

END-OF-SELECTION.

*---------------------------------------------------------------------*
*       FORM FEHLER_DOWNLOAD                                          *
*---------------------------------------------------------------------*
* Fehlermelung und Abbruch, wenn beim Download Fehler auftraten.      *
*---------------------------------------------------------------------*
FORM fehler_download.

  IF sy-subrc NE 0.
    WRITE: / 'Fehler beim Download:'.
    CASE sy-subrc.
      WHEN 1.
        WRITE: / 'File Open Error'.
      WHEN 2.
        WRITE: / 'File Write Error'.
      WHEN 3.
        WRITE: / 'Invalid Filesize'.
      WHEN 4.
        WRITE: / 'Invalid Table Width'.
      WHEN 5.
        WRITE: / 'Invalid Type'.
      WHEN 6.
        WRITE: / 'No Batch'.
      WHEN 7.
        WRITE: / 'Unknown'.
    ENDCASE.
    STOP.
  ENDIF.

ENDFORM.

 

Enno Wulff

Leave a Comment