Friday, 17 August 2018

Copy Customizing Path

I developed useful functionality for SPRO

I detected that is common the necessity of copy IMG path when you navigated of SPRO Tree Customizing .

With the following code you can copy the path very easy

The change is only apply in Developer System and is necessary register one standard object.

Step 1: Add customer Button in Status GUI IMG_DISP of Function Group S_IMG_TOOL_1.


Register the object in Marketplace, before the changes apply

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Certifications, SAP ABAP Tutorial and Materials

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Certifications, SAP ABAP Tutorial and Materials

Create a Custom Function Code “ZCOPY_P”

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Certifications, SAP ABAP Tutorial and Materials

Add custom Function Code “ZCOPY_P”

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Certifications, SAP ABAP Tutorial and Materials

Add Custom Code Functions in Interface and Key Function

SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Certifications, SAP ABAP Tutorial and Materials

Step 2: Insert Implicit Enhancement in INCLUDE: LSHI01F0X – end of FORM  execute_user_command


SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Certifications, SAP ABAP Tutorial and Materials

Step 3: Add the following ABAP code and active the implicit enhancement


DATA: lv_nodekey TYPE tv_nodekey ,
      le_item TYPE shi_item,
      le_node TYPE treev_node,
      lv_relatkey TYPE tv_nodekey,
      lv_text(500) TYPE c ,
      lv_relatship_ant TYPE int4,
      lt_path TYPE STANDARD TABLE OF char100,
      le_path TYPE char100,
      lv_choise TYPE  sy-tabix.

CASE fcode.
  WHEN 'ZCOPY_P'.
    CHECK g_tree_data->tree IS NOT INITIAL.
    READ TABLE g_tree_data->nodes INTO le_node WITH KEY node_key =  g_tree_data->node_key  .
    CHECK sy-subrc = 0.
    READ TABLE g_tree_data->items INTO le_item WITH KEY node_key =  g_tree_data->node_key  item_name = 'TEXT'.
    CHECK sy-subrc = 0.
    le_path =  le_item-text.
    APPEND le_path TO lt_path.
    lv_relatkey  = le_node-relatkey.
    lv_relatship_ant = le_node-relatship.
    WHILE lv_relatkey IS NOT INITIAL.

      READ TABLE g_tree_data->nodes INTO le_node WITH KEY node_key =  lv_relatkey .

      READ TABLE g_tree_data->items INTO le_item WITH KEY node_key =  le_node-node_key item_name = 'TEXT' .

      lv_relatkey = le_node-relatkey .

      IF  le_item-text IS NOT INITIAL AND  lv_relatship_ant = '4'.
        CONCATENATE le_item-text '->' INTO le_path.
*        le_path =  le_item-text.
        INSERT le_path INTO lt_path  INDEX 1.
      ENDIF.
      lv_relatship_ant =  le_node-relatship..
    ENDWHILE.

    CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
      EXPORTING
        endpos_col   = 130
        endpos_row   = 10
        startpos_col = 40
        startpos_row = 1
        titletext    = 'Ruta de ConfiguraciĆ³n'
*      IMPORTING
*        choise       = lv_choise
      TABLES
        valuetab     = lt_path
      EXCEPTIONS
        break_off    = 1
        OTHERS       = 2.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

Step 4: Active all objects and test de functionality. TCode SPRO–> F5 –> “Copy IMG Path”


SAP ABAP Development, SAP ABAP Extensibility, SAP ABAP Certifications, SAP ABAP Tutorial and Materials

No comments:

Post a Comment