ABAP程序代码批量导出

发布于:2024-03-26 ⋅ 阅读:(98) ⋅ 点赞:(0)

运行界面
在这里插入图片描述
在这里插入图片描述

*&---------------------------------------------------------------------*
*& Report  ZZ0001
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZZ0001.
*&---------------------------------------------------------------------*
*& Report  ZTSE_DOWN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

*REPORT  zdown.
*-------------------------------------------------------------------------------------------- --------------------------
*  SAP Tables
*-------------------------------------------------------------------------------------------- --------------------------
TABLES: trdir, seoclass, tfdir, enlfdir, dd02l, tadiv.
TYPE-POOLS: abap.

*-------------------------------------------------------------------------------------------- --------------------------
*  Types
*-------------------------------------------------------------------------------------------- --------------------------
* text element structure
TYPES: ttexttable LIKE textpool.
* GUI titles
TYPES: tguititle LIKE d347t.

* Message classes
TYPES: BEGIN OF tmessage,
         arbgb LIKE t100-arbgb,
         stext LIKE t100a-stext,
         msgnr LIKE t100-msgnr,
         text  LIKE t100-text,
       END OF tmessage.

* Screen flow.
TYPES: BEGIN OF tscreenflow,
         screen LIKE d020s-dnum,
         code LIKE d022s-line,
       END OF tscreenflow.

* Holds a table\structure definition
TYPES: BEGIN OF tdicttablestructure,
         fieldname LIKE dd03l-fieldname,
         position  LIKE dd03l-position,
         keyflag   LIKE dd03l-keyflag,
         rollname  LIKE dd03l-rollname,
         domname   LIKE dd03l-domname,
         datatype  LIKE dd03l-datatype,
         leng      LIKE dd03l-leng,
         lowercase TYPE lowercase,
         ddtext    LIKE dd04t-ddtext,
       END OF tdicttablestructure.

* Holds a tables attributes + its definition
TYPES: BEGIN OF tdicttable,
         tablename    LIKE dd03l-tabname,
         tabletitle   LIKE dd02t-ddtext,
         istructure TYPE tdicttablestructure OCCURS 0,
       END OF tdicttable.

* Include program names
TYPES: BEGIN OF tinclude,
         includename LIKE trdir-name,
         includetitle LIKE tftit-stext,
       END OF tinclude.

* Exception class texts
TYPES: BEGIN OF tconcept,
         constname TYPE string,
         concept TYPE sotr_conc,
       END OF tconcept.

* Method
TYPES: BEGIN OF tmethod,
         cmpname LIKE vseomethod-cmpname,
         descript LIKE vseomethod-descript,
         exposure LIKE vseomethod-exposure,
         methodkey TYPE string,
       END OF tmethod.

* Class
TYPES: BEGIN OF tclass,
         scanned(1),
         clsname LIKE vseoclass-clsname,
         descript LIKE vseoclass-descript,
         msg_id LIKE vseoclass-msg_id,
         exposure LIKE vseoclass-exposure,
         state LIKE vseoclass-state,
         clsfinal LIKE vseoclass-clsfinal,
         r3release LIKE vseoclass-r3release,
         imethods TYPE tmethod OCCURS 0,
         idictstruct TYPE tdicttable OCCURS 0,
         itextelements TYPE ttexttable OCCURS 0,
         imessages TYPE tmessage OCCURS 0,
         iconcepts TYPE tconcept OCCURS 0,
         textelementkey TYPE string,
         publicclasskey TYPE string,
         privateclasskey TYPE string,
         protectedclasskey TYPE string,
         typesclasskey TYPE string,
         exceptionclass TYPE abap_bool,
       END OF tclass.

* function modules
TYPES: BEGIN OF tfunction,
         functionname LIKE tfdir-funcname,
         functiongroup LIKE enlfdir-area,
         includenumber LIKE tfdir-include,
         functionmaininclude LIKE tfdir-funcname,
         functiontitle LIKE tftit-stext,
         topincludename LIKE tfdir-funcname,
         progname LIKE tfdir-pname,
         programlinkname LIKE tfdir-pname,
         messageclass LIKE t100-arbgb,
         itextelements TYPE ttexttable OCCURS 0,
         iselectiontexts TYPE ttexttable OCCURS 0,
         imessages TYPE tmessage OCCURS 0,
         iincludes TYPE tinclude OCCURS 0,
         idictstruct TYPE tdicttable OCCURS 0,
         iguititle TYPE tguititle OCCURS 0,
         iscreenflow TYPE tscreenflow OCCURS 0,
       END OF tfunction.

TYPES: BEGIN OF tprogram,
         progname LIKE trdir-name,
         programtitle LIKE tftit-stext,
         subc LIKE trdir-subc,
         messageclass LIKE t100-arbgb,
         imessages TYPE tmessage OCCURS 0,
         itextelements TYPE ttexttable OCCURS 0,
         iselectiontexts TYPE ttexttable OCCURS 0,
         iguititle TYPE tguititle OCCURS 0,
         iscreenflow TYPE tscreenflow OCCURS 0,
         iincludes TYPE tinclude OCCURS 0,
         idictstruct TYPE tdicttable OCCURS 0,
       END OF tprogram.

