ABAP源代码下载-可惜不能把报表、结构、samrtforms导出来


*&---------------------------------------------------------------------*
*& Report  YGJH003
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  YGJH003 .
***这个程序在405版本测试通过 
*   1 可执行程序
*   I INCLUDE 程序
*   M 模块池
*   F 函数组
*   S 子程序池
*   J 接口池
*   K 类别库

TABLES TRDIR ,        "SYSTEM TABLE系统表
        TFDIR ,        "FUNCTION MODULE 功能模块
        TADIR ,        "DIRECTORY OF REPOSITORY OBJECTS资源库对象的目录
        D020T ,        "SCREEN SHORT DESCRIPTION屏幕短描述
        FUPARAREF ,    "功能模块参数
        FUNCT ,        "函数模块短文本
        D020S ,        "系统表 D020S (屏幕源码)
        D021S ,        "屏幕区域
***取程序的描述没有做这个功能,因此下面的表没有用上
        TRDIRT .       "TRDIR 中程序的标题文本
***定义获得REPORT信息的内表
DATA ITAB_REPORT  LIKE  TABLE  OF TRDIR  WITH  HEADER  LINE .

DATA TITLETXT  LIKE TRDIRT - TEXT .
***定义获得PROGRAM信息的内表
DATA ITAB_PROGRAM  LIKE  TABLE  OF TRDIR  WITH  HEADER  LINE .
***定义获得INCLUDE信息的内表
DATA ITAB_INCLUDE  LIKE  TABLE  OF TRDIR  WITH  HEADER  LINE .

***定义获得信息的内表,用于FUNCTION的处理
DATA TEMP  LIKE  TABLE  OF TFDIR  WITH  HEADER  LINE .

***定义获得FUNCTION信息的内表
DATA BEGIN  OF ITAB_FUNCTION  OCCURS  0 ,
         NAME  LIKE TRDIR -NAME ,          "FUNCTION在系统里真实的程序名
        PNAME  LIKE TFDIR -FUNCNAME ,      "FUNCTION在SE37里的名字
       END  OF ITAB_FUNCTION .

***定义获得FUNCTION PRARMATER信息的内表
DATA BEGIN  OF ITAB_PRARMATER  OCCURS  0 ,
             TEXT ( 10 ) ,
        PARAMETER  LIKE FUPARAREF - PARAMETER ,
             TYPE ( 4 ) ,
        STRUCTURE  LIKE FUPARAREF - STRUCTURE ,
           STEXT  LIKE FUNCT -STEXT ,
        END  OF ITAB_PRARMATER .

