I was recently debugging a sales order user exit and wanted to see data present in all the internal tables at that point.

Since all internal tables had header line, their records count was not visible in Variable Fast Display of New Debugger.

As a result, it was inconvenient to double click on 226 internal tables only to find that most of them are empty.

This blog will cover:

  1. How to filter the internal tables’ names from a huge list of variables in New Debugger.
  2. How to easily see the record count of a given list of internal tables (esp. the ones with header line)

Scenario demonstration

A breakpoint is set in USEREXIT_READ_DOCUMENT of program MV45AFZZ and a sales order is displayed.

Navigate to Variable Fast Display > Globals tab in New Debugger.

The table icon in second column indicates that it is internal table.

We can’t know whether the table has any record by just looking at Globals tab.

To see the number of records, we need to suffix the internal table names with [].

Entering the names manually is time consuming, adding the suffix is even more time consuming.

Filtering internal tables from global variables list

We can first sort the globals list so that all internal tables are together.

There is no sort button visible, but it can be done by clicking on settings button on right side.

Select the second column, click on settings and do sort.

The sorted list now shows 20+ items at a time.

Since there were 226 internal tables, Block selection (Ctrl+Y) and PageDown cycle wasn’t so good to copy the names.

So, I used same settings button again to save the list to local spreadsheet.

We now have the list of internal tables, but they need to be suffixed with [].

Adding suffix to a list

I used Notepad++ to select every line using (.*) and regex replaced it with \1[] to add [] to all names.

However, MS Excel can also be used to do it easily using concatenation.

Just like ABAP has concatenate and && operator, MS Excel has & operator to join values.

Below screenshot shows the formula used to add suffix. Column A has the list, Column B has [].

Column C has formula =A[RowNumber]&B[RowNumber].

If I didn’t know concatenation operator, I would have pasted Column A and B to Notepad and replaced TAB character with nothing.

Variables 1 tab will be able to show records for this data.

Unfortunately “paste from clipboard” option is not present in Variables 1 tab.

The visible area allows me to display only 25 variables at once.

I copied the suffixed names in batches of 25 to see the records.

This method may seem lengthy, but it is better than double-clicking on 226 internal table names.

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Gaurav Brahmbhatt

    I was looking for a standard fix for this but this also helps. This also reminds me of sharing two such quick-fixes I’ve found out while recently debugging standard programs. Will share them shortly.

    Kudos.!

    (0) 
  2. Suhas Saha

    Hello Manish,

    I have been thinking about this for quite sometime and i think we can easily achieve this using debugger scripting. No need to use excel, ctrl-c, ctrl-v 🙂

    Algorithm is as follows –

    1. Read the global data of the program using cl_tpda_script_data_descr=>globals( ).
    2. Loop on table from §1 get the details of the variable using cl_tpda_script_data_descr=>factory( ). For the variables which are internal tables we can type-cast to the class CL_TPDA_SCRIPT_TABLEDESCR & use the method LINECNT( ) to get the table lines.
    3. Use the variable name from §1 & line count from §2, build an internal table.
    4. Display the internal table using cl_tpda_script_data_display=>data_display( ).

    Sample code looks something like this –

    1.   METHOD script.
    2. ****************************************************************
    3. *Interface (CLASS = CL_TPDA_SCRIPT_DATA_DESCR / METHOD = GLOBALS )
    4. *Importing
    5. *        REFERENCE( P_PROGRAM ) TYPE SY-REPID OPTIONAL
    6. *Returning
    7. *        VALUE( P_GLOBALS_IT ) TYPE TPDA_SCR_GLOBALS_IT OPTIONAL
    8. ****************************************************************
    9.     DATA:
    10.           lwa_global_itab TYPE ty_tab_linecnt.
    11.     TRY.
    12.         LOOP AT cl_tpda_script_data_descr=>globals( ) INTO DATA(lwa_global).
    13. ****************************************************************
    14. *Interface (CLASS = CL_TPDA_SCRIPT_DATA_DESCR / METHOD = FACTORY )
    15. *Importing
    16. *        REFERENCE( P_VAR_NAME ) TYPE TPDA_VAR_NAME
    17. *Returning
    18. *        VALUE( P_DATADESCR ) TYPE REF TO CL_TPDA_SCRIPT_DATA_DESCR
    19. ****************************************************************
    20.           TRY.
    21.               lwa_global_itablines =
    22.               CAST cl_tpda_script_tabledescr(
    23.                    cl_tpda_script_data_descr=>factory( lwa_globalname )
    24.                    )->linecnt( ).
    25.               lwa_global_itabtabname = lwa_globalname.
    26.               APPEND lwa_global_itab TO me->global_itabs_linecnt.
    27.             CATCH ##no_handler
    28.                   cx_tpda_varname
    29.                   cx_sy_move_cast_error
    30.                   cx_tpda_data_descr_invalidated.
    31.           ENDTRY.
    32.         ENDLOOP.
    33.       CATCH cx_tpda_scr_prog .
    34.     ENDTRY.
    35.   ENDMETHOD.                    “script
    36.   METHOD end.
    37.     TRY .
    38.         cl_tpda_script_data_display=>data_display(
    39.       EXPORTING
    40.             p_popup   = abap_true
    41.           CHANGING
    42.             p_data_it = me->global_itabs_linecnt
    43.         ).
    44.       CATCH cx_tpda_table_wrong_table_type.
    45.     ENDTRY.
    46.   ENDMETHOD.                    “end

    If i find time, i’ll publish a document with the detailed steps 😎

    BR,

    Suhas

    (0) 
    1. Manish Kumar Post author

      Hi Suhas

      It would be cool to do it within SAP GUI.

      I have not written any debugger script yet.

      About the last step, would it be possible to use double click to display the actual internal table having data? (just like forward navigation in variable display tool).

      (0) 

Leave a Reply