*-------------------------------------------------------------------------------------------- --------------------------
*  Internal tables
*-------------------------------------------------------------------------------------------- --------------------------
*  Dictionary object
DATA: idictionary TYPE STANDARD TABLE OF tdicttable WITH HEADER LINE.
* Function modules.
DATA: ifunctions TYPE STANDARD TABLE OF tfunction WITH HEADER LINE.
* Function modules used within programs.
DATA: iprogfunctions TYPE STANDARD TABLE OF tfunction WITH HEADER LINE.
* Tree display structure.
DATA: itreedisplay TYPE STANDARD TABLE OF snodetext WITH HEADER LINE.
* Message class data
DATA: imessages TYPE STANDARD TABLE OF tmessage WITH HEADER LINE.
* Holds a single message class an all of its messages
DATA: isinglemessageclass TYPE STANDARD TABLE OF tmessage WITH HEADER LINE.
* Holds program related data
DATA: iprograms TYPE STANDARD TABLE OF tprogram WITH HEADER LINE.
* Classes
DATA: iclasses TYPE STANDARD TABLE OF tclass WITH HEADER LINE.
* Table of paths created on the SAP server
DATA: iserverpaths TYPE STANDARD TABLE OF string WITH HEADER LINE.

*-------------------------------------------------------------------------------------------- --------------------------
*  Table prototypes
*-------------------------------------------------------------------------------------------- --------------------------
DATA: dumidictstructure TYPE STANDARD TABLE OF tdicttablestructure.
DATA: dumitexttab TYPE STANDARD TABLE OF ttexttable.
DATA: dumiincludes TYPE STANDARD TABLE OF tinclude.
DATA: dumihtml TYPE STANDARD TABLE OF string.
DATA: dumiheader TYPE STANDARD TABLE OF string .
DATA: dumiscreen TYPE STANDARD TABLE OF tscreenflow .
DATA: dumiguititle TYPE STANDARD TABLE OF tguititle.
DATA: dumimethods TYPE STANDARD TABLE OF tmethod.
DATA: dumiconcepts TYPE STANDARD TABLE OF tconcept.

*-------------------------------------------------------------------------------------------- --------------------------
*   Global objects
*-------------------------------------------------------------------------------------------- --------------------------
DATA: objfile TYPE REF TO cl_gui_frontend_services.
DATA: objruntimeerror TYPE REF TO cx_root.

*-------------------------------------------------------------------------------------------- --------------------------
*  Constants
*-------------------------------------------------------------------------------------------- --------------------------
CONSTANTS: versionno TYPE string VALUE '1.4.1'.
CONSTANTS: tables TYPE string VALUE 'TABLES'.
CONSTANTS: table TYPE string VALUE 'TABLE'.
CONSTANTS: like TYPE string VALUE 'LIKE'.
CONSTANTS: type TYPE string VALUE 'TYPE'.
CONSTANTS: typerefto TYPE string VALUE 'TYPE REF TO'.
CONSTANTS: structure TYPE string VALUE 'STRUCTURE'.
CONSTANTS: lowstructure TYPE string VALUE 'structure'.
CONSTANTS: occurs TYPE string VALUE 'OCCURS'.
CONSTANTS: function TYPE string VALUE 'FUNCTION'.
CONSTANTS: callfunction TYPE string VALUE ' CALL FUNCTION'.
CONSTANTS: message TYPE string  VALUE 'MESSAGE'.
CONSTANTS: include TYPE string VALUE 'INCLUDE'.
CONSTANTS: lowinclude TYPE string VALUE 'include'.
CONSTANTS: destination TYPE string VALUE 'DESTINATION'.
CONSTANTS: is_table TYPE string VALUE 'T'.
CONSTANTS: is_program TYPE string VALUE 'P'.
CONSTANTS: is_screen TYPE string VALUE 'S'.
CONSTANTS: is_guititle TYPE string VALUE 'G'.
CONSTANTS: is_documentation TYPE string VALUE 'D'.
CONSTANTS: is_messageclass TYPE string VALUE 'MC'.
CONSTANTS: is_function TYPE string VALUE 'F'.
CONSTANTS: is_class TYPE string VALUE 'C'.
CONSTANTS: is_method TYPE string VALUE 'M'.
CONSTANTS: asterix TYPE string VALUE '*'.
CONSTANTS: comma TYPE string VALUE ','.
CONSTANTS: period TYPE string VALUE '.'.
CONSTANTS: dash TYPE string VALUE '-'.
CONSTANTS: true TYPE abap_bool VALUE 'X'.
CONSTANTS: false TYPE abap_bool VALUE ''.
CONSTANTS: lt TYPE string VALUE '<'.
CONSTANTS: gt TYPE string VALUE '>'.
CONSTANTS: unix TYPE string VALUE 'UNIX'.
CONSTANTS: non_unix TYPE string VALUE 'not UNIX'.
CONSTANTS: htmlextension TYPE string VALUE 'html'.
CONSTANTS: textextension TYPE string VALUE 'txt'.
CONSTANTS: ss_code TYPE c VALUE 'C'.
CONSTANTS: ss_table TYPE c VALUE 'T'.

