Monday 15 May 2023

Hide ToC transports in ABAP Version Management (enhancement)

This time I come to you with an easy to implement enhancement, which will forever change your lives as ABAP developers.

How many times have you struggled with the ToCs cluttering your list of transports in the Versions Management view? Now there is a solution to that issue. After implementing the steps shown below you will be able to filter out all ToCs and enjoy clean list of transports. Enjoy!

Implementation


1. Enhance class CL_VERS_OBJTYPE_UI_ALV

i. Add private attribute MV_HIDE_TOC with type FLAG and default value of ABAP_FALSE.

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification

MV_HIDE_TOC attribute

ii. Add public method TOGGLE_HIDE_TOC.

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification

TOGGLE_HIDE_TOC method

iii. Implement the method with code shown below.

METHOD toggle_hide_toc.
  IF mv_hide_toc = abap_true.
    mv_hide_toc = abap_false.
  ELSE.
    mv_hide_toc = abap_true.
  ENDIF.
ENDMETHOD.

iv. Add “Post-Exit” to standard method OBJ_VERSION_INFO and implement it as shown below.

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification
Post-Exit for OBJ_VERSION_INFO method

METHOD ipo_yx_eo_vers_objtype_ui_alv~obj_version_info.
*"------------------------------------------------------------------------*
*" Declaration of POST-method, do not insert any comments here please!
*"
*"methods OBJ_VERSION_INFO
*" importing
*" !IV_RFCDEST type RFCDEST
*" changing
*" !ET_VERS type VRSD_TAB
*" raising
*" CX_VERS_UI_EXCEPTION .
*"------------------------------------------------------------------------*

  CONSTANTS:
    lc_transport_number_local TYPE verskorrno VALUE 'LOCAL',
    lc_transport_type_toc     TYPE trfunction VALUE 'T'.

  DATA:
    lv_tabix LIKE sy-tabix,
    ld_version TYPE REF TO vrsd,
    lt_trkorr TYPE SORTED TABLE OF trkorr WITH UNIQUE KEY table_line.

  CHECK core_object->mv_hide_toc = abap_true
    AND et_vers[] IS NOT INITIAL.

  SELECT trkorr
    INTO TABLE lt_trkorr
    FROM e070
    FOR ALL ENTRIES IN et_vers
    WHERE trkorr = et_vers-korrnum
      AND trfunction <> lc_transport_type_toc.

  LOOP AT et_vers REFERENCE INTO ld_version
    WHERE korrnum IS NOT INITIAL
      AND korrnum <> lc_transport_number_local.

    lv_tabix = sy-tabix.

    READ TABLE lt_trkorr TRANSPORTING NO FIELDS
      WITH TABLE KEY table_line = ld_version->korrnum.
    CHECK sy-subrc <> 0.

    DELETE et_vers INDEX lv_tabix.
  ENDLOOP.
ENDMETHOD.

2. Open report SAPLSVRS_UI.

i. Go to screen 0101 and enter the USER_COMMAND_0101 module.

At the end of the CASE statement (end of module) add modification as shown below.

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification
USER_COMMAND_0101 module modification

  WHEN 'TOC'.
    gr_vers_objtype_ui_alv->toggle_hide_toc( ).

ii. Go to GUI status “VER_STATUS” and enter edit mode. Add new function key “TOC” and populated its details.

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification
TOC function key

iii. Add the newly added function key to the application toolbar. Activate first the function key (Function Code button in the toolbar) and then the GUI status.

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification
Application toolbar with TOC function key

Enjoy!


Now you can easily hide/show ToCs when needed. Hope this helps!

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification
Toolbar with the new button

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification
List of transports w/ ToCs

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Career, SAP ABAP Tutorial and Materials, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning, SAP ABAP Certification
List of transports w/o ToCs

No comments:

Post a Comment