*-----------------------------------------------------------------------
* 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.
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.
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.
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.
*-----------------------------------------------------------------------
* 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.
*--- 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.
*----------------------------------------------------------------------
* 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.
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' )
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.
*-----------------------------------------------------------------------
* 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.
*-----------------------------------------------------------------------
* 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.
*-----------------------------------------------------------------------
* 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.
*----------------------------------------------------------------------
* 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.
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.
*-----------------------------------------------------------------------
* 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.
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.
*-----------------------------------------------------------------------
* 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.
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.
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.
*-----------------------------------------------------------------------
* 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.
*-----------------------------------------------------------------------
* 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.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.