*-------------------------------------------------------------------------------------------- --------------------------
*  Global variables
*-------------------------------------------------------------------------------------------- --------------------------
DATA: statusbarmessage(100).
DATA: forcedexit TYPE abap_bool VALUE false.
DATA: starttime LIKE sy-uzeit.
DATA: runtime LIKE sy-uzeit.
DATA: downloadfileextension TYPE string.
DATA: downloadfolder TYPE string.
DATA: serverslashseparator TYPE string.
DATA: frontendslashseparator TYPE string.
DATA: slashseparatortouse TYPE string.
DATA: serverfilesystem TYPE filesys_d.
DATA: serverfolder TYPE string.
DATA: frontendopsystem TYPE string.
DATA: serveropsystem TYPE string.
DATA: customernamespace TYPE string.
RANGES: soprogramname FOR trdir-name.
RANGES: soauthor FOR usr02-bname.
RANGES: sotablenames FOR dd02l-tabname.
RANGES: sofunctionname  FOR tfdir-funcname.
RANGES: soclassname FOR vseoclass-clsname.
RANGES: sofunctiongroup FOR enlfdir-area.
FIELD-SYMBOLS: <wadictstruct> TYPE tdicttable.

*-------------------------------------------------------------------------------------------- --------------------------
*  Selection screen declaration
*-------------------------------------------------------------------------------------------- --------------------------
* Author
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE tblock1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) tauth.
PARAMETERS: pauth LIKE usr02-bname MEMORY ID mauth.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(36) tpmod.
PARAMETERS: pmod AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE tblock2.
* Tables
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rtable RADIOBUTTON GROUP r1.
SELECTION-SCREEN COMMENT 5(15) trtable.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(15) tptable.
SELECT-OPTIONS: sotable FOR dd02l-tabname.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(79) ttnote.
SELECTION-SCREEN END OF LINE.

* Message classes
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rmess RADIOBUTTON GROUP r1.
SELECTION-SCREEN COMMENT 5(18) tpmes.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(18) tmname.
PARAMETERS: pmname LIKE t100-arbgb MEMORY ID mmname.
SELECTION-SCREEN END OF LINE.

* Function modules
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rfunc RADIOBUTTON GROUP r1.
SELECTION-SCREEN COMMENT 5(30) trfunc.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(15) tpfname.
SELECT-OPTIONS: sofname FOR tfdir-funcname.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(15) tfgroup.
SELECT-OPTIONS: sofgroup FOR enlfdir-area.
SELECTION-SCREEN END OF LINE.

* Classes
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rclass RADIOBUTTON GROUP r1.
SELECTION-SCREEN COMMENT 5(30) trclass.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(15) tpcname.
SELECT-OPTIONS: soclass FOR seoclass-clsname.
SELECTION-SCREEN END OF LINE.

* Programs / includes
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rprog RADIOBUTTON GROUP r1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 5(18) tprog.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(15) trpname.
SELECT-OPTIONS: soprog FOR trdir-name.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP.
* Language
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(27) tmlang.
PARAMETERS: pmlang LIKE t100-sprsl DEFAULT 'EN'.
SELECTION-SCREEN END OF LINE.

* Package
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(24) tpack.
SELECT-OPTIONS: sopack FOR tadiv-devclass.
SELECTION-SCREEN END OF LINE.

* Customer objects
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(27) tcust.
PARAMETERS: pcust AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.

* Alt customer name range
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(27) tnrange.
PARAMETERS: pcname TYPE namespace MEMORY ID mnamespace.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK b2.

* Additional things to download.
SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE tblock3.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tptext.
PARAMETERS: ptext AS CHECKBOX DEFAULT 'X' MEMORY ID mtext.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tmess.
PARAMETERS: pmess AS CHECKBOX DEFAULT 'X' MEMORY ID mmess.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tpinc.
PARAMETERS: pinc AS CHECKBOX DEFAULT 'X' MEMORY ID minc.
SELECTION-SCREEN COMMENT 40(20) treci.
PARAMETERS: preci AS CHECKBOX DEFAULT 'X' MEMORY ID mreci.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tpfunc.
PARAMETERS: pfunc AS CHECKBOX DEFAULT 'X' MEMORY ID mfunc.
SELECTION-SCREEN COMMENT 40(20) trecf.
PARAMETERS: precf AS CHECKBOX DEFAULT 'X' MEMORY ID mrecf.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) trecc.
PARAMETERS: precc AS CHECKBOX DEFAULT 'X' MEMORY ID mrecc.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tfdoc.
PARAMETERS: pfdoc AS CHECKBOX DEFAULT 'X' MEMORY ID mfdoc.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tcdoc.
PARAMETERS: pcdoc AS CHECKBOX DEFAULT 'X' MEMORY ID mcdoc.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tpscr.
PARAMETERS: pscr AS CHECKBOX DEFAULT 'X' MEMORY ID mscr.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tpdict.
PARAMETERS: pdict AS CHECKBOX DEFAULT 'X' MEMORY ID mdict.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tsortt.
PARAMETERS: psortt AS CHECKBOX DEFAULT ' ' MEMORY ID msortt.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK b3.

* File details
SELECTION-SCREEN: BEGIN OF BLOCK b4 WITH FRAME TITLE tblock4.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) tphtml.
PARAMETERS: phtml RADIOBUTTON GROUP g1 DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) tback.
PARAMETERS: pback AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) tptxt.
PARAMETERS: ptxt RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP.

