This report can find CONSTANTS and STATICS in SAPMV45A Z-includes. We know that Constants and Statics consume global variables so identifying them can help reduce their usage and improve GV count.
*&---------------------------------------------------------------------*
*& Report ZGB_TEST_36
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zzcoe_sd_include_search.
TYPES: BEGIN OF lty_coding_ext,
funcname TYPE trdir-name,
context(40) TYPE c,
lfdnr(5) TYPE n,
lineno(5) TYPE n,
codeline(255) TYPE c,
END OF lty_coding_ext.
TYPES: BEGIN OF lty_include,
include TYPE repid,
END OF lty_include.
DATA: lt_include TYPE TABLE OF lty_include.
DATA: lt_statement TYPE TABLE OF lty_coding_ext.
DATA: ls_statement TYPE lty_coding_ext.
DATA: ls_include TYPE lty_include.
DATA : lt_gen_limit TYPE TABLE OF progname.
DATA: lv_string TYPE string.
*PARAMETERS:
* pa_text TYPE char50 DEFAULT 'CONSTANTS'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01.
PARAMETERS:
rb_con RADIOBUTTON GROUP rb1 DEFAULT 'X',
rb_sta RADIOBUTTON GROUP rb1.
* rb_ref RADIOBUTTON GROUP rb1.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
IF rb_con IS NOT INITIAL.
lv_string = 'CONSTANTS'.
ENDIF.
IF rb_sta IS NOT INITIAL.
lv_string = 'STATICS'.
ENDIF.
* IF rb_ref IS NOT INITIAL.
* lv_string = '=>'.
* ENDIF.
* MOVE pa_text TO lv_string.
CALL FUNCTION 'RS_GET_ALL_INCLUDES'
EXPORTING
program = 'SAPMV45A'
* WITH_INACTIVE_INCLS = ABAP_FALSE
* WITH_RESERVED_INCLUDES = ABAP_FALSE
* WITH_CLASS_INCLUDES = ABAP_TRUE
* WITH_E_INCLUDES = ABAP_FALSE
TABLES
includetab = lt_gen_limit
EXCEPTIONS
not_existent = 1
no_program = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_gen_limit ASSIGNING FIELD-SYMBOL(<lfs_gen_limit>).
IF <lfs_gen_limit>+0(1) = 'Y' OR <lfs_gen_limit>+0(1) = 'Z'.
ls_include-include = <lfs_gen_limit>.
APPEND ls_include TO lt_include.
ENDIF.
ENDLOOP.
*ls_include-include = 'ZOTCE0229_POE_FOR_RETURNS'.
*
*APPEND ls_include TO lt_include.
CALL FUNCTION 'AA_CUS_SCAN_PROG_FOR_STRING'
EXPORTING
id_string1 = lv_string
* ID_STRING2 = lv_string
* ID_PROGRAM =
* IMPORTING
* EF_FOUND =
TABLES
it_program = lt_include
et_coding = lt_statement.
*LOOP AT lt_statement INTO ls_statement.
* WRITE: / ls_statement-funcname,
* ls_statement-context,
* ls_statement-lfdnr,
* ls_statement-lineno,
* ls_statement-codeline.
*ENDLOOP.
*==============Display ALV==================*
DATA: gr_table TYPE REF TO cl_salv_table.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = lt_statement. " Provide the table name
CATCH cx_salv_msg.
ENDTRY.
TRY.
gr_table->get_columns( )->get_column( 'CODELINE' )->set_leading_spaces( abap_true ).
CATCH cx_salv_not_found.
ENDTRY.
*... Display Table
gr_table->display( ).