List of local objects in the SAP system

This Program provides you with a list of all the objects in SAP System.

*----------------------------------------------------------------------
* Report ZLOCAL
* Author: Swarna.S. (Tata Consultancy Services)
*----------------------------------------------------------------------
* AS: List of local objects in the SAP system(Y objects and Z objects)
*----------------------------------------------------------------------

REPORT ZLOCAL NO STANDARD PAGE HEADING.
*structure declaration for tadir objects

types: BEGIN OF wa_tadir,
pgmid type tadir-pgmid,
object type tadir-object,
obj_name TYPE tadir-obj_name,
author TYPE tadir-author,
masterlang type tadir-masterlang,
END OF wa_tadir.

*OK code declaration
Data : ok_code like sy-ucomm.

*Internal table and wa declaration for objects
DATA: it_dir TYPE STANDARD TABLE OF wa_tadir INITIAL SIZE 0,
wa_dir type wa_tadir.

*ALV declarations

DATA: c_ccont TYPE REF TO cl_gui_custom_container, "Custom container
c_alvgd TYPE REF TO cl_gui_alv_grid, "ALV grid object
it_fcat TYPE lvc_t_fcat, "Field catalogue
it_layout TYPE lvc_s_layo. “ALV layout

*Parameter decl aration for number of rows
PARAMETERS : ROWS(5) type c.

*initialization event
INITIALIZATION.

*Start of selection event
START-OF-SELECTION.

*fetching data from the table TADIR only local objects and Y AND Z
*developed

SELECT obj_name
author
pgmid
object
masterlang
FROM tadir
INTO corresponding fields of TABLE it_dir
up to ROWS rows
WHERE devclass = '$TMP'
AND ( obj_name LIKE 'Z%' OR obj_name LIKE 'Y%' ).

* * Calling the ALV screen with custom container
CALL SCREEN 0600.

**On this statement double click it takes you to the screen painter
*SE51.*Enter the attributes
*Create a Custom container and name it CC_CONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid
** PBO of the actual screen ,
* Here we can give a title and customized menu
*&---------------------------------------------------------------------*
*& Module STATUS_0600 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

module STATUS_0600 output.
*We have defined a GUI status for EXIT in SE41 by double clicking
* the PF-STATUS ZLOCAL.Enter EXIT in application toolbar and
*assign a function key and text’ EXIT’ to it.Save and Activate
SET PF-STATUS 'ZLOCAL'.

*Title of the ALV is set here as ‘List of local objects in SAP system(Y*/Z*)
*This can be given by doubleclicking ZLOCAL and enter the title text
SET TITLEBAR 'ZLOCAL'.

endmodule. " STATUS_0600 OUTPUT

* calling the PBO module ALV_GRID.
*&---------------------------------------------------------------------*
*& Module ALV_GRID OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

MODULE alv_grid OUTPUT.
*Creating custom container
CREATE OBJECT c_ccont
EXPORTING
container_name = 'CC_CONT'.

*Creating ALV grid

CREATE OBJECT c_alvgd
EXPORTING
i_parent = c_ccont.

* Set field for ALV
PERFORM alv_build_fieldcat.

* Set ALV attributes FOR LAYOUT
PERFORM alv_report_layout.

CHECK NOT c_alvgd IS INITIAL.

* Call ALV GRID
CALL METHOD c_alvgd->set_table_for_first_display
EXPORTING
is_layout = it_layout
CHANGING
it_outtab = it_dir
it_fieldcatalog = it_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ENDMODULE. " ALV_GRID OUTPUT

*&---------------------------------------------------------------------*
*& Form alv_build_fieldcat
*&---------------------------------------------------------------------*
* <--P_IT_FCAT text
*----------------------------------------------------------------------*

FORM alv_build_fieldcat.
DATA lv_fldcat TYPE lvc_s_fcat.
CLEAR lv_fldcat.

lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '1'.
lv_fldcat-fieldname = 'OBJECT'.
lv_fldcat-tabname = 'IT_DIR'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Object'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.

lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '2'.
lv_fldcat-fieldname = 'PGMID'.
lv_fldcat-tabname = 'IT_DIR'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Program ID'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.

lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '3'.
lv_fldcat-fieldname = 'AUTHOR'.
lv_fldcat-tabname = 'IT_DIR'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Author'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.

lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '4'.
lv_fldcat-fieldname = 'OBJ_NAME'.
lv_fldcat-tabname = 'IT_DIR'.
lv_fldcat-outputlen = 50.
lv_fldcat-scrtext_m = 'Object name'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.

lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '5'.
lv_fldcat-fieldname = 'MASTERLANG'.
lv_fldcat-tabname = 'IT_DIR'.
lv_fldcat-outputlen = 5.
lv_fldcat-scrtext_m = 'Language'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.

ENDFORM. " alv_build_fieldcat

*&---------------------------------------------------------------------*
*& Form alv_report_layout
*&---------------------------------------------------------------------*
FORM alv_report_layout.

it_layout-cwidth_opt = 'X'.
it_layout-zebra = 'X'.

ENDFORM. " alv_report_layout

* PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes
*and based on the user command we can do the coding.
*We have given the EXIT coding in the PAI
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0600 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

module USER_COMMAND_0600 input.

if ok_code = 'EXIT'.
LEAVE PROGRAM.
ENDIF.

endmodule. "USER_COMMAND_0600 INPUT

Understand more about ALV.

Leave a Reply

Your email address will not be published. Required fields are marked *