* Download to SAP server
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) tserv.
PARAMETERS: pserv RADIOBUTTON GROUP g2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 8(20) tspath.
PARAMETERS: plogical LIKE filename-fileintern MEMORY ID mlogical.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN COMMENT /28(60) tsdpath.

* Download to PC
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) tpc.
PARAMETERS: ppc RADIOBUTTON GROUP g2 DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 8(20) tppath.
PARAMETERS: pfolder LIKE rlgrap-filename MEMORY ID mfolder.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK b4.

* Display options
SELECTION-SCREEN: BEGIN OF BLOCK b5 WITH FRAME TITLE tblock5.
* Display final report
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) trep.
PARAMETERS: prep AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
* Display progress messages
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) tpromess.
PARAMETERS: ppromess AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK b5.

*-------------------------------------------------------------------------------------------- --------------------------
* Display a directory picker window
*-------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfolder.

  DATA: objfile TYPE REF TO cl_gui_frontend_services.
  DATA: pickedfolder TYPE string.
  DATA: initialfolder TYPE string.

  IF sy-batch IS INITIAL.
    CREATE OBJECT objfile.

    IF NOT pfolder IS INITIAL.
      initialfolder = pfolder.
    ELSE.
      objfile->get_temp_directory( CHANGING temp_dir = initialfolder
                                   EXCEPTIONS cntl_error = 1
                                             error_no_gui = 2
                                             not_supported_by_gui = 3 ).
    ENDIF.

    objfile->directory_browse( EXPORTING initial_folder = initialfolder
                               CHANGING selected_folder = pickedfolder
                               EXCEPTIONS cntl_error = 1
                                          error_no_gui = 2
                                          not_supported_by_gui = 3 ).

    IF sy-subrc = 0.
      pfolder = pickedfolder.
    ELSE.
      WRITE: / 'An error has occured picking a folder'.
    ENDIF.
  ENDIF.

*-------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN.
*-------------------------------------------------------------------------------------------- --------------------------
  CASE 'X'.
    WHEN ppc.
      IF pfolder IS INITIAL.
*       User must enter a path to save to
        MESSAGE e000(oo) WITH 'You must enter a file path'.
      ENDIF.

    WHEN pserv.
      IF plogical IS INITIAL.
*       User must enter a logical path to save to
        MESSAGE e000(oo) WITH 'You must enter a logical file name'.
      ENDIF.
  ENDCASE.

*-------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON plogical.
*-------------------------------------------------------------------------------------------- --------------------------
  IF NOT pserv IS INITIAL.
    CALL FUNCTION 'FILE_GET_NAME'
      EXPORTING
        logical_filename = plogical
      IMPORTING
        file_name        = serverfolder
      EXCEPTIONS
        file_not_found   = 1
        OTHERS           = 2.
    IF sy-subrc = 0.
      IF serverfolder IS INITIAL.
        MESSAGE e000(oo) WITH 'No file path returned from logical filename'.
      ELSE.
*       Path to display on the selection screen
        tsdpath = serverfolder.
*       Remove the trailing slash off the path as the subroutine buildFilename will add an  extra one
        SHIFT serverfolder RIGHT DELETING TRAILING serverslashseparator.
        SHIFT serverfolder LEFT DELETING LEADING space.
      ENDIF.
    ELSE.
      MESSAGE e000(oo) WITH 'Logical filename does not exist'.
    ENDIF.
  ENDIF.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR soprog-low.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
    EXPORTING
      object_type           = 'PROG'
      object_name           = soprog-low
      suppress_selection    = 'X'
      use_alv_grid          = ''
      without_personal_list = ''
    IMPORTING
      object_name_selected  = soprog-low
    EXCEPTIONS
      cancel                = 1.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR soprog-high.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
    EXPORTING
      object_type           = 'PROG'
      object_name           = soprog-high
      suppress_selection    = 'X'
      use_alv_grid          = ''
      without_personal_list = ''
    IMPORTING
      object_name_selected  = soprog-high
    EXCEPTIONS
      cancel                = 1.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR soclass-low.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'F4_DD_ALLTYPES'
    EXPORTING
      object               = soclass-low
      suppress_selection   = 'X'
      display_only         = ''
      only_types_for_clifs = 'X'
    IMPORTING
      result               = soclass-low.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR soclass-high.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'F4_DD_ALLTYPES'
    EXPORTING
      object               = soclass-high
      suppress_selection   = 'X'
      display_only         = ''
      only_types_for_clifs = 'X'
    IMPORTING
      result               = soclass-high.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofname-low.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
    EXPORTING
      object_type           = 'FUNC'
      object_name           = sofname-low
      suppress_selection    = 'X'
      use_alv_grid          = ''
      without_personal_list = ''
    IMPORTING
      object_name_selected  = sofname-low
    EXCEPTIONS
      cancel                = 1.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofname-high.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
    EXPORTING
      object_type           = 'FUNC'
      object_name           = sofname-high
      suppress_selection    = 'X'
      use_alv_grid          = ''
      without_personal_list = ''
    IMPORTING
      object_name_selected  = sofname-high
    EXCEPTIONS
      cancel                = 1.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofgroup-low.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
    EXPORTING
      object_type           = 'FUGR'
      object_name           = sofgroup-low
      suppress_selection    = 'X'
      use_alv_grid          = ''
      without_personal_list = ''
    IMPORTING
      object_name_selected  = sofgroup-low
    EXCEPTIONS
      cancel                = 1.

