Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Program to select data from Maintenance View

Link to Content's target Space :

http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP+Development+and+Programming

Summary

Sometimes requirements arises to select data from the Maintenance View. As all of you know that functions like SELECT cannot be used with maintenance view. So this could be achieved by using the function module VIEW_GET_DATA. The function has additional parameters related to subset selection ( Read Cluster View to know about subset ), authorization checks, selection conditions etc.

 REPORT ymaintenance.

DATA:wf_tab TYPE REF TO data,
     repid TYPE sy-repid.

FIELD-SYMBOLS:<fs_tab> TYPE TABLE.

PARAMETERS:pa_view TYPE dd02v-tabname OBLIGATORY.

START-OF-SELECTION.

  create data wf_tab type table of (pa_view).
  IF wf_tab IS BOUND.
    ASSIGN wf_tab->* TO <fs_tab>.
    CHECK <fs_tab> IS ASSIGNED.
  ELSE.
    EXIT.
  ENDIF.

  CALL FUNCTION 'VIEW_GET_DATA'
       EXPORTING
            view_name              = pa_view
            with_authority_check   = 'X'
       TABLES
            data                   = <fs_tab>
       EXCEPTIONS
            no_viewmaint_tool      = 1
            no_authority           = 2
            no_auth_for_sel        = 3
            data_access_restricted = 4
            OTHERS                 = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_structure_name   = pa_view
            i_callback_program = repid
       TABLES
            t_outtab           = <fs_tab>
       EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.