일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Smart Forms
- selection screen
- 이명박
- Standard Function
- 동적 쿼리
- EXIT
- fi
- EUC-kr
- List box
- gimp
- ole
- ABAP
- 스마트폼
- SAP
- function
- KOSA
- ALV
- Enhancement
- 유닉스
- 엑소버드
- FI 용어정리
- 머니플랜
- 가계부
- 방화벽
- Java
- badi
- alv 정형화
- 오라클 함수
- sapa
- UTF-8
- Today
- Total
Drunken Lion
SAP 4.0 DOWNLOAD PROGRAM 본문
REPORT ZDOWN.
*$*$================================================================*$*$
* Direct download ver 4.12.
* THIS SOFTWARE IS FOR PERSONAL USE ONLY.
* THIS PROGRAM IS FREEWARE AND IS PROVIDED ON AN AS-IS BASIS
* WITHOUT WARRANTY OF ANY KIND.
* THE PROVIDER SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY,
* EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
* IN NO EVENT SHALL PROVIDER BE LIABLE FOR ANY CONSEQUENTIAL,
* INDIRECT, SPECIAL OR INCIDENTAL DAMAGES, EVEN IF PROVIDER
* HAS BEEN ADVISED BY CLIENT OF THE POSSIBILITY OF SUCH
* POTENTIAL LOSS OR DAMAGE. CLIENT AGREES TO HOLD PROVIDER
* HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES,
* LIABILITIES AND EXPENSES. BY INSTALLING OR RUNNING
* THIS PROGRAM YOU ARE AGREEING TO THE TERMS AND CONDITONS STATED
* ABOVE.
*
*$*$----------------------------------------------------------------*$*$
* PROGRAM DESCRIPTION
* Allows a user to download ABAPs, Functions DD definitions, etc to
* the presentation server. This version searches recursively for
* nested includes and function modules, and allows you to download
* the resulting code as standard text or HTML web pages.
* Compatible with R/3 versions 3 and 4.
*$*$----------------------------------------------------------------*$*$
* AUTHORS : E.Mellodew & John Davies-Hale
* PROGRAM HISTORY
* ---------------
* 1.0 Original program created
* 2.0 Modified selection texts so they are now stored within
* the actual abap program.
* Added functionality to download text elements and selection
* texts for any downloaded online programs.
* Added functionality to download message classes.
* Added functionality to download screens.
* 2.1 Fixed program names being truncated when downloading
* programs on version 4 systems.
* 3.0 New version - allows you to download files in HTML format as
* well as text format.
* 3.1 Added the ability to download nested include programs.
* 3.2 Added the ability to download custom dictionary structures
* referenced within programs.
* Added the option to include/exclude local private objects.
* Fixed problem with HTML documents not displaying correctly
* within Netscape Communicator.
* 3.21 Added domain name texts to HTML dictionary structure download.
* Fixed issue whereby field symbols displayed incorrectly within
* HTML documents.
* 4.00 Re-structured program.
* Increased scope of options on parameter screen
* Created user friendly screen showing downloads
* Allows user to download function modules
* Program is now fully recursive and allows downloading of
* includes within includes/functions
* and functions within functions/includes.
* 4.02 Added ability to download module pools
* Added 'key' flag to dictionary downloads
* 4.03 Screen 1000's can now be downloaded if they belong to a
* module pool and are not a parameter screen
* 4.10 Added ability to download function module documentation
* 4.11 Problem with some documentation not being downloaded fixed
*
* Limitations
* SAP does not have the provision to create sub-folders at present.
* Messages are not downloaded for nested includes
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* TABLES - DATABASES
*----------------------------------------------------------------------*
TABLES: RS38M, TADIR, TRDIR, DD01T, INFO_PROG, TRDIRE, T100, TLIBV,
DD02L, DD03L, DD04T, V_FDIR, TFDIR, TFTIT, D010INC, DD02T.
*-----------------------------------------------------------------------
* TYPES
*-----------------------------------------------------------------------
*----- Text element structure
TYPES: T_TEXTTAB LIKE TEXTPOOL.
*--- Message classes
TYPES: BEGIN OF T_MESSAGES,
MSGID LIKE TRDIRE-MSGID,
MSGNR LIKE T100-MSGNR,
TEXT LIKE T100-TEXT,
END OF T_MESSAGES.
*--- screen flow.
TYPES: BEGIN OF T_SCREEN_FLOW,
SCREEN LIKE D020S-DNUM,
CODE LIKE D022S-LINE,
END OF T_SCREEN_FLOW.
*--- Data dictionary objects - tables, structures.
TYPES: BEGIN OF T_DICT_STRUCT,
TABNAME LIKE DD03L-TABNAME,
TABTEXT LIKE DD02T-DDTEXT,
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,
DDTEXT LIKE DD04T-DDTEXT,
END OF T_DICT_STRUCT.
*--- Function Modules
TYPES: BEGIN OF T_FUNCTIONS,
FUNCNAME LIKE TFDIR-FUNCNAME,
INCLUDE LIKE TFDIR-INCLUDE,
PNAME LIKE TFDIR-PNAME,
STEXT LIKE TFTIT-STEXT,
END OF T_FUNCTIONS.
*--- Include program names
TYPES: BEGIN OF T_INCLUDES,
PROG LIKE TRDIR-NAME,
TEXT(255),
END OF T_INCLUDES.
*----- ABAP program list
TYPES: BEGIN OF T_PROGRAMMES,
DEVCLASS LIKE INFO_PROG-DEVCLASS,
PROG LIKE TRDIR-NAME,
TEXT(255),
SUBC LIKE INFO_PROG-SUBC,
FUNCTIONS TYPE T_FUNCTIONS OCCURS 0,
END OF T_PROGRAMMES.
*----------------------------------------------------------------------*
* DATA - INTERNAL TABLES
*----------------------------------------------------------------------*
*---- Program texts - declaration only not used
DATA: I_TEXTTAB TYPE T_TEXTTAB OCCURS 0 WITH HEADER LINE.
DATA: I_MESSAGES TYPE T_MESSAGES OCCURS 0 WITH HEADER LINE.
DATA: I_SCREEN_FLOW TYPE T_SCREEN_FLOW.
*----- Program content for text download
DATA: BEGIN OF CONTENT OCCURS 0,
LINE(255),
END OF CONTENT.
*--- Programme texts.
DATA: I_PROGRAMME_TEXTS TYPE T_TEXTTAB OCCURS 0 WITH HEADER LINE.
*--- dictionary object
DATA: I_DICTIONARY TYPE T_DICT_STRUCT OCCURS 0 WITH HEADER LINE.
*--- Allows HTML routines to create an HTML without the table name on
* each line.
DATA: BEGIN OF I_DICT_MINUS_TABNAME OCCURS 0,
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,
ddtext like dd04t-ddtext,
END OF I_DICT_MINUS_TABNAME.
*--- Table names of customer tables, used for searching for tables
DATA: BEGIN OF TABLE_NAMES OCCURS 0,
TABNAME LIKE I_DICTIONARY-TABNAME,
TABTEXT LIKE DD02T-DDTEXT,
END OF TABLE_NAMES.
*--- Function Modules.
DATA: I_FUNCTIONS TYPE T_FUNCTIONS OCCURS 0 WITH HEADER LINE.
DATA: I_FUNCTIONS_2 TYPE T_FUNCTIONS OCCURS 0 WITH HEADER LINE.
*--- Customer function names, used for searching for functions
DATA: BEGIN OF FUNCTION_NAMES OCCURS 0,
FUNCNAME LIKE I_FUNCTIONS-FUNCNAME,
END OF FUNCTION_NAMES.
DATA: BEGIN OF I_PROGRAMMES OCCURS 0,
DEVCLASS LIKE INFO_PROG-DEVCLASS,
PROG LIKE TRDIR-NAME,
TEXT(255),
SUBC LIKE INFO_PROG-SUBC,
MESSAGES TYPE T_MESSAGES OCCURS 0,
TEXT_ELEMENTS TYPE T_TEXTTAB OCCURS 0,
SELECTION_TEXTS TYPE T_TEXTTAB OCCURS 0,
SCREEN_FLOW TYPE T_SCREEN_FLOW OCCURS 0,
INCLUDES TYPE T_INCLUDES OCCURS 0,
FUNCTIONS TYPE T_FUNCTIONS OCCURS 0,
DICT_STRUCT TYPE T_DICT_STRUCT OCCURS 0,
END OF I_PROGRAMMES.
*--- Names of function modules used within programmes
data: i_prog_includes type t_includes occurs 0 with header line.
*--- Includes to download
DATA: I_INCLUDES LIKE I_PROGRAMMES OCCURS 0 WITH HEADER LINE.
*--- Tree display structure.
DATA: I_NODE LIKE SNODETEXT OCCURS 0 WITH HEADER LINE.
*--- Temp table of downloaded objects.
DATA: BEGIN OF I_DOWNLOADED OCCURS 0,
OBJECT(30),
END OF I_DOWNLOADED.
*----------------------------------------------------------------------*
* DATA - WORKING FIELDS
*----------------------------------------------------------------------*
DATA: FOOTER_MESSAGE LIKE CONTENT-LINE.
DATA: MESS(100).
DATA: TEMP_FUNC_NAME LIKE I_FUNCTIONS-FUNCNAME.
DATA: FORCED_EXIT TYPE I VALUE 0.
DATA: START_TIME LIKE SY-UZEIT.
DATA: RUN_TIME LIKE SY-UZEIT.
DATA: RUN_TIME_CHAR(8).
RANGES: S_PROG FOR TRDIR-NAME.
RANGES: S_DEV FOR TADIR-DEVCLASS.
RANGES: S_AUTH FOR USR02-BNAME.
RANGES: S_TABLE FOR DD02L-TABNAME.
RANGES: S_FNAME FOR TFDIR-FUNCNAME.
RANGES: S_FGROUP FOR ENLFDIR-AREA.
*-----------------------------------------------------------------------
* CONSTANTS
*-----------------------------------------------------------------------
CONSTANTS: C_TABLES(6) VALUE 'TABLES'.
CONSTANTS: C_LIKE(4) VALUE 'LIKE'.
CONSTANTS: C_TYPE(4) VALUE 'TYPE'.
CONSTANTS: C_STRUCTURE(9) VALUE 'STRUCTURE'.
CONSTANTS: C_COMMA(1) VALUE ','.
CONSTANTS: C_PERIOD(1) VALUE '.'.
CONSTANTS: C_VERSION_NO(4) VALUE '4.12'.
*-----------------------------------------------------------------------
* SELECTION SCREEN
*-----------------------------------------------------------------------
*--- Author
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE T_B1.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 5(23) T_AUTH.
PARAMETERS: P_AUTH LIKE USR02-BNAME.
selection-screen end of line.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 5(36) T_PMOD.
parameters: p_mod as checkbox.
selection-screen end of line.
SELECTION-SCREEN: END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE T_B2.
*--- Tables
selection-screen begin of line.
PARAMETERS: R_TABLE RADIOBUTTON GROUP R1.
SELECTION-SCREEN COMMENT 5(20) T_RTABLE.
selection-screen end of line.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(18) T_PTABLE.
PARAMETERS: P_TABLE LIKE DD02L-TABNAME.
SELECTION-SCREEN END OF LINE.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 10(69) T_TNOTE.
selection-screen end of line.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 14(61) T_TNOTE1.
selection-screen end of line.
*--- Function Modules
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R_FUNC RADIOBUTTON GROUP R1.
SELECTION-SCREEN COMMENT 5(30) T_RFUNC.
selection-screen end of line.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 10(18) T_PFNAME.
PARAMETERS: P_FNAME LIKE TFDIR-FUNCNAME.
selection-screen end of line.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 10(18) T_FGROUP.
PARAMETERS: P_FGROUP LIKE ENLFDIR-AREA.
selection-screen end of line.
*--- Programs / Includes
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R_PROG RADIOBUTTON GROUP R1.
SELECTION-SCREEN COMMENT 5(18) T_RPROG.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(18) T_RPNAME.
PARAMETERS: P_PROG LIKE TRDIR-NAME MEMORY ID RID.
SELECTION-SCREEN END OF LINE.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 10(18) T_SDEV.
PARAMETERS: P_DEV LIKE TADIR-DEVCLASS.
selection-screen end of line.
*--- Local objects
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(27) T_$TMP.
PARAMETERS: P_$TMP AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK B2.
*----- Additional things to download.
SELECTION-SCREEN: BEGIN OF BLOCK B3 WITH FRAME TITLE T_B3.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) T_PTEXT.
PARAMETERS: P_TEXT AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) T_PMES.
PARAMETERS: P_MES AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) T_PINC.
PARAMETERS: P_INC AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 40(20) T_RECU.
PARAMETERS: P_RECI AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 1(30) T_PFUNC.
PARAMETERS: P_FUNC AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 40(20) T_RECF.
PARAMETERS: P_RECF AS CHECKBOX DEFAULT 'X'.
selection-screen end of line.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) T_DOC.
PARAMETERS: P_DOC AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
selection-screen begin of line.
SELECTION-SCREEN COMMENT 1(30) T_PSCR.
PARAMETERS: P_SCR AS CHECKBOX.
selection-screen end of line.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) T_PDICT.
PARAMETERS: P_DICT AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK B3.
*----- File details
SELECTION-SCREEN: BEGIN OF BLOCK B4 WITH FRAME TITLE T_B4.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) T_PHTML.
PARAMETERS: P_HTML RADIOBUTTON GROUP G1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 30(20) T_PHEXT.
PARAMETERS: P_HEX(4) TYPE C DEFAULT 'Html' LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) T_PTXT.
PARAMETERS: P_TXT RADIOBUTTON GROUP G1.
SELECTION-SCREEN COMMENT 30(20) T_PEXT.
PARAMETERS: P_TEX(4) TYPE C DEFAULT 'Txt' LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) T_PPATH.
PARAMETERS: P_PATH LIKE RLGRAP-FILENAME
OBLIGATORY DEFAULT 'C:\temp'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK B4.
*-----------------------------------------------------------------------
* INITIALIZATION
*-----------------------------------------------------------------------
INITIALIZATION.
*--- parameter screen texts.
T_B1 = 'Author (Optional)'.
T_B2 = 'Objects to download'.
T_B3 = 'Additional downloads'.
T_B4 = 'Download parameters'.
T_AUTH = 'Author name'.
T_PMOD = 'Include programs modified by author'.
T_RTABLE = 'Tables'.
T_PTABLE = 'Table name'.
T_TNOTE = 'Please note: tables are stored under the username of'.
T_TNOTE1 = ' the last person who modified them.'.
T_RFUNC = 'Function modules'.
T_PFNAME = 'Function name'.
T_FGROUP = 'Function group'.
T_RPROG = 'Programs'.
T_RPNAME = 'Program name'.
T_SDEV = 'Development class'.
T_PTXT = 'Text document'.
T_PHTML = 'HTML document'.
T_PTEXT = 'Text elements'.
T_PINC = 'Include programs'.
T_RECU = 'Recursive search'.
T_PHEXT = 'File extension'.
T_PEXT = 'File extension'.
T_PPATH = 'File path'.
T_PMES = 'Message classes'.
T_PFUNC = 'Function modules'.
T_DOC = 'Function module documentation'.
T_RECF = 'Recursive search'.
T_PSCR = 'Screens'.
T_PDICT = 'Dictionary structures'.
T_$TMP = 'Include local objects'.
CONCATENATE 'Extracted by Direct download v' C_VERSION_NO
' 1998-2000.' INTO FOOTER_MESSAGE.
*-----------------------------------------------------------------------
* START-OF-SELECTION.
*-----------------------------------------------------------------------
START-OF-SELECTION.
PERFORM CHECK_COMBO_BOXES.
PERFORM FILL_RANGES.
START_TIME = SY-UZEIT.
TRANSLATE P_HEX TO LOWER CASE.
TRANSLATE P_TEX TO LOWER CASE.
*--- Main program flow.
CASE 'X'.
*--- Select tables
WHEN R_TABLE.
PERFORM RETRIEVE_TABLES TABLES I_DICTIONARY
TABLE_NAMES
S_TABLE.
WHEN R_FUNC.
*--- Select function modules
PERFORM RETRIEVE_FUNCTIONS TABLES S_FNAME
S_FGROUP
I_PROGRAMMES
I_FUNCTIONS
USING 1.
LOOP AT I_FUNCTIONS.
PERFORM FUNC_INCLUDE_NAME USING I_FUNCTIONS-PNAME
I_FUNCTIONS-INCLUDE
TEMP_FUNC_NAME
0.
PERFORM FIND_INCLUDE_PROGRAMS USING TEMP_FUNC_NAME.
PERFORM FIND_CUSTOM_FUNCTIONS TABLES I_FUNCTIONS
USING TEMP_FUNC_NAME.
ENDLOOP.
SORT I_PROG_INCLUDES ASCENDING BY PROG.
DELETE ADJACENT DUPLICATES FROM I_PROG_INCLUDES COMPARING PROG.
perform retrieve_functions tables s_fname
s_fgroup
I_FUNCTIONS
I_FUNCTIONS_2
USING 0.
I_FUNCTIONS[] = I_FUNCTIONS_2[].
*--- Select programs
WHEN R_PROG.
MESS = 'Processing please wait...'.
PERFORM DISPLAY_STATUS USING MESS 0.
PERFORM RETRIEVE_PROGRAMS TABLES I_PROGRAMMES
S_PROG
S_DEV
S_AUTH.
ENDCASE.
*-----------------------------------------------------------------------
** END-OF-SELECTION
*-----------------------------------------------------------------------
END-OF-SELECTION.
IF FORCED_EXIT = 0.
CASE 'X'.
WHEN R_TABLE.
IF NOT ( I_DICTIONARY[] IS INITIAL ).
PERFORM DOWNLOAD_DD_STRUCTURES TABLES I_DICTIONARY
USING P_PATH.
PERFORM FILL_TREE_NODE_TABLES TABLES I_DICTIONARY.
ENDIF.
WHEN R_FUNC.
IF NOT ( I_FUNCTIONS[] IS INITIAL ).
PERFORM DOWNLOAD_FUNCTIONS TABLES I_FUNCTIONS
USING P_PATH.
PERFORM FILL_TREE_NODE_FUNCTIONS TABLES I_FUNCTIONS.
ENDIF.
WHEN R_PROG.
IF NOT ( I_PROGRAMMES[] IS INITIAL ).
PERFORM DOWNLOAD_PROGRAMS TABLES I_PROGRAMMES
USING P_PATH.
PERFORM FILL_TREE_NODE_PROGRAMS TABLES I_PROGRAMMES.
ENDIF.
ENDCASE.
IF NOT ( I_NODE[] IS INITIAL ).
PERFORM DISPLAY_TREE TABLES I_NODE.
ELSE.
MESS = 'No items found matching selection criteria'.
PERFORM DISPLAY_STATUS USING MESS 2.
ENDIF.
ENDIF.
*--- Name parameters
SET PARAMETER ID 'RID' FIELD P_PROG.
SET PARAMETER ID 'DOB' FIELD P_TABLE.
SET PARAMETER ID 'DVC' FIELD P_DEV.
SET PARAMETER ID 'LIB' FIELD P_FNAME.
************************************************************************
*****************************SUBROUTINES********************************
************************************************************************
*-----------------------------------------------------------------------
* CHECK_COMBO_BOXES...
*-----------------------------------------------------------------------
FORM CHECK_COMBO_BOXES.
IF P_AUTH IS INITIAL.
CASE 'X'.
WHEN R_TABLE.
IF P_TABLE IS INITIAL.
MESS = 'You must enter a table name or author'.
ENDIF.
WHEN R_FUNC.
IF ( P_FNAME IS INITIAL AND P_FGROUP IS INITIAL ).
CONCATENATE 'You must enter a function name,'
'function group or author'
INTO MESS SEPARATED BY SPACE.
ENDIF.
WHEN R_PROG.
IF P_PROG IS INITIAL.
CONCATENATE 'You must enter a program name'
'development class or author'
INTO MESS SEPARATED BY SPACE.
ENDIF.
ENDCASE.
ELSE.
IF R_FUNC = 'X'.
IF ( ( P_AUTH <> '' ) AND
( ( P_FNAME <> '' ) OR ( P_FGROUP <> '' ) ) ).
CONCATENATE 'You cannnot enter an author as well as'
'a func name or func group'
INTO MESS SEPARATED BY SPACE.
ENDIF.
ENDIF.
ENDIF.
IF NOT MESS IS INITIAL.
PERFORM DISPLAY_STATUS USING MESS 3.
FORCED_EXIT = 1.
STOP.
ENDIF.
ENDFORM. " CHECK_COMBO_BOXES
*-----------------------------------------------------------------------
* FILL_RANGES... for selection routines
*-----------------------------------------------------------------------
FORM FILL_RANGES.
if not p_auth is initial.
s_auth-sign = 'I'.
s_auth-option = 'EQ'.
s_auth-low = p_auth.
append s_auth.
endif.
IF NOT P_TABLE IS INITIAL.
S_TABLE-SIGN = 'I'.
S_TABLE-OPTION = 'EQ'.
S_TABLE-LOW = P_TABLE.
APPEND S_TABLE.
endif.
IF NOT P_FNAME IS INITIAL.
S_FNAME-SIGN = 'I'.
S_FNAME-OPTION = 'EQ'.
S_FNAME-LOW = P_FNAME.
APPEND S_FNAME.
endif.
IF NOT P_FGROUP IS INITIAL.
S_FGROUP-SIGN = 'I'.
S_FGROUP-OPTION = 'EQ'.
S_FGROUP-LOW = P_FGROUP.
APPEND S_FGROUP.
endif.
IF NOT P_PROG IS INITIAL.
S_PROG-SIGN = 'I'.
S_PROG-OPTION = 'EQ'.
S_PROG-LOW = P_PROG.
APPEND S_PROG.
ENDIF.
IF NOT P_DEV IS INITIAL.
S_DEV-SIGN = 'I'.
S_DEV-OPTION = 'EQ'.
S_DEV-LOW = P_DEV.
APPEND S_DEV.
ENDIF.
IF P_$TMP IS INITIAL.
S_DEV-SIGN = 'E'.
S_DEV-OPTION = 'EQ'.
S_DEV-LOW = '$TMP'.
APPEND S_DEV.
ENDIF.
ENDFORM.
*-----------------------------------------------------------------------
* FIND_TABLES... Search for tables in dictionary
*-----------------------------------------------------------------------
FORM RETRIEVE_TABLES TABLES I_DICTIONARY STRUCTURE I_DICTIONARY
TABLE_NAMES STRUCTURE TABLE_NAMES
RANGE_TABLE STRUCTURE S_TABLE.
SELECT TABNAME FROM DD02L
INTO TABLE_NAMES-TABNAME
WHERE TABNAME IN RANGE_TABLE
AND AS4USER IN S_AUTH.
SELECT SINGLE DDTEXT FROM DD02T
INTO TABLE_NAMES-TABTEXT
WHERE TABNAME = TABLE_NAMES-TABNAME
AND DDLANGUAGE = SY-LANGU.
APPEND TABLE_NAMES.
ENDSELECT.
IF NOT ( TABLE_NAMES[] IS INITIAL ).
PERFORM FIND_TABLE_DEFINITION TABLES I_DICTIONARY
TABLE_NAMES.
ENDIF.
ENDFORM.
*-----------------------------------------------------------------------
* find_table_definition... from sap database.
*-----------------------------------------------------------------------
FORM FIND_TABLE_DEFINITION TABLES I_DICT STRUCTURE I_DICTIONARY
TABLENAMES STRUCTURE TABLE_NAMES.
DATA gotstate LIKE dcobjif-gotstate.
DATA dd02v_wa LIKE dd02v.
DATA dd09l_wa LIKE dd09l.
DATA: DEFINITION LIKE DD03P OCCURS 0 WITH HEADER LINE.
LOOP AT TABLENAMES.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
NAME = TABLENAMES-TABNAME
STATE = 'A'
LANGU = 'E'
IMPORTING
GOTSTATE = GOTSTATE
DD02V_WA = DD02V_WA
DD09L_WA = DD09L_WA
TABLES
DD03P_TAB = DEFINITION
EXCEPTIONS
ILLEGAL_INPUT = 1
OTHERS = 2.
IF SY-SUBRC = 0 AND GOTSTATE = 'A'.
LOOP AT DEFINITION.
MOVE-CORRESPONDING DEFINITION TO I_DICT.
MOVE TABLE_NAMES-TABTEXT TO I_DICT-TABTEXT.
APPEND I_DICT.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* RETRIEVE_FUNCTIONS... Retrieve function modules from SAP DB
*-----------------------------------------------------------------------
FORM RETRIEVE_FUNCTIONS TABLES S_FNAME STRUCTURE S_FNAME
S_FGROUP STRUCTURE S_FGROUP
FUNC_NAMES STRUCTURE I_FUNCTIONS
FOUND_FUNC STRUCTURE I_FUNCTIONS
USING MAIN_SCAN.
RANGES: SEL_FNAME FOR TFDIR-FUNCNAME.
RANGES: SEL_FGROUP FOR ENLFDIR-AREA.
SEL_FNAME[] = S_FNAME[].
SEL_FGROUP[] = S_FGROUP[].
IF MAIN_SCAN = 1.
IF NOT P_AUTH IS INITIAL.
*--- select all function groups by author
SELECT AREA FROM TLIBV INTO SEL_FGROUP-LOW
WHERE UNAME = P_AUTH.
SEL_FGROUP-SIGN = 'I'.
SEL_FGROUP-OPTION = 'EQ'.
APPEND SEL_FGROUP.
ENDSELECT.
ENDIF.
*--- Select by function name and/or function group.
SELECT * FROM V_FDIR
WHERE FUNCNAME IN SEL_FNAME
AND AREA IN SEL_FGROUP
AND GENERATED = ''.
SELECT SINGLE FUNCNAME
PNAME
INCLUDE FROM TFDIR
INTO (FOUND_FUNC-FUNCNAME,
FOUND_FUNC-PNAME,
FOUND_FUNC-INCLUDE)
WHERE FUNCNAME = V_FDIR-FUNCNAME.
SELECT SINGLE STEXT FROM TFTIT
INTO FOUND_FUNC-STEXT
WHERE SPRAS = SY-LANGU
AND FUNCNAME = V_FDIR-FUNCNAME.
APPEND I_FUNCTIONS.
ENDSELECT.
ELSE.
LOOP AT FUNC_NAMES.
SELECT SINGLE FUNCNAME
PNAME
INCLUDE FROM TFDIR
INTO (FOUND_FUNC-FUNCNAME,
FOUND_FUNC-PNAME,
FOUND_FUNC-INCLUDE)
WHERE FUNCNAME = FUNC_NAMES-FUNCNAME.
SELECT SINGLE STEXT FROM TFTIT
INTO FOUND_FUNC-STEXT
WHERE SPRAS = SY-LANGU
AND FUNCNAME = FUNC_NAMES-FUNCNAME.
APPEND FOUND_FUNC.
ENDLOOP.
ENDIF.
ENDFORM.
*-----------------------------------------------------------------------
* RETRIEVE_PROGRAMS... find programs and sub objects from SAP DB
*-----------------------------------------------------------------------
FORM RETRIEVE_PROGRAMS TABLES I_PROG STRUCTURE I_PROGRAMMES
SEL_PROG STRUCTURE S_PROG
SEL_DEV STRUCTURE S_DEV
SEL_AUTH STRUCTURE S_AUTH.
DATA: COUNTER TYPE I VALUE 1.
DATA: WA_INCLUDES TYPE T_INCLUDES.
*----- Select by name, development class and author
IF P_MOD IS INITIAL.
SELECT DEVCLASS PROG SUBC FROM INFO_PROG
INTO (I_PROG-DEVCLASS,
I_PROG-PROG,
I_PROG-SUBC)
WHERE PROG IN SEL_PROG
AND DEVCLASS IN SEL_DEV
AND CNAM IN SEL_AUTH
AND ( SUBC = '1'
OR SUBC = 'M' ).
APPEND I_PROG.
ENDSELECT.
ELSE.
SELECT DEVCLASS PROG SUBC FROM INFO_PROG
INTO (I_PROG-DEVCLASS,
I_PROG-PROG,
I_PROG-SUBC)
WHERE PROG IN SEL_PROG
AND DEVCLASS IN SEL_DEV
AND SUBC = '1'
AND ( CNAM IN SEL_AUTH
OR UNAM IN SEL_AUTH ).
APPEND I_PROG.
ENDSELECT.
ENDIF.
*----- Find extra items
LOOP AT I_PROG.
PERFORM FIND_PROGRAM_NAME USING I_PROG-PROG
CHANGING I_PROG-TEXT.
IF P_TEXT = 'X'.
PERFORM FIND_PROGRAM_TEXTS TABLES I_PROG.
ENDIF.
IF P_MES = 'X'.
PERFORM FIND_MESSAGES TABLES I_PROG USING I_PROG-PROG.
ENDIF.
IF P_SCR = 'X'.
PERFORM FIND_SCREEN_FLOW TABLES I_PROG USING I_PROG-PROG.
ENDIF.
if p_dict = 'X'.
perform find_custom_dict_structures tables i_prog
table_names
using i_prog-prog.
endif.
if p_func = 'X'.
PERFORM FIND_CUSTOM_FUNCTIONS TABLES FUNCTION_NAMES
USING I_PROG-PROG.
endif.
IF P_INC = 'X'.
PERFORM FIND_INCLUDE_PROGRAMS USING I_PROG-PROG.
PERFORM SORT_INCLUDES TABLES I_PROG.
*--- find all relevant data for the includes table.
IF NOT ( I_INCLUDES[] IS INITIAL ).
LOOP AT I_PROG-INCLUDES INTO WA_INCLUDES.
IF P_DICT = 'X'.
PERFORM FIND_CUSTOM_DICT_STRUCTURES TABLES I_PROG
TABLE_NAMES
USING WA_INCLUDES-PROG.
ENDIF.
IF P_FUNC = 'X'.
PERFORM FIND_CUSTOM_FUNCTIONS TABLES FUNCTION_NAMES
USING WA_INCLUDES-PROG.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
PERFORM SORT_DICT_STRUCTURES TABLES I_PROG TABLE_NAMES.
PERFORM SORT_FUNCTIONS TABLES I_PROG FUNCTION_NAMES.
MODIFY I_PROG INDEX COUNTER.
COUNTER = COUNTER + 1.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------
* FIND_PROGRAM_NAME... find programme name
*----------------------------------------------------------------------
FORM FIND_PROGRAM_NAME USING PROGramme_name
CHANGING programme_TEXT.
READ TEXTPOOL PROGRAMME_NAME INTO I_PROGRAMME_TEXTS LANGUAGE SY-LANGU.
READ TABLE I_PROGRAMME_TEXTS WITH KEY 'R'.
IF SY-SUBRC EQ 0.
PROGRAMME_TEXT = I_PROGRAMME_TEXTS-ENTRY.
DELETE I_PROGRAMME_TEXTS INDEX SY-TABIX.
ENDIF.
ENDFORM. " FIND_PROGRAMME_NAME
*----------------------------------------------------------------------
* FIND_PROGRAM_TEXTS... Messages and text elements
*----------------------------------------------------------------------
FORM FIND_PROGRAM_TEXTS TABLES I_PROG STRUCTURE I_PROGRAMMES.
DATA: TEMP_SELECTION TYPE T_TEXTTAB.
*--- selection texts.
LOOP AT I_PROGRAMME_TEXTS WHERE ID = 'S'.
APPEND I_PROGRAMME_TEXTS TO I_PROG-SELECTION_TEXTS.
DELETE I_PROGRAMME_TEXTS INDEX SY-TABIX.
ENDLOOP.
*--- Text elements.
LOOP AT I_PROGRAMME_TEXTS WHERE ID = 'I'.
APPEND I_PROGRAMME_TEXTS TO I_PROG-TEXT_ELEMENTS.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------
* FIND_MESSAGES... finds all program messages including dynamically
* called messages - providing they have been
* declared on one complete line.
*----------------------------------------------------------------------
FORM FIND_MESSAGES TABLES I_PROG STRUCTURE I_PROGRAMMES
USING PROGNAME.
*--- lines for main program
DATA: I_REPORT_LINES LIKE CONTENT OCCURS 0 WITH HEADER LINE.
*-- Separate working area for internal table
DATA: WA_MESSAGES TYPE T_MESSAGES.
DATA: msgid LIKE trdire-msgid.
DATA: HEAD LIKE I_REPORT_LINES-LINE.
DATA: TAIL LIKE I_REPORT_LINES-LINE.
DATA: headlength TYPE i VALUE 0.
DATA: TAILLENGTH TYPE I VALUE 0.
*--- Read the program contents into memory
READ REPORT PROGNAME INTO I_REPORT_LINES.
*--- Read the report content looking for message calls.
LOOP AT I_REPORT_LINES.
TRANSLATE I_REPORT_LINES TO UPPER CASE.
IF NOT ( I_REPORT_LINES IS INITIAL ) AND I_REPORT_LINES(1) <> '*'.
* Find the main message definition.
IF I_REPORT_LINES CS 'MESSAGE-ID'.
SHIFT I_REPORT_LINES LEFT DELETING LEADING SPACE.
SPLIT I_REPORT_LINES AT 'MESSAGE-ID' INTO HEAD TAIL.
SPLIT TAIL AT '.' INTO HEAD TAIL.
SHIFT HEAD LEFT DELETING LEADING SPACE.
MSGID = HEAD.
ELSE.
* There are three different ways of calling a message to display
* this routine looks for all three of them and strips the message
* class and number out of the code
IF I_REPORT_LINES CS 'MESSAGE'.
SHIFT I_REPORT_LINES-LINE UP TO 'MESSAGE'.
IF I_REPORT_LINES-LINE CS '('.
SPLIT I_REPORT_LINES-LINE AT '(' INTO HEAD TAIL.
HEADLENGTH = STRLEN( HEAD ).
HEADLENGTH = HEADLENGTH - 3.
WA_MESSAGES-MSGNR = HEAD+HEADLENGTH(3).
SPLIT TAIL AT ')' INTO HEAD TAIL.
WA_MESSAGES-MSGID = HEAD.
ELSEIF I_REPORT_LINES-LINE CS 'ID'.
SHIFT I_REPORT_LINES UP TO 'ID'.
SPLIT I_REPORT_LINES AT SPACE INTO HEAD TAIL.
SHIFT TAIL LEFT DELETING LEADING SPACE.
HEAD = TAIL.
SPLIT HEAD AT SPACE INTO HEAD TAIL.
WA_MESSAGES-MSGID = HEAD.
SPLIT TAIL AT 'NUMBER' INTO HEAD TAIL.
SHIFT TAIL LEFT DELETING LEADING SPACE.
TAILLENGTH = STRLEN( TAIL ).
IF TAILLENGTH = 3.
WA_MESSAGES-MSGNR = TAIL+0(3).
ELSE.
CONTINUE.
ENDIF.
ELSE.
*--- use message class from main program
SPLIT I_REPORT_LINES-LINE AT SPACE INTO HEAD TAIL.
SHIFT TAIL LEFT DELETING LEADING SPACE.
WA_MESSAGES-MSGID = MSGID.
WA_MESSAGES-MSGNR = TAIL+1(3).
ENDIF.
APPEND WA_MESSAGES TO I_PROG-MESSAGES.
CLEAR WA_MESSAGES.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
*--- Sort the messages and delete multiple occurrences from the
* internal table.
SORT I_PROG-MESSAGES ASCENDING BY MSGID MSGNR.
DELETE I_PROG-MESSAGES WHERE MSGID(1) <> 'Y'
AND MSGID(1) <> 'Z'.
DELETE ADJACENT DUPLICATES FROM I_PROG-MESSAGES.
DELETE I_PROG-MESSAGES WHERE MSGID IS INITIAL.
DELETE I_PROG-MESSAGES WHERE MSGNR IS INITIAL.
DELETE I_PROG-MESSAGES WHERE MSGNR CN '0123456789'.
LOOP AT I_PROG-MESSAGES INTO WA_MESSAGES.
SELECT SINGLE TEXT FROM T100 INTO WA_MESSAGES-TEXT
WHERE SPRSL = SY-LANGU
AND ARBGB = WA_MESSAGES-MSGID
AND MSGNR = WA_MESSAGES-MSGNR.
MODIFY I_PROG-MESSAGES FROM WA_MESSAGES INDEX SY-TABIX.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------
* FIND_SCREEN_FLOW...
*----------------------------------------------------------------------
FORM FIND_SCREEN_FLOW TABLES I_PROG STRUCTURE I_PROGRAMMES
USING PROGNAME.
DATA: FLOW TYPE T_SCREEN_FLOW OCCURS 0 WITH HEADER LINE.
call function 'DYNPRO_PROCESSINGLOGIC'
exporting
REP_NAME = PROGNAME
tables
SCR_LOGIC = FLOW.
SORT FLOW ASCENDING BY SCREEN.
DELETE ADJACENT DUPLICATES FROM FLOW COMPARING SCREEN.
IF I_PROG-SUBC <> 'M'.
DELETE FLOW WHERE SCREEN = '1000'.
ENDIF.
LOOP AT FLOW.
APPEND FLOW TO I_PROG-SCREEN_FLOW.
ENDLOOP.
ENDFORM. " FIND_SCREEN_FLOW
*-----------------------------------------------------------------------
* FIND_INCLUDE_PROGRAMS... Search each program for INCLUDE programs
*----------------------------------------------------------------------
FORM FIND_INCLUDE_PROGRAMS USING VALUE(PROGRAM).
DATA: FIP_PROG(255),
TAIL(255).
*--- Lines for include
DATA: I_INC_LINES LIKE CONTENT OCCURS 0 WITH HEADER LINE.
*----- Read ABAP
READ REPORT PROGRAM INTO I_INC_LINES.
*----- Examine each line of ABAP
LOOP AT I_INC_LINES.
*--- find include programs.
IF I_INC_LINES(1) = '*' OR I_INC_LINES IS INITIAL.
CONTINUE.
ENDIF.
TRANSLATE I_INC_LINES-LINE TO UPPER CASE.
SHIFT I_INC_LINES-LINE UP TO 'INCLUDE'.
IF ( I_INC_LINES-LINE(9) EQ 'INCLUDE Z' ) OR
( I_INC_LINES-LINE(9) EQ 'INCLUDE Y' ) OR
( I_INC_LINES-LINE(10) EQ 'INCLUDE MZ' ) OR "여기 추가..
( I_INC_LINES-LINE(10) EQ 'INCLUDE MY' ) "For Dialog PGM
AND I_INC_LINES-LINE+8(9) NE SPACE
AND SY-TABIX <> 1.
FIP_PROG = I_INC_LINES-LINE+8(64).
SPLIT FIP_PROG AT '.' INTO FIP_PROG TAIL.
* Append program name to list of include programs
SELECT SINGLE * FROM TRDIR WHERE NAME EQ FIP_PROG.
CHECK SY-SUBRC EQ 0.
I_PROG_INCLUDES-PROG = FIP_PROG.
APPEND I_PROG_INCLUDES.
*--- Recursively look for other includes.
IF P_RECI = 'X'.
PERFORM FIND_INCLUDE_PROGRAMS USING FIP_PROG.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FIND_INCLUDE_PROGRAMS
*----------------------------------------------------------------------
* SORT_INCLUDES.. Remove any duplicates from include table.
*----------------------------------------------------------------------
FORM SORT_INCLUDES TABLES I_PROG STRUCTURE I_PROGRAMMES.
SORT I_PROG_INCLUDES.
DELETE ADJACENT DUPLICATES FROM I_PROG_INCLUDES COMPARING PROG.
LOOP AT I_PROG_INCLUDES.
PERFORM FIND_PROGRAM_NAME USING I_PROG_INCLUDES-PROG
CHANGING I_PROG_INCLUDES-TEXT.
MODIFY I_PROG_INCLUDES.
MOVE-CORRESPONDING I_PROG_INCLUDES TO I_INCLUDES.
APPEND I_INCLUDES.
ENDLOOP.
APPEND LINES OF I_PROG_INCLUDES TO I_PROG-INCLUDES.
CLEAR I_PROG_INCLUDES. REFRESH I_PROG_INCLUDES.
ENDFORM.
*----------------------------------------------------------------------
* FIND_CUSTOM_DICT_STRUCTURES... Look for any dictionary objects
* not created by SAP
*----------------------------------------------------------------------
FORM FIND_CUSTOM_DICT_STRUCTURES TABLES I_PROG STRUCTURE I_PROGRAMMES
TABLE_NAMES
STRUCTURE TABLE_NAMES
USING VALUE(PROGRAM).
DATA I_LINES LIKE CONTENT OCCURS 0 WITH HEADER LINE.
DATA: HEAD(76).
DATA: TAIL(76).
DATA: LINETYPE(9).
DATA: END_OF_LINE TYPE I VALUE 1.
*--- read abap
READ REPORT PROGRAM INTO I_LINES.
LOOP AT I_LINES.
*--- find custom tables.
IF I_LINES-LINE(1) = '*' OR I_LINES IS INITIAL.
CONTINUE.
ENDIF.
TRANSLATE I_LINES-LINE TO UPPER CASE.
* Determine the linetype.
IF END_OF_LINE = 1.
SHIFT I_LINES-LINE UP TO C_TABLES.
IF SY-SUBRC = 0.
LINETYPE = C_TABLES.
ELSE.
SHIFT I_LINES-LINE UP TO C_LIKE.
IF SY-SUBRC = 0.
LINETYPE = C_TYPE.
ELSE.
SHIFT I_LINES-LINE UP TO C_TYPE.
IF SY-SUBRC = 0.
LINETYPE = C_TYPE.
ELSE.
SHIFT I_LINES-LINE UP TO C_STRUCTURE.
IF SY-SUBRC = 0.
LINETYPE = C_STRUCTURE.
ELSE.
CONTINUE.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSE.
LINETYPE = C_COMMA.
ENDIF.
* Work on the appropriate linetype
CASE LINETYPE.
WHEN C_TABLES.
SHIFT I_LINES-LINE UP TO SPACE.
PERFORM FIND_TABLES_ON_ONE_LINE TABLES TABLE_NAMES
USING I_LINES-LINE END_OF_LINE.
WHEN C_COMMA.
PERFORM FIND_TABLES_ON_NEW_LINE TABLES TABLE_NAMES
USING I_LINES-LINE END_OF_LINE.
WHEN C_LIKE OR C_TYPE OR C_STRUCTURE.
SHIFT I_LINES-LINE UP TO SPACE.
SHIFT I_LINES-LINE LEFT DELETING LEADING SPACE.
IF I_LINES-LINE(1) = 'Y' OR I_LINES-LINE(1) = 'Z'.
IF I_LINES-LINE CS C_COMMA.
SPLIT I_LINES-LINE AT C_COMMA INTO HEAD TAIL.
IF I_LINES-LINE CS '-'.
SPLIT HEAD AT '-' INTO HEAD TAIL.
ENDIF.
IF I_LINES-LINE CS 'OCCURS'.
SPLIT I_LINES-LINE AT SPACE INTO HEAD TAIL.
ENDIF.
ELSE.
IF I_LINES-LINE CS C_PERIOD.
SPLIT I_LINES-LINE AT C_PERIOD INTO HEAD TAIL.
IF I_LINES-LINE CS '-'.
SPLIT HEAD AT '-' INTO HEAD TAIL.
ENDIF.
IF I_LINES-LINE CS 'OCCURS'.
SPLIT I_LINES-LINE AT SPACE INTO HEAD TAIL.
ENDIF.
ELSE.
SPLIT I_LINES-LINE AT SPACE INTO HEAD TAIL.
ENDIF.
ENDIF.
TABLE_NAMES-TABNAME = HEAD.
APPEND TABLE_NAMES.
endif.
ENDCASE.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* SORT_DICT_STRUCTURES... don't allow muliples in prog structure
*-----------------------------------------------------------------------
FORM SORT_DICT_STRUCTURES TABLES I_PROG STRUCTURE I_PROGRAMMES
TAB_NAMES STRUCTURE TABLE_NAMES.
DATA: WA_DICT_STRUCT TYPE T_DICT_STRUCT.
SORT TAB_NAMES ASCENDING BY TABNAME.
DELETE ADJACENT DUPLICATES FROM TAB_NAMES.
IF NOT TAB_NAMES[] IS INITIAL.
LOOP AT TABLE_NAMES.
MOVE-CORRESPONDING TABLE_NAMES TO WA_DICT_STRUCT.
APPEND WA_DICT_STRUCT TO I_PROG-DICT_STRUCT.
ENDLOOP.
CLEAR TAB_NAMES. REFRESH TAB_NAMES.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------
* FIND_TABLES_ON_NEW_LINE... Find custom tables declared with a
* tables statement but have extended onto
* multiple lines.
*----------------------------------------------------------------------
FORM FIND_TABLES_ON_NEW_LINE TABLES CUST_TABLES STRUCTURE TABLE_nameS
USING LINE EOL.
DATA: TEMP_LINE(100).
DATA: HEAD(76).
DATA: TAIL(76).
DATA: STRLENGTH TYPE I VALUE 0.
TEMP_LINE = LINE.
SHIFT TEMP_LINE LEFT DELETING LEADING SPACE.
IF TEMP_LINE(1) = 'Y' OR TEMP_LINE(1) = 'Z'.
IF TEMP_LINE CS C_COMMA.
SPLIT TEMP_LINE AT ',' INTO HEAD TAIL.
TABLE_NAMES-TABNAME = HEAD.
APPEND TABLE_NAMES.
SHIFT TAIL LEFT BY 1 PLACES.
PERFORM FIND_TABLES_ON_NEW_LINE TABLES TABLE_NAMES
USING TAIL EOL.
ELSE.
SPLIT TEMP_LINE AT '.' INTO HEAD TAIL.
EOL = 1.
TABLE_NAMES-TABNAME = HEAD.
APPEND TABLE_NAMES.
ENDIF.
ELSE.
STRLENGTH = STRLEN( TEMP_LINE ).
IF STRLENGTH > 0.
IF TEMP_LINE CS C_COMMA.
SHIFT TEMP_LINE UP TO SPACE.
PERFORM FIND_TABLES_ON_NEW_LINE TABLES TABLE_NAMES
USING TEMP_LINE EOL.
ELSE.
IF TEMP_LINE(1) = '"'.
EOL = 0.
ELSE.
EOL = 1.
ENDIF.
ENDIF.
ELSE.
EOL = 0.
ENDIF.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------
* FIND_TABLES_ON_ONE_LINE... Find custom tables declared with a table
* statement whereby the tables are declare
* on one line
*----------------------------------------------------------------------
FORM FIND_TABLES_ON_ONE_LINE TABLES CUST_TABLES STRUCTURE TABLE_nameS
USING LINE EOL.
DATA: TEMP_LINE(100).
DATA: HEAD(76).
DATA: TAIL(76).
DATA: STRLENGTH TYPE I VALUE 0.
TEMP_LINE = LINE.
SHIFT TEMP_LINE LEFT DELETING LEADING SPACE.
IF TEMP_LINE(1) = 'Y' OR TEMP_LINE(1) = 'Z'.
IF TEMP_LINE CS C_COMMA.
SPLIT TEMP_LINE AT ',' INTO HEAD TAIL.
TABLE_NAMES-TABNAME = HEAD.
APPEND TABLE_NAMES.
SHIFT TAIL LEFT BY 1 PLACES.
PERFORM FIND_TABLES_ON_ONE_LINE TABLES TABLE_NAMES
USING TAIL EOL.
ELSE.
SPLIT TEMP_LINE AT '.' INTO HEAD TAIL.
EOL = 1.
TABLE_NAMES-TABNAME = HEAD.
APPEND TABLE_NAMES.
ENDIF.
ELSE.
STRLENGTH = STRLEN( TEMP_LINE ).
IF STRLENGTH > 0.
SHIFT TEMP_LINE UP TO SPACE.
PERFORM FIND_TABLES_ON_ONE_LINE TABLES TABLE_NAMES
USING TEMP_LINE EOL.
ELSE.
EOL = 0.
ENDIF.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------
* FIND_CUSTOM_FUNCTIONS... Look for any functions not created by SAP
*----------------------------------------------------------------------
FORM FIND_CUSTOM_FUNCTIONS TABLES I_FUNC_NAMES STRUCTURE FUNCTION_NAMES
USING VALUE(PROGRAM).
DATA I_LINES LIKE CONTENT OCCURS 0 WITH HEADER LINE.
DATA: HEAD(76).
DATA: TAIL(76).
DATA: I_RECURSIVE_FUNC LIKE I_FUNCTIONS OCCURS 0 WITH HEADER LINE.
DATA: I_FOUND_RECURSIVE LIKE I_FUNCTIONS OCCURS 0 WITH HEADER LINE.
DATA: REC_FUNC_NAME LIKE TRDIR-NAME.
*--- read abap
READ REPORT PROGRAM INTO I_LINES.
LOOP AT I_LINES.
*--- find custom tables.
IF I_LINES-LINE(1) = '*' OR I_LINES IS INITIAL.
CONTINUE.
ENDIF.
TRANSLATE I_LINES-LINE TO UPPER CASE.
IF I_LINES-LINE CS 'CALL FUNCTION'.
SHIFT I_LINES-LINE UP TO 'FUNCTION'.
SHIFT I_LINES-LINE UP TO SPACE.
SHIFT I_LINES-LINE LEFT DELETING LEADING SPACE.
SHIFT I_LINES-LINE LEFT DELETING LEADING ''''.
SPLIT I_LINES-LINE AT '''' INTO HEAD TAIL.
IF HEAD(1) = 'Y' OR HEAD(1) = 'Z'.
I_FUNC_NAMES-FUNCNAME = HEAD.
APPEND I_FUNC_NAMES TO I_RECURSIVE_FUNC.
READ TABLE I_FUNC_NAMES WITH KEY FUNCNAME = HEAD.
IF SY-SUBRC <> 0.
APPEND I_FUNC_NAMES.
IF P_RECF = 'X'.
PERFORM RETRIEVE_FUNCTIONS TABLES S_FNAME
S_FGROUP
I_RECURSIVE_FUNC
I_FOUND_RECURSIVE
USING 0.
READ TABLE I_FOUND_RECURSIVE INDEX 1.
PERFORM FUNC_INCLUDE_NAME USING I_FOUND_RECURSIVE-PNAME
I_FOUND_RECURSIVE-INCLUDE
REC_FUNC_NAME
0.
PERFORM FIND_INCLUDE_PROGRAMS USING REC_FUNC_NAME.
PERFORM FIND_CUSTOM_FUNCTIONS TABLES I_FUNC_NAMES
USING REC_FUNC_NAME.
ENDIF.
CLEAR I_FOUND_RECURSIVE. REFRESH I_FOUND_RECURSIVE.
CLEAR I_RECURSIVE_FUNC. REFRESH I_RECURSIVE_FUNC.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* FUNC_INCLUDE_NAME...
*-----------------------------------------------------------------------
FORM FUNC_INCLUDE_NAME USING VALUE(PROG_NAME)
VALUE(INCLUDE_NO)
INTERNAL_NAME
VALUE(WANT_TOP).
DATA: INC_NUMBER(4).
CONCATENATE '%U' INCLUDE_NO INTO INC_NUMBER.
IF WANT_TOP = 0.
SELECT SINGLE INCLUDE FROM D010INC INTO INTERNAL_NAME
WHERE MASTER = PROG_NAME
AND INCLUDE LIKE INC_NUMBER.
ELSE.
SELECT SINGLE INCLUDE FROM D010INC INTO INTERNAL_NAME
WHERE MASTER = PROG_NAME
AND ( INCLUDE LIKE '%TOP'
OR ( INCLUDE LIKE INC_NUMBER
AND INCLUDE NOT LIKE '%$%' ) ).
ENDIF.
ENDFORM.
*-----------------------------------------------------------------------
* SORT_FUNCTIONS... don't allow duplicates in prog structure.
*-----------------------------------------------------------------------
FORM SORT_FUNCTIONS TABLES I_PROG STRUCTURE I_PROGRAMMES
I_FUNC_NAMES STRUCTURE FUNCTION_NAMES.
DATA: WA_FUNC_STRUCT TYPE T_FUNCTIONS.
SORT I_FUNC_NAMES ASCENDING BY FUNCNAME.
DELETE ADJACENT DUPLICATES FROM I_FUNC_NAMES.
IF NOT I_FUNC_NAMES[] IS INITIAL.
LOOP AT I_FUNC_NAMES.
MOVE-CORRESPONDING I_FUNC_NAMES TO WA_FUNC_STRUCT.
APPEND WA_FUNC_STRUCT TO I_PROG-FUNCTIONS.
ENDLOOP.
CLEAR I_FUNC_NAMES. REFRESH I_FUNC_NAMES.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------
* DISPLAY_STATUS...
*----------------------------------------------------------------------
FORM DISPLAY_STATUS USING MESSAGE DELAY.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = MESSAGE
EXCEPTIONS
OTHERS = 1.
IF DELAY > 0.
call function 'RZL_SLEEP'
exporting
SECONDS = DELAY
exceptions
argument_error = 1
others = 2.
ENDIF.
ENDFORM. " DISPLAY_STATUS
************************************************************************
************************HTML ROUTINES***********************************
************************************************************************
*-----------------------------------------------------------------------
* CONVERT_DD_TO_HTML... Convert text description to HTML
*-----------------------------------------------------------------------
FORM CONVERT_DD_TO_HTML TABLES I_DICT STRUCTURE I_DICT_MINUS_TABNAME
I_DICT_HTML STRUCTURE W3HTML.
DATA: COLUMN_CAPTIONS LIKE W3HEAD OCCURS 0 WITH HEADER LINE.
DATA ROW_ATTRIBUTES LIKE W3FIELDS OCCURS 0 WITH HEADER LINE.
PERFORM SET_COLUMN_HEADERS TABLES COLUMN_CAPTIONS.
PERFORM SET_ROW_ATTRIBUTES TABLES ROW_ATTRIBUTES.
CALL FUNCTION 'WWW_ITAB_TO_HTML'
EXPORTING
TABLE_ATTRIBUTES = 'BORDER=1'
ALL_FIELDS = 'X'
TABLES
HTML = I_DICT_HTML
FIELDS = ROW_ATTRIBUTES
ROW_HEADER = COLUMN_CAPTIONS
ITABLE = I_DICT.
PERFORM RE_FORMAT_HTML TABLES I_DICT_HTML.
ENDFORM.
*----------------------------------------------------------------------
* SET_COLUMN_HEADERS... For DD structures converted to HTML
*----------------------------------------------------------------------
FORM SET_COLUMN_HEADERS TABLES COLUMN_CAPTIONS STRUCTURE W3HEAD.
DATA FIELD_NO LIKE W3HEAD-NR VALUE 1.
DATA TEXT LIKE W3HEAD-TEXT VALUE 'Field name'.
DO 8 TIMES. "number of fields in structure i_dictionary.
CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
FIELD_NR = FIELD_NO
TEXT = TEXT
FGCOLOR = '#FFFF00'
BGCOLOR = '#000000'
TABLES
HEADER = COLUMN_CAPTIONS.
FIELD_NO = FIELD_NO + 1.
CASE FIELD_NO.
WHEN 2. TEXT = 'Position'.
WHEN 3. TEXT = 'Key'.
WHEN 4. TEXT = 'Data element'.
WHEN 5. TEXT = 'Domain'.
WHEN 6. TEXT = 'Datatype'.
WHEN 7. TEXT = 'Length'.
WHEN 8. TEXT = 'Domain text'.
ENDCASE.
ENDDO.
ENDFORM.
*----------------------------------------------------------------------
* SET_ROW_ATTRIBUTES... For DD structures converted to HTML
*----------------------------------------------------------------------
FORM SET_ROW_ATTRIBUTES TABLES ROW_ATTRIBUTES STRUCTURE W3FIELDS.
DATA FIELD_NO LIKE W3FIELDS-NR VALUE 1.
DO 8 TIMES. "number of fields in structure i_dict.
CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
FIELD_NR = FIELD_NO
SIZE = '1'
FGCOLOR = 'green'
FONT = '"Arial"'
TABLES
FIELDS = ROW_ATTRIBUTES.
FIELD_NO = FIELD_NO + 1.
ENDDO.
ENDFORM.
*----------------------------------------------------------------------
* RE_FORMAT_HTML... Splits table lines at EOL marker an places line on
* a new line.
*----------------------------------------------------------------------
FORM RE_FORMAT_HTML TABLES HTML_TABLE STRUCTURE W3HTML.
DATA: NEW_HTML LIKE W3HTML OCCURS 0 WITH HEADER LINE.
DATA: HEAD LIKE W3HTML.
DATA TAIL(510).
CONSTANTS: CR(2) TYPE X VALUE '0D0A'.
LOOP AT HTML_TABLE.
CONCATENATE TAIL HTML_TABLE INTO TAIL.
IF HTML_TABLE CS CR.
WHILE tail CS cr.
SPLIT tail AT cr INTO head tail.
APPEND HEAD TO NEW_HTML.
ENDWHILE.
ELSE.
APPEND HTML_TABLE TO NEW_HTML.
ENDIF.
ENDLOOP.
APPEND tail TO new_html.
HTML_TABLE[] = NEW_HTML[].
ENDFORM.
*----------------------------------------------------------------------
* BUILD_HTML_TABLE... Builds an HTML table based upon a text table
* Replaces signs '<>' with HTML versions.
*----------------------------------------------------------------------
FORM CONVERT_TABLE_TO_HTML TABLES CONTENTS STRUCTURE CONTENT
USING VALUE(PROGRAM_NAME).
DATA: HTML_TABLE LIKE W3HTML OCCURS 0 WITH HEADER LINE.
DATA: LISTING_NAME(100) VALUE 'Program listing for:'.
CONSTANTS: BR(4) VALUE '<br>'.
CONSTANTS: CR(4) VALUE '<cr>'.
CONSTANTS: HR(4) VALUE '<hr>'.
CONSTANTS: LT(4) VALUE '<'.
CONSTANTS: GT(4) VALUE '>'.
HTML_TABLE = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">'.
APPEND HTML_TABLE.
HTML_TABLE = '<html>'.
APPEND HTML_TABLE.
HTML_TABLE = '<head>'.
APPEND HTML_TABLE.
CONCATENATE '<title>' PROGRAM_NAME '</title>' INTO HTML_TABLE.
APPEND HTML_TABLE.
HTML_TABLE = '</head>'.
APPEND HTML_TABLE.
HTML_TABLE = '<body bgcolor=#FFFF4b>'.
APPEND HTML_TABLE.
CONCATENATE LISTING_NAME PROGRAM_NAME INTO LISTING_NAME
SEPARATED BY SPACE.
CONCATENATE '<font size=3 face = "Arial" color=#000000><b>'
LISTING_NAME '</b></font>' INTO HTML_TABLE.
APPEND HTML_TABLE.
HTML_TABLE = HR.
APPEND HTML_TABLE.
HTML_TABLE = '<font size=2 face = "Sans Serif">'.
APPEND HTML_TABLE.
HTML_TABLE = '<pre width=100>'.
APPEND HTML_TABLE.
LOOP AT CONTENTS.
IF NOT ( CONTENTS IS INITIAL ).
WHILE ( CONTENTS CS '<' OR CONTENTS CS '>' ).
REPLACE '<' WITH LT INTO CONTENTS.
REPLACE '>' WITH GT INTO CONTENTS.
ENDWHILE.
CONCATENATE CONTENTS CR INTO HTML_TABLE.
ELSE.
HTML_TABLE = BR.
ENDIF.
APPEND HTML_TABLE.
ENDLOOP.
HTML_TABLE = '</pre>'.
APPEND HTML_TABLE.
HTML_TABLE = HR.
APPEND HTML_TABLE.
CONCATENATE FOOTER_MESSAGE BR INTO HTML_TABLE.
APPEND HTML_TABLE.
HTML_TABLE = '</body>'.
APPEND HTML_TABLE.
HTML_TABLE = '</html>'.
APPEND HTML_TABLE.
CONTENTS[] = HTML_TABLE[].
ENDFORM.
************************************************************************
*********************DOWNLOAD ROUTINES**********************************
************************************************************************
*-----------------------------------------------------------------------
* DOWNLOAD_DD_STRUCTURES... download database objects to file
*-----------------------------------------------------------------------
FORM DOWNLOAD_DD_STRUCTURES TABLES I_DICT STRUCTURE I_DICTIONARY
USING VALUE(PATHNAME).
DATA: FILENAME LIKE RLGRAP-FILENAME.
DATA: I_DICT_HTML LIKE W3HTML OCCURS 0 WITH HEADER LINE.
LOOP AT I_DICT.
MOVE-CORRESPONDING I_DICT TO I_DICT_MINUS_TABNAME.
APPEND I_DICT_MINUS_TABNAME.
AT END OF TABNAME.
CONCATENATE 'Converting table' I_DICT-TABNAME 'to html'
INTO MESS SEPARATED BY SPACE.
PERFORM DISPLAY_STATUS USING MESS 0.
TRANSLATE I_DICT-TABNAME TO LOWER CASE.
TRANSLATE P_HEX TO LOWER CASE.
CONCATENATE PATHNAME '\' 'Dictionary-'
I_DICT-TABNAME '.'
P_HEX INTO FILENAME.
PERFORM CONVERT_DD_TO_HTML TABLES I_DICT_MINUS_TABNAME
i_dict_html.
PERFORM WS_DOWNLOAD TABLES I_DICT_HTML
USING FILENAME.
CLEAR I_DICT_HTML. REFRESH I_DICT_HTML.
CLEAR I_DICT_MINUS_TABNAME. REFRESH I_DICT_MINUS_TABNAME.
ENDAT.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* DOWNLOAD_FUNCTIONS... Download function modules to file.
*-----------------------------------------------------------------------
FORM DOWNLOAD_FUNCTIONS TABLES I_FUNC STRUCTURE I_FUNCTIONS
USING VALUE(P_PATH).
DATA: INC_NUMBER(4).
DATA: FILE_EXT(4).
DATA: FUNC_PATH LIKE RLGRAP-FILENAME.
DATA: HTML_NAME(110).
DATA: BEGIN OF I_LOC_INCLUDES OCCURS 0,
INCLUDE LIKE D010INC-INCLUDE,
END OF I_LOC_INCLUDES.
LOOP AT I_FUNC.
CLEAR I_LOC_INCLUDES. REFRESH I_LOC_INCLUDES.
*--- Function module
PERFORM FUNC_INCLUDE_NAME USING I_FUNC-PNAME
I_FUNC-INCLUDE
I_LOC_INCLUDES-INCLUDE
0.
APPEND I_LOC_INCLUDES.
*--- Global declarations
perform func_include_name using i_func-pname
i_func-include
I_LOC_INCLUDES-INCLUDE
1.
append i_loc_includes.
LOOP AT I_LOC_INCLUDES.
READ REPORT I_LOC_INCLUDES-INCLUDE INTO CONTENT.
TRANSLATE I_FUNCTIONS-STEXT TO LOWER CASE.
*--- Create filename and convert contents to HTML if applicable
IF P_HTML = 'X'.
IF I_LOC_INCLUDES-INCLUDE CS 'TOP'.
CONCATENATE 'Global-' I_FUNC-FUNCNAME
INTO HTML_NAME SEPARATED BY SPACE.
ELSE.
HTML_NAME = I_FUNC-FUNCNAME.
ENDIF.
PERFORM CONVERT_TABLE_TO_HTML TABLES CONTENT
USING HTML_NAME.
FILE_EXT = P_HEX.
ELSE.
FILE_EXT = P_TEX.
ENDIF.
IF I_LOC_INCLUDES-INCLUDE CS 'TOP'.
CONCATENATE P_PATH '\Global-' I_FUNC-FUNCNAME '.'
FILE_EXT
INTO FUNC_PATH.
ELSE.
CONCATENATE P_PATH '\' I_FUNC-FUNCNAME '.' FILE_EXT
INTO FUNC_PATH.
ENDIF.
TRANSLATE FUNC_PATH TO LOWER CASE.
PERFORM WS_DOWNLOAD TABLES CONTENT
USING FUNC_PATH.
CLEAR CONTENT. REFRESH CONTENT.
ENDLOOP.
IF P_DOC = 'X'.
PERFORM DOWNLOAD_FUNC_DOCUMENTATION USING I_FUNC-FUNCNAME
I_FUNC-STEXT.
ENDIF.
ENDLOOP.
LOOP AT I_PROG_INCLUDES.
PERFORM READ_MAIN_CODE_AND_DOWNLOAD TABLES I_TEXTTAB
I_TEXTTAB
I_MESSAGES
USING I_PROG_INCLUDES-PROG.
endloop.
ENDFORM.
*-----------------------------------------------------------------------
* DOWNLOAD_FUNCTION_DOCUMENTATION...
*-----------------------------------------------------------------------
FORM DOWNLOAD_FUNC_DOCUMENTATION USING FUNCTION_NAME
DESCRIPTION.
DATA: I_LINES LIKE CONTENT OCCURS 0 WITH HEADER LINE.
DATA: I_SCRIPT_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA: HTML_PAGE_NAME(100).
DATA: DOC_PATH LIKE RLGRAP-FILENAME.
DATA: OBJECT LIKE DOKHL-OBJECT.
MOVE FUNCTION_NAME TO OBJECT.
CALL FUNCTION 'DOCU_GET'
EXPORTING
ID = 'FU'
LANGU = SY-LANGU
OBJECT = OBJECT
TYP = 'T'
VERSION_ACTIVE_OR_LAST = 'L'
TABLES
LINE = I_SCRIPT_LINES
EXCEPTIONS
NO_DOCU_ON_SCREEN = 1
NO_DOCU_SELF_DEF = 2
NO_DOCU_TEMP = 3
RET_CODE = 4
OTHERS = 5.
IF SY-SUBRC = 0 AND NOT ( I_SCRIPT_LINES[] IS INITIAL ).
APPEND 'SHORT TEXT' TO I_LINES.
APPEND DESCRIPTION TO I_LINES.
APPEND SPACE TO I_LINES.
LOOP AT I_SCRIPT_LINES.
MOVE I_SCRIPT_LINES-TDLINE TO I_LINES-LINE.
WHILE I_LINES-LINE CP '&*' OR I_LINES-LINE CP '*&'.
REPLACE '&' WITH '' INTO I_LINES-LINE.
ENDWHILE.
APPEND I_LINES.
ENDLOOP.
CONCATENATE 'Documentation -' FUNCTION_NAME
INTO HTML_PAGE_NAME SEPARATED BY SPACE.
PERFORM CONVERT_TABLE_TO_HTML TABLES I_LINES
USING HTML_PAGE_NAME.
CONCATENATE P_PATH '\Docs-' FUNCTION_NAME '.'
P_HEX
INTO DOC_PATH.
TRANSLATE DOC_PATH TO LOWER CASE.
PERFORM WS_DOWNLOAD TABLES I_LINES
USING DOC_PATH.
ENDIF.
ENDFORM.
*-----------------------------------------------------------------------
* DOWNLOAD_PROGRAMS..
*-----------------------------------------------------------------------
FORM DOWNLOAD_PROGRAMS TABLES I_PROG STRUCTURE I_PROGRAMMES
USING VALUE(P_PATH).
DATA: WA_DICT_STRUCT LIKE I_DICTIONARY.
DATA: I_LOC_TAB_NAMES LIKE TABLE_NAMES OCCURS 0 WITH HEADER LINE.
DATA: I_LOC_DICT TYPE T_DICT_STRUCT OCCURS 0 WITH HEADER LINE.
DATA: WA_INCLUDES TYPE T_INCLUDES.
DATA: I_LOC_FUNCTIONS TYPE T_FUNCTIONS OCCURS 0 WITH HEADER LINE.
DATA: WA_FUNCTIONS TYPE T_FUNCTIONS.
SORT I_PROG ASCENDING BY PROG.
DELETE ADJACENT DUPLICATES FROM I_PROG COMPARING PROG.
LOOP AT I_PROG.
*-- Download screens.
PERFORM DOWNLOAD_SCREENS TABLES I_PROG-SCREEN_FLOW
USING I_PROG-PROG.
*-- Download dictionary objects
LOOP AT I_PROG-DICT_STRUCT INTO WA_DICT_STRUCT.
MOVE WA_DICT_STRUCT-TABNAME TO I_LOC_TAB_NAMES-TABNAME.
APPEND I_LOC_TAB_NAMES.
ENDLOOP.
*--- Temporary stops multiple objects with the same name being
* downloaded to the same directory.
LOOP AT I_LOC_TAB_NAMES.
SORT I_DOWNLOADED ASCENDING BY OBJECT.
READ TABLE I_DOWNLOADED WITH KEY OBJECT = I_LOC_TAB_NAMES-TABNAME.
IF SY-SUBRC = 0.
DELETE I_LOC_TAB_NAMES.
ENDIF.
ENDLOOP.
IF NOT ( I_LOC_TAB_NAMES[] IS INITIAL ).
PERFORM FIND_TABLE_DEFINITION TABLES I_LOC_DICT
I_LOC_TAB_NAMES.
PERFORM DOWNLOAD_DD_STRUCTURES TABLES I_LOC_DICT
USING P_PATH.
ENDIF.
*--- Temporary
LOOP AT I_LOC_TAB_NAMES.
APPEND I_LOC_TAB_NAMES TO I_DOWNLOADED.
ENDLOOP.
*-- Download function modules
*--- Temporary stops multiple objects with the same name being
* downloaded to the same directory.
LOOP AT I_PROG-FUNCTIONS INTO WA_FUNCTIONS.
SORT I_DOWNLOADED ASCENDING BY OBJECT.
READ TABLE I_DOWNLOADED WITH KEY
OBJECT = WA_FUNCTIONS-FUNCNAME.
if sy-subrc = 0.
DELETE I_PROG-FUNCTIONS.
endif.
endloop.
IF NOT ( I_PROG-FUNCTIONS[] IS INITIAL ).
PERFORM RETRIEVE_FUNCTIONS TABLES S_FNAME
S_FGROUP
I_PROG-FUNCTIONS
I_LOC_FUNCTIONS
USING 0.
PERFORM DOWNLOAD_FUNCTIONS TABLES I_LOC_FUNCTIONS
USING P_PATH.
ENDIF.
*--- Temporary
LOOP AT I_LOC_FUNCTIONS.
MOVE I_LOC_FUNCTIONS-FUNCNAME TO I_DOWNLOADED.
APPEND I_DOWNLOADED.
ENDLOOP.
*-- Download includes
LOOP AT I_PROG-INCLUDES INTO WA_INCLUDES.
PERFORM READ_MAIN_CODE_AND_DOWNLOAD TABLES I_TEXTTAB
I_TEXTTAB
I_MESSAGES
USING WA_INCLUDES-PROG.
ENDLOOP.
*-- Main program
PERFORM READ_MAIN_CODE_AND_DOWNLOAD TABLES I_PROG-TEXT_ELEMENTS
I_PROG-SELECTION_TEXTS
I_PROG-MESSAGES
USING I_PROG-PROG.
CLEAR CONTENT. REFRESH CONTENT.
CLEAR I_LOC_DICT. REFRESH I_LOC_DICT.
CLEAR I_LOC_TAB_NAMES. REFRESH I_LOC_TAB_NAMES.
CLEAR I_LOC_FUNCTIONS. REFRESH I_LOC_FUNCTIONS.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* FIND_MAIN_CODE_AND_DOWNLOAD...
*-----------------------------------------------------------------------
FORM READ_MAIN_CODE_AND_DOWNLOAD TABLES
TEXT_ELEMENTS STRUCTURE I_TEXTTAB
SELECTION_TEXTS STRUCTURE I_TEXTTAB
MESSAGES STRUCTURE I_MESSAGES
USING PROGNAME.
DATA: I_LINES LIKE CONTENT OCCURS 0 WITH HEADER LINE.
DATA: W_FILENAME LIKE RLGRAP-FILENAME.
READ REPORT PROGNAME INTO I_LINES.
*-- download text elements and selection texts for main program
PERFORM APPEND_TEXT_ELEMENTS TABLES TEXT_ELEMENTS
SELECTION_TEXTS
i_lines.
*-- download messages classes for main program.
PERFORM APPEND_MESSAGES_TO_FILE TABLES MESSAGES I_LINES.
IF ( P_TXT = 'X' ) OR ( PROGNAME = SY-CPROG ).
IF PROGNAME = SY-CPROG.
CONCATENATE P_PATH '\' 'Direct download v' C_VERSION_NO '.' P_TEX
INTO W_FILENAME.
ELSE.
CONCATENATE P_PATH '\' PROGNAME '.' P_TEX INTO W_FILENAME.
ENDIF.
TRANSLATE W_FILENAME TO LOWER CASE.
PERFORM WS_DOWNLOAD TABLES I_LINES USING W_FILENAME.
ELSE.
PERFORM CONVERT_TABLE_TO_HTML TABLES I_LINES
USING PROGNAME.
CONCATENATE P_PATH '\' PROGNAME '.' P_HEX INTO W_FILENAME.
TRANSLATE W_FILENAME TO LOWER CASE.
PERFORM WS_DOWNLOAD TABLES I_LINES USING W_FILENAME.
ENDIF.
ENDFORM.
*-----------------------------------------------------------------------
* APPEND_TEXTS_TO_FILE...
*-----------------------------------------------------------------------
FORM APPEND_TEXT_ELEMENTS TABLES TEXT_ELEMENTS STRUCTURE I_TEXTTAB
SELECTION_TEXTS STRUCTURE I_TEXTTAB
I_LINES STRUCTURE CONTENT.
DATA: W_LINES TYPE I VALUE 0.
DESCRIBE TABLE TEXT_ELEMENTS LINES W_LINES.
IF W_LINES > 0.
DO 3 TIMES.
I_LINES-LINE = ''.
APPEND I_LINES.
ENDDO.
I_LINES-LINE = '*Text elements'.
APPEND I_LINES.
I_LINES-LINE = '*-------------'.
APPEND I_LINES.
LOOP AT TEXT_ELEMENTS.
I_LINES-LINE+0(2) = '* '.
I_LINES-LINE+2(74) = TEXT_ELEMENTS.
APPEND I_LINES.
ENDLOOP.
ENDIF.
DESCRIBE TABLE SELECTION_TEXTS LINES W_LINES.
IF W_LINES > 0.
DO 3 TIMES.
I_LINES-LINE = ''.
APPEND I_LINES.
ENDDO.
I_LINES-LINE = '*Selection texts'.
APPEND I_LINES.
I_LINES-LINE = '*---------------'.
APPEND I_LINES.
LOOP AT SELECTION_TEXTS.
I_LINES-LINE+0(1) = '*'.
I_LINES-LINE+1(75) = SELECTION_TEXTS.
APPEND I_LINES.
ENDLOOP.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------
* APPEND_MESSAGES_TO_FILE
*----------------------------------------------------------------------
FORM APPEND_MESSAGES_TO_FILE TABLES MESSAGES STRUCTURE I_MESSAGES
I_LINES STRUCTURE CONTENT.
DATA: W_LINES TYPE I VALUE 0,
PREV_MSGID LIKE MESSAGES-MSGID.
DESCRIBE TABLE MESSAGES LINES W_LINES.
IF W_LINES > 0.
DO 2 TIMES.
I_LINES-LINE = ''.
APPEND I_LINES.
ENDDO.
I_LINES-LINE = '*Messages'.
APPEND I_LINES.
I_LINES-LINE = '*-------------'.
APPEND I_LINES.
LOOP AT MESSAGES.
IF ( MESSAGES-MSGID <> PREV_MSGID ).
CONCATENATE '*' 'Message class:' MESSAGES-MSGID
INTO I_LINES-LINE SEPARATED BY SPACE.
PREV_MSGID = MESSAGES-MSGID.
APPEND I_LINES.
ENDIF.
CONCATENATE '*' MESSAGES-MSGNR MESSAGES-TEXT INTO I_LINES-LINE
SEPARATED BY SPACE.
APPEND I_LINES.
ENDLOOP.
ENDIF.
ENDFORM. " APPEND_MESSAGES_TO_FILE
*-----------------------------------------------------------------------
* DOWNLOAD_SCREENS...
*-----------------------------------------------------------------------
FORM DOWNLOAD_SCREENS TABLES SCREEN_FLOW STRUCTURE I_SCREEN_FLOW
USING VALUE(PROGNAME).
DATA: HEADER LIKE D020S.
DATA: FIELDS LIKE D021S OCCURS 0 WITH HEADER LINE.
DATA: FLOW LIKE D022S OCCURS 0 WITH HEADER LINE.
DATA: W_FILENAME LIKE RLGRAP-FILENAME.
LOOP AT SCREEN_FLOW.
CLEAR HEADER.
CLEAR FIELDS[].
CLEAR FLOW[].
CALL FUNCTION 'RS_IMPORT_DYNPRO'
EXPORTING
DYLANG = SY-LANGU
DYNAME = PROGNAME
DYNUMB = SCREEN_FLOW-SCREEN
IMPORTING
HEADER = HEADER
TABLES
FTAB = FIELDS
PLTAB = FLOW.
CONCATENATE PROGNAME 'screen' SCREEN_FLOW-SCREEN
INTO W_FILENAME SEPARATED BY SPACE.
CONCATENATE P_PATH '\' W_FILENAME '.txt' INTO W_FILENAME.
CALL FUNCTION 'RS_DYNPRO_DOWNLOAD'
EXPORTING
HEADER = HEADER
DESCRIPT = ''
FILE = W_FILENAME
TABLES
FIELDS = FIELDS
FLOWLOGIC = FLOW.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* WS_DOWNLOAD... Write an internal table to file
*-----------------------------------------------------------------------
FORM WS_DOWNLOAD TABLES I_DOWNLOAD
USING FILENAME.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = I_DOWNLOAD.
ENDFORM.
************************************************************************
**************************DISPLAY ROUTINES******************************
************************************************************************
*-----------------------------------------------------------------------
* FILL_TREE_NODE_PROGRAMS
*-----------------------------------------------------------------------
FORM FILL_TREE_NODE_PROGRAMS TABLES I_PROG STRUCTURE I_PROGRAMMES.
DATA: W_PROG TYPE T_PROGRAMMES.
DATA: W_NODE LIKE SNODETEXT.
DATA: WA_SCREENS TYPE T_SCREEN_FLOW.
DATA: WA_MESSAGES TYPE T_MESSAGES.
DATA: WA_INCLUDES TYPE T_INCLUDES.
DATA: WA_DICT_STRUCT TYPE T_DICT_STRUCT.
DATA: WA_FUNC_STRUCT TYPE T_FUNCTIONS.
DATA: STRLENGTH TYPE I.
DATA: TEXT(255).
DATA: W_LINES(4) TYPE C.
DESCRIBE TABLE I_PROG LINES W_LINES.
IF W_LINES = 1.
CONCATENATE W_LINES 'programs downloaded' INTO W_NODE-TEXT2
SEPARATED BY SPACE.
ELSE.
CONCATENATE W_LINES 'programs downloaded' INTO W_NODE-TEXT2
SEPARATED BY SPACE.
ENDIF.
run_time = sy-uzeit - start_time.
write run_time to run_time_char.
concatenate w_node-text2 '- runtime' run_time_char into w_node-text2
separated by space.
*--- Include header display record.
w_node-tlevel = '1'.
W_NODE-TLENGTH2 = 45.
W_NODE-TCOLOR2 = 1.
append w_node to i_node.
LOOP AT I_PROG.
*--- Main programs.
w_node-tlevel = '2'.
CONCATENATE 'Program -' I_PROG-TEXT INTO TEXT SEPARATED BY SPACE.
W_NODE-TEXT2 = I_PROG-PROG.
* Description
STRLENGTH = STRLEN( TEXT ).
W_NODE-TLENGTH3 = STRLENGTH.
W_NODE-TCOLOR3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = TEXT.
* write 'Main Program' to w_node-text3.
APPEND W_NODE TO I_NODE.
*--- Screens.
LOOP AT I_PROG-SCREEN_FLOW INTO WA_SCREENS.
W_NODE-TLEVEL = '3'.
W_NODE-TEXT2 = WA_SCREENS-SCREEN.
W_NODE-TLENGTH3 = 6.
W_NODE-TCOLOR3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = 'Screen'.
APPEND W_NODE TO I_NODE.
ENDLOOP.
*--- Message Classes.
LOOP AT I_PROG-MESSAGES INTO WA_MESSAGES.
AT NEW MSGID.
W_NODE-TLEVEL = '3'.
W_NODE-TEXT2 = WA_MESSAGES-MSGID.
W_NODE-TLENGTH3 = 14.
W_NODE-TCOLOR3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = 'Message class'.
APPEND W_NODE TO I_NODE.
ENDAT.
ENDLOOP.
*--- Includes
LOOP AT I_PROG-INCLUDES INTO WA_INCLUDES.
w_node-tlevel = '3'.
W_NODE-TEXT2 = WA_INCLUDES-PROG.
W_NODE-TLENGTH3 = 8.
W_NODE-TCOLOR3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = 'Include'.
APPEND W_NODE TO I_NODE.
ENDLOOP.
*--- Dictionary structures
LOOP AT I_PROG-DICT_STRUCT INTO WA_DICT_STRUCT.
w_node-tlevel = '3'.
W_NODE-TEXT2 = WA_DICT_STRUCT-TABNAME.
W_NODE-TLENGTH3 = 17.
w_node-tcolor3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = 'Dictionary object'.
append w_node to i_node.
endloop.
*--- Function Modules
LOOP AT I_PROG-FUNCTIONS INTO WA_FUNC_STRUCT.
w_node-tlevel = '3'.
W_NODE-TEXT2 = WA_FUNC_STRUCT-FUNCNAME.
w_node-tlength3 = 17.
w_node-tcolor3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = 'Function Module'.
append w_node to i_node.
endloop.
ENDLOOP.
ENDFORM. " FILL_TREE_NODE
*-----------------------------------------------------------------------
* FILL_TREE_NODE_TABLES...
*-----------------------------------------------------------------------
FORM FILL_TREE_NODE_TABLES TABLES I_DICT STRUCTURE I_DICTIONARY.
DATA: W_LINES(4) TYPE C VALUE '0'.
DATA: W_NODE LIKE SNODETEXT.
DATA: WA_DICT_STRUCT TYPE T_DICT_STRUCT.
LOOP AT I_DICT.
AT NEW TABNAME.
W_LINES = W_LINES + 1.
ENDAT.
ENDLOOP.
IF W_LINES = 1.
CONCATENATE W_LINES 'table downloaded' INTO W_NODE-TEXT2
SEPARATED BY SPACE.
ELSE.
CONCATENATE W_LINES 'tables downloaded' INTO W_NODE-TEXT2
SEPARATED BY SPACE.
ENDIF.
run_time = sy-uzeit - start_time.
write run_time to run_time_char.
concatenate w_node-text2 '- runtime' run_time_char into w_node-text2
separated by space.
*--- include header display record.
w_node-tlevel = '1'.
W_NODE-TLENGTH2 = 45.
w_node-tcolor2 = 1.
append w_node to i_node.
LOOP AT I_DICT.
MOVE-CORRESPONDING I_DICT TO WA_DICT_STRUCT.
AT NEW TABNAME.
W_NODE-TLEVEL = '2'.
W_NODE-TEXT2 = WA_DICT_STRUCT-TABNAME.
W_NODE-TLENGTH3 = 60.
W_NODE-TCOLOR3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = WA_DICT_STRUCT-TABTEXT.
APPEND W_NODE TO I_NODE.
ENDAT.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* FILL_TREE_NODE_FUNCTIONS...
*-----------------------------------------------------------------------
FORM FILL_TREE_NODE_FUNCTIONS TABLES I_FUNC STRUCTURE I_FUNCTIONS.
DATA: W_LINES(4) TYPE C VALUE '0'.
DATA: W_NODE LIKE SNODETEXT.
DESCRIBE TABLE I_FUNC LINES W_LINES.
IF W_LINES = 1.
CONCATENATE W_LINES 'function downloaded' INTO W_NODE-TEXT2
SEPARATED BY SPACE.
ELSE.
CONCATENATE W_LINES 'functions downloaded' INTO W_NODE-TEXT2
SEPARATED BY SPACE.
ENDIF.
RUN_TIME = SY-UZEIT - START_TIME.
WRITE RUN_TIME TO RUN_TIME_CHAR.
CONCATENATE W_NODE-TEXT2 '- runtime' RUN_TIME_CHAR INTO W_NODE-TEXT2
SEPARATED BY SPACE.
*--- include header display record.
w_node-tlevel = '1'.
W_NODE-TLENGTH2 = 45.
w_node-tcolor2 = 1.
append w_node to i_node.
SORT I_FUNC ASCENDING BY FUNCNAME.
LOOP AT I_FUNC.
W_NODE-TLEVEL = '2'.
W_NODE-TEXT2 = I_FUNC-FUNCNAME.
W_NODE-TLENGTH3 = 74.
W_NODE-TCOLOR3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = I_FUNC-STEXT.
APPEND W_NODE TO I_NODE.
ENDLOOP.
LOOP AT I_PROG_INCLUDES.
W_NODE-TLEVEL = '2'.
W_NODE-TEXT2 = I_PROG_INCLUDES-PROG.
w_node-tlength3 = 74.
w_node-tcolor3 = 4.
W_NODE-TPOS3 = 60.
W_NODE-TEXT3 = 'Include'.
append w_node to i_node.
ENDLOOP.
ENDFORM.
*-----------------------------------------------------------------------
* DISPLAY_TREE...
*-----------------------------------------------------------------------
FORM DISPLAY_TREE TABLES I_NODES STRUCTURE SNODETEXT.
DATA: W_NODE LIKE SNODETEXT.
* build up the tree from the internal table node
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
NODETAB = I_NODE
EXCEPTIONS
TREE_FAILURE = 1
ID_NOT_FOUND = 2
WRONG_RELATIONSHIP = 3
OTHERS = 4.
* get the first index and expand the whole tree
READ TABLE I_NODE INTO W_NODE INDEX 1.
CALL FUNCTION 'RS_TREE_EXPAND'
EXPORTING
NODE_ID = W_NODE-ID
ALL = 'X'
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
* now display the tree
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
CALLBACK_PROGRAM = SY-CPROG
CALLBACK_USER_COMMAND = 'CB_USER_COMMAND'
CALLBACK_TEXT_DISPLAY = 'CB_TEXT_DISPLAY'
CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
EXCEPTIONS
OTHERS = 1.
ENDFORM. " DISPLAY_TREE
*-----------------------------------------------------------------------
* TOP_OF_PAGE... for tree display routines.
*-----------------------------------------------------------------------
FORM TOP_OF_PAGE.
ENDFORM.
'SAP > ABAP' 카테고리의 다른 글
SAP TABLE (0) | 2008.09.22 |
---|---|
SAP Object (0) | 2008.09.05 |
셀렉션 스크린에 List Box 만들기 (0) | 2008.08.19 |
SD 관련 T-code (0) | 2008.08.05 |
USER EXIT_BADI 간단정리 (0) | 2008.07.30 |