* ------------------------------------------------------------------------------------------- --------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofgroup-high.
* ------------------------------------------------------------------------------------------- --------------------------
  CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
    EXPORTING
      object_type           = 'FUGR'
      object_name           = sofgroup-high
      suppress_selection    = 'X'
      use_alv_grid          = ''
      without_personal_list = ''
    IMPORTING
      object_name_selected  = sofgroup-high
    EXCEPTIONS
      cancel                = 1.

*-------------------------------------------------------------------------------------------- --------------------------
* initialisation
*-------------------------------------------------------------------------------------------- --------------------------
INITIALIZATION.
* Parameter screen texts.
  tblock1 = 'Author (Optional)'.
  tblock2 = 'Objects to download'.
  tblock3 = 'Additional downloads for programs, function modules and classes'.
  tblock4 = 'Download parameters'.
  tblock5 = 'Display options'.
  tauth   = 'Author name'.
  tpmod   = 'Include programs modified by author'.
  tcust   = 'Only customer objects'.
  tnrange = 'Alt customer name range'.
  trtable = 'Tables / Structures'.
  tptable = 'Table name'.
  ttnote  = 'Note: tables are stored under the username of the last person who modified them'.
  trfunc  = 'Function modules'.
  tpfname = 'Function name'.
  tfgroup = 'Function group'.
  trclass  = 'Classes'.
  tpcname = 'Class name'.
  tmess   = 'Message class'.
  tmname  = 'Class name'.
  tmlang  = 'Language'.
  tprog   = 'Programs'.
  trpname = 'Program name'.
  tpack   = 'Package'.
  tptxt   = 'Text document'.
  tphtml  = 'HTML document'.
  tback   = 'Include background colour'.
  tptext  = 'Text elements'.
  tpinc   = 'Include programs'.
  treci   = 'Recursive search'.
  tppath  = 'File path'.
  tspath  = 'Logical file name'.
  tpmes   = 'Message classes'.
  tpfunc  = 'Function modules'.
  tfdoc    = 'Function module documentation'.
  tcdoc    = 'Class documentation'.
  trecf   = 'Recursive search'.
  trecc   = 'Class recursive search'.
  tpscr   = 'Screens'.
  tpdict  = 'Dictionary structures'.
  tsortt  = 'Sort table fields alphabetically'.
  tserv   = 'Download to server'.
  tpc     = 'Download to PC'.
  trep    = 'Display download report'.
  tpromess  = 'Display progress messages'.

* Determine the frontend operating system type.
  IF sy-batch IS INITIAL.
    PERFORM determinefrontendopsystem USING frontendslashseparator frontendopsystem.
  ENDIF.
  PERFORM determineserveropsystem USING serverslashseparator serverfilesystem serveropsystem.

* Determine if the external command exists.  If it doesn't then disable the server input field
  PERFORM findexternalcommand USING serverfilesystem.

*-------------------------------------------------------------------------------------------- --------------------------
START-OF-SELECTION.
*-------------------------------------------------------------------------------------------- --------------------------
  PERFORM checkcomboboxes.
  PERFORM fillselectionranges.
  starttime = sy-uzeit.

* Don't display status messages if we are running in the background
  IF NOT sy-batch IS INITIAL.
    ppromess = ''.
  ENDIF.

* Fool the HTML routines to stop them hyperlinking anything with a space in them
  IF pcname IS INITIAL.
    customernamespace  = '^'.
  ELSE.
    customernamespace = pcname.
  ENDIF.

* Set the file extension and output type of the file
  IF ptxt IS INITIAL.
    downloadfileextension = htmlextension.
  ELSE.
    downloadfileextension = textextension.
  ENDIF.

* Determine which operating slash and download directory to use
  CASE 'X'.
    WHEN ppc.
      slashseparatortouse = frontendslashseparator.
      downloadfolder = pfolder.
    WHEN pserv.
      slashseparatortouse = serverslashseparator.
      downloadfolder = serverfolder.
  ENDCASE.

* Main program flow.
  CASE 'X'.
*   Select tables
    WHEN rtable.
      PERFORM retrievetables USING idictionary[]
                                   sotablenames[]
                                   soauthor[]
                                   sopack[].

*   Select message classes tables
    WHEN rmess.
      PERFORM retrievemessageclass USING imessages[]
                                         soauthor[]      "Author
                                         pmname          "Message class name
                                         pmlang          "Message class language
                                         pmod            "Modified by author
                                         sopack[].       "Package

*   Select function modules
    WHEN rfunc.
      PERFORM retrievefunctions USING sofunctionname[]   "Function name
                                      sofunctiongroup[]  "Function group
                                      ifunctions[]       "Found functions
                                      soauthor[]         "Author
                                      ptext              "Get text elements
                                      pscr               "Get screens
                                      pcust              "Customer data only
                                      customernamespace  "Customer name range
                                      sopack[].             "Package


      LOOP AT ifunctions.