***定义存放代码的内表
DATA BEGIN  OF TABSOURCE  OCCURS  0 ,
      SOURCE ( 300 TYPE  C ,
       END  OF TABSOURCE .
*DATA: TABSOURCE LIKE STANDARD TABLE OF SOURCE_TAB.
***定义存放文本的内表
DATA BEGIN  OF TEXTSOURCE  OCCURS  0 .
       INCLUDE  STRUCTURE  TEXTPOOL .
DATA END  OF TEXTSOURCE .
DATA BEGIN  OF  TEXT  OCCURS  0 ,
      ZZID ( 1 ) ,
      ZKEY ( 8 ) ,
      ZENTRY ( 255 ) ,
      ZLENGTH ( 10 ) ,
       END  OF  TEXT .
*DATA: TEXT LIKE TABSOURCE OCCURS 0 WITH HEADER LINE.
*DATA: TEXTSOURCE LIKE STANDARD TABLE OF TABTEXT.

DATA SOURCEROWS  TYPE  I .
DATA FULLPATH  LIKE RLGRAP -FILENAME .

SELECTION-SCREEN  BEGIN  OF  BLOCK WIN  WITH  FRAME  TITLE TEXT1 .
SELECTION-SCREEN  BEGIN  OF  LINE .
SELECTION-SCREEN  COMMENT  5 ( 33 MENUA .
SELECTION-SCREEN  END  OF  LINE .

SELECTION-SCREEN  BEGIN  OF  LINE .
SELECTION-SCREEN  COMMENT  5 ( 33 MENUB .
SELECTION-SCREEN  POSITION  40 .
SELECT-OPTIONS REPO  FOR TRDIR -NAME OBLIGATORY .
SELECTION-SCREEN  END  OF  LINE .

SELECTION-SCREEN  BEGIN  OF  LINE .
SELECTION-SCREEN  COMMENT  19 ( 17 MENUC .
SELECTION-SCREEN  POSITION  43 .
PARAMETERS PATH  LIKE RLGRAP -FILENAME  DEFAULT  'E:\TMP' .
SELECTION-SCREEN  END  OF  LINE .
SELECTION-SCREEN  END  OF  BLOCK WIN .

SELECTION-SCREEN  BEGIN  OF  BLOCK WINA  WITH  FRAME  TITLE TEXT2 .
SELECTION-SCREEN  BEGIN  OF  LINE .
SELECTION-SCREEN  COMMENT  5 ( 12 MENUD .
SELECTION-SCREEN  POSITION  18 .
PARAMETERS PA  AS  CHECKBOX  DEFAULT  'X' .
SELECTION-SCREEN  COMMENT  24 ( 12 MENUE .
SELECTION-SCREEN  POSITION  37 .
PARAMETERS PB  AS  CHECKBOX  DEFAULT  'X' .
SELECTION-SCREEN  COMMENT  43 ( 12 MENUF .
SELECTION-SCREEN  POSITION  56 .
PARAMETERS PC  AS  CHECKBOX  DEFAULT  'X' .
SELECTION-SCREEN  COMMENT  62 ( 12 MENUG .
SELECTION-SCREEN  POSITION  75 .
PARAMETERS PD  AS  CHECKBOX  DEFAULT  'X' .
SELECTION-SCREEN  END  OF  LINE .
SELECTION-SCREEN  END  OF  BLOCK WINA .

*&--------------------------------------------------------------------*
* INITIALIZATION.
*&--------------------------------------------------------------------*
INITIALIZATION .
 TEXT1  'SELECT OPTION' .
 TEXT2  'FURTHER OPTION' .
 MENUA  '选择要下载的' .
 MENUB  'PROGRAM/FUNCTION/REPORT等的名字:' .
 MENUC  '选择要保存的路径:' .
 MENUD  '  REPORT代码' .
 MENUE  ' PROGRAM代码' .
 MENUF  'FUNCTION代码' .
 MENUG  ' INCLUDE代码' .
 REPO -LOW  'Z*' .
  APPEND REPO .

AT  SELECTION-SCREEN  ON  VALUE-REQUEST  FOR PATH .
  DATA FOLDER  TYPE STRING .
  CALL  METHOD CL_GUI_FRONTEND_SERVICES =>DIRECTORY_BROWSE
     EXPORTING
      WINDOW_TITLE     'SELECT SAVE DIRECTORY'
      INITIAL_FOLDER   'E:\'
     CHANGING
      SELECTED_FOLDER  FOLDER .
  CHECK  NOT FOLDER  IS  INITIAL .
  MOVE FOLDER  TO PATH .

START-OF-SELECTION .
CONCATENATE PATH  '\'  INTO PATH .
CONDENSE PATH  NO -GAPS .
IF  NOT REPO -LOW  IS  INITIAL .
    REPLACE  '*'  WITH  '%'  INTO REPO -LOW .
ENDIF .
IF  NOT REPO -HIGH  IS  INITIAL .
    REPLACE  '*'  WITH  '%'  INTO REPO -HIGH .
ENDIF .
IF PA  'X' .      "REPORT代码
   CALL  FUNCTION  'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
            PERCENTAGE  0
             TEXT        '下载REPORT数据中......'
        EXCEPTIONS
             OTHERS      1 .
    PERFORM GET_REPORT .
ENDIF .
IF PB  'X' .      "PROGRAM代码
   CALL  FUNCTION  'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
            PERCENTAGE  0
             TEXT        '下载PROGRAM数据中......'
        EXCEPTIONS
             OTHERS      1 .
    PERFORM GET_PROGRAM .
ENDIF .
IF PC  'X' .      "FUNCTION代码
   CALL  FUNCTION  'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
            PERCENTAGE  0
             TEXT        '下载FUNCTION数据中......'
        EXCEPTIONS
             OTHERS      1 .
    PERFORM GET_FUNCTION .
ENDIF .
IF PD  'X' .      "INCLUDE代码
   CALL  FUNCTION  'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
            PERCENTAGE  0
             TEXT        '下载INCLUDE数据中......'
        EXCEPTIONS
             OTHERS      1 .
    PERFORM GET_INCLUDE .
ENDIF .


***获得FUNCTION并输出

FORM GET_FUNCTION .           "得到想要输出的FUNCTION名称
CLEAR ITAB_FUNCTION ,ITAB_FUNCTION[] .
SELECT FROM TFDIR  INTO  TABLE TEMP  WHERE FUNCNAME  IN REPO .
LOOP  AT TEMP .
  ITAB_FUNCTION -PNAME  TEMP -FUNCNAME .
   REPLACE  'SAPL'  WITH SPACE  INTO TEMP -PNAME .
   CONDENSE TEMP -PNAME .
*下面有2种做法,一种是取全部的FUNCTION版本,另一种只取激活的FUNCTION版本
*第一种做法,只取激活的FUNCTION版本.
   CONCATENATE  'L' TEMP -PNAME  'U' TEMP - INCLUDE  INTO ITAB_FUNCTION -NAME .
   APPEND ITAB_FUNCTION .
*第二种做法,取全部的FUNCTION版本.
*  CONCATENATE 'L' TEMP-PNAME 'U0%' INTO TEMP-PNAME.
*  SELECT * FROM TRDIR WHERE NAME LIKE TEMP-PNAME.
*     ITAB_FUNCTION-NAME = TRDIR-NAME.
*     APPNED ITAB_FUNCTION.
*  ENDSELECT.
ENDLOOP .
SORT ITAB_FUNCTION  BY NAME .
IF  NOT ITAB_FUNCTION[]  IS  INITIAL .
    PERFORM DOWN_FUNCTION .
    PERFORM DOWN_FUNCTION_PARAMATER .
ENDIF .
ENDFORM .                     " GET_FUNCTION

FORM DOWN_FUNCTION .           "下载FUNCTION的代码
LOOP  AT ITAB_FUNCTION .
  READ  REPORT ITAB_FUNCTION -NAME  INTO TABSOURCE .
  DESCRIBE  TABLE TABSOURCE  LINES SOURCEROWS .
  CHECK SOURCEROWS >  0 .
  CONDENSE ITAB_FUNCTION -NAME  NO -GAPS .
  CALL  FUNCTION  'STRING_CONCATENATE_3'
       EXPORTING
           STRING1  PATH
           STRING2  ITAB_FUNCTION -NAME
           STRING3  '.FUN'
       IMPORTING
           STRING  FULLPATH
       EXCEPTIONS
           TOO_SMALL  01 .
  CONDENSE FULLPATH  NO -GAPS .
  CALL  FUNCTION  'WS_DOWNLOAD'
    EXPORTING
     CODEPAGE             '8400'
     FILENAME             FULLPATH
     FILETYPE             'ASC'
    TABLES
     DATA_TAB             TABSOURCE .
ENDLOOP .
ENDFORM .                     " DOWN_FUNCTION

FORM DOWN_FUNCTION_PARAMATER .          "下载FUNCTION的参数
LOOP  AT ITAB_FUNCTION .
     CLEAR ITAB_PRARMATER . CLEAR ITAB_PRARMATER[] .
     SELECT FROM FUNCT  WHERE FUNCNAME  ITAB_FUNCTION -PNAME
***FUNCTION的参数是在登陆语言环境下维护的,因此一定选择语言减小范围
                           AND    SPRAS  SY -LANGU
                           AND     KIND  'P' .
        ITAB_PRARMATER -STEXT  FUNCT -STEXT .
         SELECT  SINGLE FROM FUPARAREF  WHERE FUNCNAME  FUNCT -FUNCNAME
                                          AND  PARAMETER  FUNCT - PARAMETER
                                          AND R3STATE  'A' .    "取激活版本
           IF SY -SUBRC  0 .
             CASE FUPARAREF -PARAMTYPE .
                WHEN  'E' .
                 ITAB_PRARMATER - TEXT  'EXPORT' .
                WHEN  'X' .
                 ITAB_PRARMATER - TEXT  'EXCEPTION' .
                WHEN  'I' .
                 ITAB_PRARMATER - TEXT  'IMPORT' .
                WHEN  'T' .
                 ITAB_PRARMATER - TEXT  'TABLE' .
                WHEN  'C' .
                 ITAB_PRARMATER - TEXT  'CHANGING' .
              ENDCASE .
             ITAB_PRARMATER - PARAMETER  FUPARAREF - PARAMETER .
             ITAB_PRARMATER - TYPE  'LIKE' .
             ITAB_PRARMATER - STRUCTURE  FUPARAREF - STRUCTURE .
             APPEND ITAB_PRARMATER .
           ENDIF .
     ENDSELECT .
  DESCRIBE  TABLE ITAB_PRARMATER  LINES SOURCEROWS .
  CHECK SOURCEROWS >  0 .
  CONDENSE ITAB_FUNCTION -PNAME  NO -GAPS .
  CALL  FUNCTION  'STRING_CONCATENATE_3'
       EXPORTING
           STRING1  PATH
           STRING2  ITAB_FUNCTION -PNAME
           STRING3  '.PAR'
       IMPORTING
           STRING  FULLPATH
       EXCEPTIONS
           TOO_SMALL  01 .
  CONDENSE FULLPATH  NO -GAPS .
  CALL  FUNCTION  'WS_DOWNLOAD'
    EXPORTING
     CODEPAGE             '8400'
     FILENAME             FULLPATH
     FILETYPE             'ASC'
    TABLES
     DATA_TAB             ITAB_PRARMATER
    EXCEPTIONS
     FILE_OPEN_ERROR      1
     FILE_WRITE_ERROR     2
     INVALID_FILESIZE     3
     INVALID_TABLE_WIDTH  4
     INVALID_TYPE         5
     NO_BATCH             6
     UNKNOWN_ERROR        7 .
ENDLOOP .
ENDFORM .                     " DOWN_FUNCTION_PARAMATER

***获得PROGRAM并输出

FORM GET_PROGRAM .            ""得到想要输出的PROGRAM名称
CLEAR ITAB_PROGRAM ,ITAB_PROGRAM[] .
SELECT FROM TRDIR  INTO  TABLE ITAB_PROGRAM  WHERE NAME  IN REPO
                                               AND SUBC  'M' .
SORT ITAB_PROGRAM  BY NAME .
IF  NOT ITAB_PROGRAM[]  IS  INITIAL .
    PERFORM DOWN_PROGRAM .
    PERFORM DOWN_PROGRAM_TEXT .
    PERFORM DOWN_PROGRAM_SCREEN .
ENDIF .
ENDFORM .                     " GET_PROGRAM


FORM DOWN_PROGRAM .            "下载PROGRAM代码
LOOP  AT ITAB_PROGRAM .
  READ  REPORT ITAB_PROGRAM -NAME  INTO TABSOURCE .
  DESCRIBE  TABLE TABSOURCE  LINES SOURCEROWS .
  CHECK SOURCEROWS >  0 .
  CONDENSE ITAB_PROGRAM -NAME  NO -GAPS .
  CALL  FUNCTION  'STRING_CONCATENATE_3'
       EXPORTING
           STRING1  PATH
           STRING2  ITAB_PROGRAM -NAME
           STRING3  '.PRO'
       IMPORTING
           STRING  FULLPATH
       EXCEPTIONS
           TOO_SMALL  01 .
  CONDENSE FULLPATH  NO -GAPS .
  CALL  FUNCTION  'WS_DOWNLOAD'
    EXPORTING
     CODEPAGE             '8400'
     FILENAME             FULLPATH
     FILETYPE             'ASC'
    TABLES
     DATA_TAB             TABSOURCE .
ENDLOOP .
ENDFORM .                     " DOWN_PROGRAM

FORM DOWN_PROGRAM_TEXT .         "下载PROGRAM的文本描述
LOOP  AT ITAB_PROGRAM .
  READ  TEXTPOOL ITAB_PROGRAM -NAME  INTO TEXTSOURCE .
  DESCRIBE  TABLE TEXTSOURCE  LINES SOURCEROWS .
  CHECK SOURCEROWS >  0 .
  CONDENSE ITAB_PROGRAM -NAME  NO -GAPS .
  CALL  FUNCTION  'STRING_CONCATENATE_3'
       EXPORTING
           STRING1  PATH
           STRING2  ITAB_PROGRAM -NAME
           STRING3  '.PRT'
       IMPORTING
           STRING  FULLPATH
       EXCEPTIONS
           TOO_SMALL  01 .
  CONDENSE FULLPATH  NO -GAPS .
  LOOP  AT TEXTSOURCE .
    TEXT -ZZID  TEXTSOURCE - ID .
    TEXT -ZENTRY  TEXTSOURCE -ENTRY .
    TEXT -ZKEY  TEXTSOURCE - KEY .
    TEXT -ZLENGTH  TEXTSOURCE -LENGTH .
*              INTO TEXT-SOURCE SEPARATED BY '  '.
   APPEND  TEXT .
  ENDLOOP .
  CALL  FUNCTION  'WS_DOWNLOAD'
    EXPORTING
     CODEPAGE             '8400'
     FILENAME             FULLPATH
     FILETYPE             'ASC'
    TABLES
     DATA_TAB             TEXT .
  CLEAR TEXT[] . CLEAR  TEXT .
  CLEAR TEXTSOURCE . CLEAR TEXTSOURCE[] .
ENDLOOP .
ENDFORM .                     " DOWN_PROGRAM_TEXT

***获得REPORT并输出

FORM GET_REPORT .           "得到想要输出的REPORT名称
CLEAR ITAB_REPORT ,ITAB_REPORT[] .
SELECT FROM TRDIR  INTO  TABLE ITAB_REPORT  WHERE NAME  IN REPO
                                              AND SUBC  '1' .
SORT ITAB_REPORT  BY NAME .
IF  NOT ITAB_REPORT[]  IS  INITIAL .
    PERFORM DOWN_REPORT .
*   PERFORM DOWN_REPORT_TEXT.
*   PERFORM DOWN_REPORT_SCREEN.
ENDIF .
ENDFORM .                     " GET_REPORT

FORM DOWN_REPORT .         "下载REPORT代码
LOOP  AT ITAB_REPORT .

   CLEAR TITLETXT .
   SELECT  SINGLE  TEXT  FROM TRDIRT  INTO TITLETXT
     WHERE NAME  ITAB_REPORT -NAME .
*  REPLACE ALL '/' WITH '' INTO TITLETXT.
   REPLACE  ALL  OCCURRENCES  OF  '/'  IN TITLETXT  WITH  '' .
   CONCATENATE ITAB_REPORT -NAME TITLETXT  INTO TITLETXT .

  READ  REPORT ITAB_REPORT -NAME  INTO TABSOURCE .
  DESCRIBE  TABLE TABSOURCE  LINES SOURCEROWS .
  CHECK SOURCEROWS >  0 .
  CONDENSE ITAB_REPORT -NAME  NO -GAPS .
  CALL  FUNCTION  'STRING_CONCATENATE_3'
       EXPORTING
           STRING1  PATH
*           STRING2 = ITAB_REPORT-NAME
           STRING2  TITLETXT
           STRING3  '.TXT'
       IMPORTING
           STRING  FULLPATH
       EXCEPTIONS
           TOO_SMALL  01 .
  CONDENSE FULLPATH  NO -GAPS .
***不用GUI_DOWNLOAD同样因为FILENAME类型必须是STRING,回增加代码和程序累赘
  CALL  FUNCTION  'WS_DOWNLOAD'
    EXPORTING
     CODEPAGE             '8400'
     FILENAME             FULLPATH
     FILETYPE             'ASC'
    TABLES
     DATA_TAB             TABSOURCE .
***CALL METHOD取下载很不实用可以参照下面格式
* CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
*      EXPORTING
*        FILENAME = FULLPATH     "FULLPATH必须是STRING类型
*        FILETYPE = 'ASC'
*      CHANGING
*        DATA_TAB = TABSOURCE.   "必须是无表头的内表
ENDLOOP .
ENDFORM .                     " DOWN_REPORT

FORM DOWN_REPORT_TEXT .         "下载REPORT的文本描述
LOOP  AT ITAB_REPORT .
  READ  TEXTPOOL ITAB_REPORT -NAME  INTO TEXTSOURCE .
  DESCRIBE  TABLE TEXTSOURCE  LINES SOURCEROWS .
  CHECK SOURCEROWS >  0 .
  CONDENSE ITAB_REPORT -NAME  NO -GAPS .
  CALL  FUNCTION  'STRING_CONCATENATE_3'
       EXPORTING
           STRING1  PATH
           STRING2  ITAB_REPORT -NAME
           STRING3  '.ABT'
       IMPORTING
           STRING  FULLPATH
       EXCEPTIONS
           TOO_SMALL  01 .
  CONDENSE FULLPATH  NO -GAPS .
  LOOP  AT TEXTSOURCE .
    TEXT -ZZID  TEXTSOURCE - ID .
    TEXT -ZENTRY  TEXTSOURCE -ENTRY .
    TEXT -ZKEY  TEXTSOURCE - KEY .
    TEXT -ZLENGTH  TEXTSOURCE -LENGTH .
*              INTO TEXT-SOURCE SEPARATED BY '  '.
   APPEND  TEXT .
  ENDLOOP .
  CALL  FUNCTION  'WS_DOWNLOAD'
    EXPORTING
     CODEPAGE             '8400'
     FILENAME             FULLPATH
     FILETYPE             'ASC'
    TABLES
     DATA_TAB             TEXT .
  CLEAR TEXT[] . CLEAR  TEXT .
  CLEAR TEXTSOURCE . CLEAR TEXTSOURCE[] .
ENDLOOP .
ENDFORM .                     " DOWN_REPORT_TEXT

FORM DOWN_PROGRAM_SCREEN .            "下载PROGRAM的SCREEN
   DATA ITAB_HEAD  LIKE D020S  OCCURS  WITH  HEADER  LINE .
   DATA ITAB_HEAD_TEMP  LIKE D020S .
   DATA E_G  TYPE DYN_FLOWLIST .
   DATA F_G  LIKE D021S  OCCURS  WITH  HEADER  LINE .
   DATA M_G  LIKE D023S  OCCURS  WITH  HEADER  LINE .

* DEFINITION FIELD SYMBOLS
   FIELD-SYMBOLS <FS>  TYPE  ANY .
   DATA  HEADER_CHAR  LIKE SCR_CHHEAD .
   DATA  DYNP_CHAR  LIKE SCR_CHFLD  OCCURS  WITH  HEADER  LINE .
   DATA  FIELDS_CHAR  LIKE SCR_CHFLD  OCCURS  WITH  HEADER  LINE .
   DATA  PROG_LEN      TYPE P .
* DEFINE CONSTANTS
   CONSTANTS HEADER_TEXT ( 8 )      VALUE  '%_HEADER' ,
             DYNPRO_TEXT ( 8 )      VALUE  '%_DYNPRO' ,
             DESCRIPT_TEXT ( 13 )   VALUE  '%_DESCRIPTION' ,
             STARS ( 64 )           VALUE  '****************************************************************' ,
             COMMENT1 ( 64 )        VALUE  '*                                                              *' ,
             COMMENT2 ( 64 )        VALUE  '*                                                              *' ,
             FIELDS_TEXT ( 8 )      VALUE  '%_FIELDS' ,
             PARAMS_TEXT ( 8 )      VALUE  '%_PARAMS' ,
             FLOWLOGIC_TEXT ( 11 VALUE  '%_FLOWLOGIC' .

LOOP  AT ITAB_PROGRAM .
   CLEAR ITAB_HEAD . CLEAR ITAB_HEAD[] .
   SELECT FROM D020S  INTO CORRESPONDING  FIELDS  OF  TABLE ITAB_HEAD
                                    WHERE PROG  ITAB_REPORT -NAME
                                      AND  TYPE  ' ' .
   LOOP  AT ITAB_HEAD .
      CLEAR ITAB_HEAD_TEMP .
      CLEAR E_G . CLEAR E_G[] .
      CLEAR F_G . CLEAR F_G[] .
      CLEAR M_G . CLEAR M_G[] .
      CLEAR HEADER_CHAR .
      MOVE-CORRESPONDING ITAB_HEAD  TO ITAB_HEAD_TEMP .
      CALL  FUNCTION  'RS_SCREEN_IMPORT'
           EXPORTING
             DYNNR         ITAB_HEAD -DNUM
             PROGNAME      ITAB_HEAD -PROG
             WANTED_MODE   'SHOW'            "可以是MODIFY,用来修改
           TABLES
             E_G           E_G
             F_G           F_G
             M_G           M_G
           EXCEPTIONS
             NOT_EXECUTED  1
             NOT_FOUND     2
              OTHERS        3 .

      CALL  FUNCTION  'RS_SCRP_HEADER_RAW_TO_CHAR'
           EXPORTING
             HEADER_INT   ITAB_HEAD_TEMP
           IMPORTING
             HEADER_CHAR  HEADER_CHAR
           EXCEPTIONS
              OTHERS       1 .
         REFRESH DYNP_CHAR .
*      说明信息,可以自定义
        DYNP_CHAR  STARS .     APPEND DYNP_CHAR .
        DYNP_CHAR  COMMENT1 APPEND DYNP_CHAR .
        DYNP_CHAR  COMMENT2 APPEND DYNP_CHAR .
        DYNP_CHAR  STARS .     APPEND DYNP_CHAR .
*      SCREEN的证明
        DYNP_CHAR  DYNPRO_TEXT .       APPEND DYNP_CHAR .
        DYNP_CHAR  HEADER_CHAR -PROG APPEND DYNP_CHAR .
        DYNP_CHAR  HEADER_CHAR -DNUM APPEND DYNP_CHAR .
        DYNP_CHAR  SY -SAPRL .          APPEND DYNP_CHAR .
         DESCRIBE  FIELD D020T -PROG LENGTH PROG_LEN  IN CHARACTER  MODE .
        DYNP_CHAR ( 16 PROG_LEN .      APPEND DYNP_CHAR .
*      SCREEN的HEADER
        DYNP_CHAR  HEADER_TEXT .       APPEND DYNP_CHAR .
         APPEND HEADER_CHAR  TO DYNP_CHAR .
*      SCREEN的描述DESCRIPTION
        DYNP_CHAR  DESCRIPT_TEXT .     APPEND DYNP_CHAR .
*      SCREEN的FIELDLIST
        DYNP_CHAR  FIELDS_TEXT .
         APPEND DYNP_CHAR .
         CALL  FUNCTION  'RS_SCRP_FIELDS_RAW_TO_CHAR'
           TABLES
            FIELDS_INT   F_G
            FIELDS_CHAR  FIELDS_CHAR
           EXCEPTIONS
             OTHERS       1 .

         LOOP  AT FIELDS_CHAR .
           APPEND FIELDS_CHAR  TO DYNP_CHAR .
         ENDLOOP .

*      SCREEN的逻辑FLOWLOGIC
        DYNP_CHAR  FLOWLOGIC_TEXT .
         APPEND DYNP_CHAR .

         LOOP  AT E_G  ASSIGNING <FS> .
           APPEND <FS>  TO DYNP_CHAR .
         ENDLOOP .

*      SCREEN的屏幕参数DYNPRO PARAMETERS
         IF M_G  IS  NOT  INITIAL .
          DYNP_CHAR  PARAMS_TEXT .
           APPEND DYNP_CHAR .

           LOOP  AT M_G .
             APPEND M_G  TO DYNP_CHAR .
           ENDLOOP .
         ENDIF .
*       DOWNLOAD
      CONDENSE ITAB_REPORT -NAME  NO -GAPS .
      CALL  FUNCTION  'STRING_CONCATENATE_3'
           EXPORTING
             STRING1  PATH
             STRING2  ITAB_REPORT -NAME
             STRING3  '.SCE'
           IMPORTING
             STRING  FULLPATH
           EXCEPTIONS
             TOO_SMALL  01 .
      CONDENSE FULLPATH  NO -GAPS .
      CALL  FUNCTION  'WS_DOWNLOAD'
           EXPORTING
             CODEPAGE               '8400'
             FILENAME               FULLPATH
             FILETYPE               'ASC'
           TABLES
             DATA_TAB               DYNP_CHAR .
   ENDLOOP .
ENDLOOP .
ENDFORM .                     " DOWN_PROGRAM_SCREEN

FORM DOWN_REPORT_SCREEN .            "下载REPORT的SCREEN
   DATA ITAB_HEAD  LIKE D020S  OCCURS  WITH  HEADER  LINE .
   DATA ITAB_HEAD_TEMP  LIKE D020S .
   DATA E_G  TYPE DYN_FLOWLIST .
   DATA F_G  LIKE D021S  OCCURS  WITH  HEADER  LINE .
   DATA M_G  LIKE D023S  OCCURS  WITH  HEADER  LINE .

* DEFINITION FIELD SYMBOLS
   FIELD-SYMBOLS <FS>  TYPE  ANY .
   DATA  HEADER_CHAR  LIKE SCR_CHHEAD .
   DATA  DYNP_CHAR  LIKE SCR_CHFLD  OCCURS  WITH  HEADER  LINE .
   DATA  FIELDS_CHAR  LIKE SCR_CHFLD  OCCURS  WITH  HEADER  LINE .
   DATA  PROG_LEN      TYPE P .
* DEFINE CONSTANTS
   CONSTANTS HEADER_TEXT ( 8 )      VALUE  '%_HEADER' ,
             DYNPRO_TEXT ( 8 )      VALUE  '%_DYNPRO' ,
             DESCRIPT_TEXT ( 13 )   VALUE  '%_DESCRIPTION' ,
             STARS ( 64 )           VALUE  '****************************************************************' ,
             COMMENT1 ( 64 )        VALUE  '*                                                              *' ,
             COMMENT2 ( 64 )        VALUE  '*                                                              *' ,
             FIELDS_TEXT ( 8 )      VALUE  '%_FIELDS' ,
             PARAMS_TEXT ( 8 )      VALUE  '%_PARAMS' ,
             FLOWLOGIC_TEXT ( 11 VALUE  '%_FLOWLOGIC' .

LOOP  AT ITAB_REPORT .
   CLEAR ITAB_HEAD . CLEAR ITAB_HEAD[] .
   SELECT FROM D020S  INTO CORRESPONDING  FIELDS  OF  TABLE ITAB_HEAD
                                    WHERE PROG  ITAB_REPORT -NAME
                                      AND  TYPE  ' ' .
   LOOP  AT ITAB_HEAD .
      CLEAR ITAB_HEAD_TEMP .
      CLEAR E_G . CLEAR E_G[] .
      CLEAR F_G . CLEAR F_G[] .
      CLEAR M_G . CLEAR M_G[] .
      CLEAR HEADER_CHAR .
      MOVE-CORRESPONDING ITAB_HEAD  TO ITAB_HEAD_TEMP .
      CALL  FUNCTION  'RS_SCREEN_IMPORT'
           EXPORTING
             DYNNR         ITAB_HEAD -DNUM
             PROGNAME      ITAB_HEAD -PROG
             WANTED_MODE   'SHOW'            "可以是MODIFY,用来修改
           TABLES
             E_G           E_G
             F_G           F_G
             M_G           M_G
           EXCEPTIONS
             NOT_EXECUTED  1
             NOT_FOUND     2
              OTHERS        3 .

      CALL  FUNCTION  'RS_SCRP_HEADER_RAW_TO_CHAR'
           EXPORTING
             HEADER_INT   ITAB_HEAD_TEMP
           IMPORTING
             HEADER_CHAR  HEADER_CHAR
           EXCEPTIONS
              OTHERS       1 .
         REFRESH DYNP_CHAR .
*      说明信息,可以自定义
        DYNP_CHAR  STARS .     APPEND DYNP_CHAR .
        DYNP_CHAR  COMMENT1 APPEND DYNP_CHAR .
        DYNP_CHAR  COMMENT2 APPEND DYNP_CHAR .
        DYNP_CHAR  STARS .     APPEND DYNP_CHAR .
*      SCREEN的证明
        DYNP_CHAR  DYNPRO_TEXT .       APPEND DYNP_CHAR .
        DYNP_CHAR  HEADER_CHAR -PROG APPEND DYNP_CHAR .
        DYNP_CHAR  HEADER_CHAR -DNUM APPEND DYNP_CHAR .
        DYNP_CHAR  SY -SAPRL .          APPEND DYNP_CHAR .
         DESCRIBE  FIELD D020T -PROG LENGTH PROG_LEN  IN CHARACTER  MODE .
        DYNP_CHAR ( 16 PROG_LEN .      APPEND DYNP_CHAR .
*      SCREEN的HEADER
        DYNP_CHAR  HEADER_TEXT .       APPEND DYNP_CHAR .
         APPEND HEADER_CHAR  TO DYNP_CHAR .
*      SCREEN的描述DESCRIPTION
        DYNP_CHAR  DESCRIPT_TEXT .     APPEND DYNP_CHAR .
*      SCREEN的FIELDLIST
        DYNP_CHAR  FIELDS_TEXT .
         APPEND DYNP_CHAR .
         CALL  FUNCTION  'RS_SCRP_FIELDS_RAW_TO_CHAR'
           TABLES
            FIELDS_INT   F_G
            FIELDS_CHAR  FIELDS_CHAR
           EXCEPTIONS
             OTHERS       1 .

         LOOP  AT FIELDS_CHAR .
           APPEND FIELDS_CHAR  TO DYNP_CHAR .
         ENDLOOP .

*      SCREEN的逻辑FLOWLOGIC
        DYNP_CHAR  FLOWLOGIC_TEXT .
         APPEND DYNP_CHAR .

         LOOP  AT E_G  ASSIGNING <FS> .
           APPEND <FS>  TO DYNP_CHAR .
         ENDLOOP .

*      SCREEN的屏幕参数DYNPRO PARAMETERS
         IF M_G  IS  NOT  INITIAL .
          DYNP_CHAR  PARAMS_TEXT .
           APPEND DYNP_CHAR .

           LOOP  AT M_G .
             APPEND M_G  TO DYNP_CHAR .
           ENDLOOP .
         ENDIF .
*       DOWNLOAD
      CONDENSE ITAB_REPORT -NAME  NO -GAPS .
      CALL  FUNCTION  'STRING_CONCATENATE_3'
           EXPORTING
             STRING1  PATH
             STRING2  ITAB_REPORT -NAME
             STRING3  '.SCE'
           IMPORTING
             STRING  FULLPATH
           EXCEPTIONS
             TOO_SMALL  01 .
      CONDENSE FULLPATH  NO -GAPS .
      CALL  FUNCTION  'WS_DOWNLOAD'
           EXPORTING
             CODEPAGE               '8400'
             FILENAME               FULLPATH
             FILETYPE               'ASC'
           TABLES
             DATA_TAB               DYNP_CHAR .
   ENDLOOP .
ENDLOOP .
ENDFORM .                     " DOWN_REPORT_SCREEN

***获得INCLUDE并输出

FORM GET_INCLUDE .          "得到想要输出的INCLUDE名称
CLEAR ITAB_INCLUDE ,ITAB_INCLUDE[] .
SELECT FROM TRDIR  INTO  TABLE ITAB_INCLUDE  WHERE NAME  IN REPO
                                               AND SUBC  'I' .
SORT ITAB_INCLUDE  BY NAME .
IF  NOT ITAB_INCLUDE[]  IS  INITIAL .
    PERFORM DOWN_INCLUDE .
ENDIF .
ENDFORM .                     " GET_INCLUDE

FORM DOWN_INCLUDE .               "下载INCLUDE代码
LOOP  AT ITAB_INCLUDE .
  READ  REPORT ITAB_INCLUDE -NAME  INTO TABSOURCE .
  DESCRIBE  TABLE TABSOURCE  LINES SOURCEROWS .
  CHECK SOURCEROWS >  0 .
  CONDENSE ITAB_INCLUDE -NAME  NO -GAPS .
  CALL  FUNCTION  'STRING_CONCATENATE_3'
       EXPORTING
           STRING1  PATH
           STRING2  ITAB_INCLUDE -NAME
           STRING3  '.TXT'
       IMPORTING
           STRING  FULLPATH
       EXCEPTIONS
           TOO_SMALL  01 .
  CONDENSE FULLPATH  NO -GAPS .
  CALL  FUNCTION  'WS_DOWNLOAD'
    EXPORTING
     CODEPAGE             '8400'
     FILENAME             FULLPATH
     FILETYPE             'ASC'
    TABLES
     DATA_TAB             TABSOURCE .
ENDLOOP .
ENDFORM .                     " DOWN_INCLUDE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值