*       Find Dict structures, messages, functions, includes etc.
        PERFORM scanforadditionalfuncstuff USING ifunctions[]
                                                 preci                   "Search for includes  recursively
                                                 precf                   "Search for functions  recursively
                                                 pinc                    "Search for includes
                                                 pfunc                   "Search for functions
                                                 pdict                   "search for  dictionary objects
                                                 pmess                   "Search for messages
                                                 pcust                   "Customer data only
                                                 customernamespace.      "Customer name range
      ENDLOOP.

*   Select Classes
    WHEN rclass.
      PERFORM retrieveclasses USING iclasses[]
                                    ifunctions[]
                                    soclassname[]       "Class name
                                    soauthor[]          "Author
                                    customernamespace   "Customer name range
                                    pmod                "Also modified by author
                                    pcust               "Customer object only
                                    pmess               "Find messages
                                    ptext               "Text Elements
                                    pdict               "Dictionary structures
                                    pfunc               "Get functions
                                    pinc                "Get includes
                                    precf               "Search recursively for functions
                                    preci               "Search recursively for includes
                                    precc               "Search recursively for classes
                                    pmlang              "Language
                                    sopack[].           "Package

      LOOP AT ifunctions.
*       Find Dict structures, messages, functions, includes etc.
        PERFORM scanforadditionalfuncstuff USING ifunctions[]
                                                 preci                   "Search for includes  recursively
                                                 precf                   "Search for functions  recursively
                                                 pinc                    "Search for includes
                                                 pfunc                   "Search for functions
                                                 pdict                   "search for  dictionary objects
                                                 pmess                   "Search for messages
                                                 pcust                   "Customer data only
                                                 customernamespace.      "Customer name range
      ENDLOOP.

*   Select programs
    WHEN rprog.
      PERFORM retrieveprograms USING iprograms[]
                                     iprogfunctions[]
                                     soprogramname[]    "Program name
                                     soauthor[]         "Author
                                     customernamespace  "Customer name range
                                     pmod               "Also modified by author
                                     pcust              "Customer object only
                                     pmess              "Find messages
                                     ptext              "Text Elements
                                     pdict              "Dictionay structures
                                     pfunc              "Get functions
                                     pinc               "Get includes
                                     pscr               "Get screens
                                     precf              "Search recursively for functions
                                     preci              "Search recursively for includes
                                     sopack[].             "Package
  ENDCASE.

*-------------------------------------------------------------------------------------------- --------------------------
END-OF-SELECTION.
*-------------------------------------------------------------------------------------------- --------------------------
  IF forcedexit = 0.
*   Decide what to download
    CASE 'X'.
*     Download tables
      WHEN rtable.
        IF NOT ( idictionary[] IS INITIAL ).
          PERFORM downloadddstructures USING idictionary[]
                                             downloadfolder
                                             htmlextension
                                             space
                                             psortt
                                             slashseparatortouse
                                             pserv
                                             ppromess
                                             serverfilesystem
                                             pback.
        ENDIF.

*     Download message class
      WHEN rmess.
        IF NOT ( imessages[] IS INITIAL ).
          SORT imessages ASCENDING BY arbgb msgnr.
          LOOP AT imessages.
            APPEND imessages TO isinglemessageclass.
            AT END OF arbgb.
              PERFORM downloadmessageclass USING isinglemessageclass[]
                                                 imessages-arbgb
                                                 downloadfolder
                                                 downloadfileextension
                                                 phtml
                                                 space
                                                 customernamespace
                                                 pinc
                                                 pdict
                                                 pmess
                                                 slashseparatortouse
                                                 pserv
                                                 ppromess
                                                 serverfilesystem
                                                 pback.
              CLEAR isinglemessageclass[].
            ENDAT.
          ENDLOOP.
        ENDIF.

*     Download functions
      WHEN rfunc.
        IF NOT ( ifunctions[] IS INITIAL ).
          PERFORM downloadfunctions USING ifunctions[]
                                          downloadfolder
                                          downloadfileextension
                                          space
                                          pfdoc
                                          phtml
                                          customernamespace
                                          pinc
                                          pdict
                                          textextension
                                          htmlextension
                                          psortt
                                          slashseparatortouse
                                          pserv
                                          ppromess
                                          serverfilesystem
                                          pback.
        ENDIF.

*     Download Classes
      WHEN rclass.
        IF NOT ( iclasses[] IS INITIAL ).
          PERFORM downloadclasses USING iclasses[]
                                        ifunctions[]
                                        downloadfolder
                                        downloadfileextension
                                        htmlextension
                                        textextension
                                        phtml
                                        customernamespace
                                        pinc
                                        pdict
                                        pcdoc
                                        psortt
                                        slashseparatortouse
                                        pserv
                                        ppromess
                                        serverfilesystem
                                        pback.
        ENDIF.

*     Download programs
      WHEN rprog.
        IF NOT ( iprograms[] IS INITIAL ).
          PERFORM downloadprograms USING iprograms[]
                                         iprogfunctions[]
                                         downloadfolder
                                         downloadfileextension
                                         htmlextension
                                         textextension
                                         phtml
                                         customernamespace
                                         pinc
                                         pdict
                                         '' "Documentation
                                         psortt
                                         slashseparatortouse
                                         pserv
                                         ppromess
                                         serverfilesystem
                                         pback.
        ENDIF.
    ENDCASE.

*   Free all the memory IDs we may have built up in the program
*   Free up any memory used for caching HTML versions of objects
    PERFORM freememory USING iprograms[]
                             ifunctions[]
                             iprogfunctions[]
                             idictionary[].

    IF NOT prep IS INITIAL.
      GET TIME.
      runtime = sy-uzeit - starttime.

      CASE 'X'.
        WHEN rtable.
          PERFORM filltreenodetables USING idictionary[]
                                           itreedisplay[]
                                           runtime.

        WHEN rmess.
          PERFORM filltreenodemessages USING imessages[]
                                             itreedisplay[]
                                             runtime.


        WHEN rfunc.
          PERFORM filltreenodefunctions USING ifunctions[]
                                              itreedisplay[]
                                              runtime.

        WHEN rclass.
          PERFORM filltreenodeclasses USING iclasses[]
                                            ifunctions[]
                                            itreedisplay[]
                                            runtime.

        WHEN rprog.
          PERFORM filltreenodeprograms USING iprograms[]
                                             iprogfunctions[]
                                             itreedisplay[]
                                             runtime.
      ENDCASE.

      IF NOT ( itreedisplay[] IS INITIAL ).
        PERFORM displaytree USING itreedisplay[].
      ELSE.
        statusbarmessage = 'No items found matching selection criteria'.
        PERFORM displaystatus USING statusbarmessage 2.
      ENDIF.
    ENDIF.
  ENDIF.

* Clear out all the internal tables
  CLEAR iprograms[].
  CLEAR ifunctions[].
  CLEAR iclasses[].
  CLEAR iprogfunctions[].
  CLEAR imessages[].
  CLEAR idictionary[].

*--- Memory IDs
* User name
  SET PARAMETER ID 'MAUTH' FIELD pauth.
* Message class
  SET PARAMETER ID 'MMNAME' FIELD pmname.
* Customer namespace
  SET PARAMETER ID 'MNAMESPACE' FIELD pcname.
* Folder
  SET PARAMETER ID 'MFOLDER' FIELD pfolder.
* Logical filepath
  SET PARAMETER ID 'MLOGICAL' FIELD plogical.
* Text element checkbox
  SET PARAMETER ID 'MTEXT' FIELD ptext.
* Messages checkbox
  SET PARAMETER ID 'MMESS' FIELD pmess.
* Includes checkbox
  SET PARAMETER ID 'MINC' FIELD pinc.
* Recursive includes checkbox.
  SET PARAMETER ID 'MRECI' FIELD preci.
* Functions checkbox
  SET PARAMETER ID 'MFUNC' FIELD pfunc.
* Recursive functions checkbox
  SET PARAMETER ID 'MRECF' FIELD precf.
* Recursive classes checkbox
  SET PARAMETER ID 'MRECF' FIELD precc.
* Function module documentation checkbox
  SET PARAMETER ID 'MFDOC' FIELD pfdoc.
* Class documentation checkbox
  SET PARAMETER ID 'MCDOC' FIELD pcdoc.
* Screens checkbox
  SET PARAMETER ID 'MSCR' FIELD pscr.
* Dictionary checkbox
  SET PARAMETER ID 'MDICT' FIELD pdict.
* Sort table ascending checkBox
  SET PARAMETER ID 'MSORTT' FIELD psortt.


********************************************************************************************** *************************
***************************************************SUBROUTINES******************************** *************************
********************************************************************************************** *************************

*-------------------------------------------------------------------------------------------- --------------------------
*  free memory...
*-------------------------------------------------------------------------------------------- --------------------------
FORM freememory USING ilocprograms LIKE iprograms[]
                      ilocfunctions LIKE ifunctions[]
                      ilocprogfunctions LIKE iprogfunctions[]
                      ilocdictionary LIKE idictionary[].

  FIELD-SYMBOLS: <wafunction> LIKE LINE OF ilocfunctions.
  FIELD-SYMBOLS: <waprogram> LIKE LINE OF ilocprograms.
  FIELD-SYMBOLS: <wadictstruct> TYPE tdicttable.

  LOOP AT ilocfunctions ASSIGNING <wafunction>.
    LOOP AT <wafunction>-idictstruct ASSIGNING <wadictstruct>.
      FREE MEMORY ID <wadictstruct>-tablename.
    ENDLOOP.
  ENDLOOP.

  LOOP AT ilocprogfunctions ASSIGNING <wafunction>.
    LOOP AT <wafunction>-idictstruct ASSIGNING <wadictstruct>.
      FREE MEMORY ID <wadictstruct>-tablename.
    ENDLOOP.
  ENDLOOP.

  LOOP AT ilocprograms ASSIGNING <waprogram>.
    LOOP AT <waprogram>-idictstruct ASSIGNING <wadictstruct>.
      FREE MEMORY ID <wadictstruct>-tablename.
    ENDLOOP.
  ENDLOOP.

  LOOP AT ilocdictionary ASSIGNING <wadictstruct>.
    FREE MEMORY ID <wadictstruct>-tablename.
  ENDLOOP.
ENDFORM.                    "FREEMEMORY

*-------------------------------------------------------------------------------------------- --------------------------
*  checkComboBoxes...  Check input parameters
*-------------------------------------------------------------------------------------------- --------------------------
FORM checkcomboboxes.

  IF pauth IS INITIAL.
    IF sopack[] IS INITIAL.
      CASE 'X'.
        WHEN rtable.
          IF sotable[] IS INITIAL.
            statusbarmessage = 'You must enter either a table name or author.'.
          ENDIF.
        WHEN rfunc.
          IF ( sofname[] IS INITIAL ) AND ( sofgroup[] IS INITIAL ).
            IF sofname[] IS INITIAL.
              statusbarmessage = 'You must enter either a function name or author.'.
            ELSE.
              IF sofgroup[] IS INITIAL.
                statusbarmessage = 'You must enter either a function group, or an author  name.'.
              ENDIF.
            ENDIF.
          ENDIF.
        WHEN rprog.
          IF soprog[] IS INITIAL.
            statusbarmessage = 'You must enter either a program name or author name.'.
          ENDIF.
      ENDCASE.
    ENDIF.
  ELSE.
*   Check the user name of the person objects are to be downloaded for
    IF pauth = 'SAP*' OR pauth = 'SAP'.
      statusbarmessage = 'Sorry cannot download all objects for SAP standard user'.
    ENDIF.
  ENDIF.

  IF NOT statusbarmessage IS INITIAL.
    PERFORM displaystatus USING statusbarmessage 3.
    forcedexit = 1.
    STOP.
  ENDIF.
ENDFORM.                                                                                 "checkComboBoxes

*-------------------------------------------------------------------------------------------- --------------------------
* fillSelectionRanges...      for selection routines
*-------------------------------------------------------------------------------------------- --------------------------
FORM fillselectionranges.

  DATA: strlength TYPE i.

  strlength = strlen( pcname ).

  IF NOT pauth IS INITIAL.
    soauthor-sign = 'I'.
    soauthor-option = 'CP'.
    soauthor-low = '*'.
    APPEND soauthor.
  ENDIF.

* Tables
  IF NOT sotable IS INITIAL.
    sotablenames[] = sotable[].
*   Add in the customer namespace if we need to
    IF NOT pcname IS INITIAL.
      LOOP AT sotablenames.
        IF sotablenames-low+0(strlength) <> pcname.
          CONCATENATE pcname sotablenames-low INTO sotablenames-low.
        ENDIF.

        IF sotablenames-high+0(strlength) <> pcname.
          CONCATENATE pcname sotablenames-high INTO sotablenames-high.
        ENDIF.

        MODIFY sotablenames.
      ENDLOOP.
    ENDIF.
  ENDIF.

* Function names
  IF NOT sofname IS INITIAL.
    sofunctionname[] = sofname[].
*   Add in the customer namespace if we need to
    IF NOT pcname IS INITIAL.
      LOOP AT sofunctionname.
        IF sofunctionname-low+0(strlength) <> pcname.
          CONCATENATE pcname sofunctionname-low INTO sofunctionname-low.
        ENDIF.

        IF sofunctionname-high+0(strlength) <> pcname.
          CONCATENATE pcname sofunctionname-high INTO sofunctionname-high.
        ENDIF.

        MODIFY sofunctionname.
      ENDLOOP.
    ENDIF.
  ENDIF.

* Function group
  IF NOT sofgroup IS INITIAL.
    sofunctiongroup[] = sofgroup[].
*   Add in the customer namespace if we need to
    IF NOT pcname IS INITIAL.
      LOOP AT sofunctionname.
        IF sofunctiongroup-low+0(strlength) <> pcname.
          CONCATENATE pcname sofunctiongroup-low INTO sofunctiongroup-low.
        ENDIF.

        IF sofunctiongroup-high+0(strlength) <> pcname.
          CONCATENATE pcname sofunctiongroup-high INTO sofunctiongroup-high.
        ENDIF.

        MODIFY sofunctiongroup.
      ENDLOOP.
    ENDIF.
  ENDIF.

* Class names
  IF NOT soclass IS INITIAL.
    soclassname[] = soclass[].
*   Add in the customer namespace if we need to
    IF NOT pcname IS INITIAL.
      LOOP AT soclassname.
        IF soclassname-low+0(strlength) <> pcname.
          CONCATENATE pcname soclassname-low INTO soclassname-low.
        ENDIF.

        IF soclassname-high+0(strlength) <> pcname.
          CONCATENATE pcname soclassname-high INTO soclassname-high.
        ENDIF.

        MODIFY soclassname.
      ENDLOOP.
    ENDIF.
  ENDIF.

* Program names
  IF NOT soprog IS INITIAL.
    soprogramname[] = soprog[].
*   Add in the customer namespace if we need to
    IF NOT pcname IS INITIAL.
      LOOP AT soprogramname.
        IF soprogramname-low+0(strlength) <> pcname.
          CONCATENATE pcname soprogramname-low INTO soprogramname-low.
        ENDIF.

        IF soprogramname-high+0(strlength) <> pcname.
          CONCATENATE pcname soprogramname-high INTO soprogramname-high.
        ENDIF.

        MODIFY soprogramname.
      ENDLOOP.
    ENDIF.
  ENDIF.
ENDFORM.                                                                                           " fillSelectionRanges

*------------------------------------------------------------------------
本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到