Skip to Content
Author's profile photo Petr Plenkov

Advanced navigation to a source code from the message long text.

Hi again.

In the previous post I described the basic concepts of programming using SE91 messages

How to use messages properly in the code. Common rules.

If you used to do OO programming your logic probably works on class-based exceptions.

In most of cases I would choose IF_T100_MESSAGE variant to explain the reason of the error (Rule #4)

Meanwhile, sometime you have a foreign code you’re not responsible to modify and this code raises an exception.

Now we speak about the case when you want to output the message immediately. To be abstract let’s just use cx_root example.

If you go the easiest way:

do_something( ).
catch cx_root into data(lo_cx).
  message lo_cx->get_text( ) type 'I' .

you will get the popup:


but unfortunatelly F1 button won’t work here. Debugger on you, my friend.

But let’s jut imagine that we press F1 and have a documentation like this:


and when we click “Navigate to source” link we go directly to the source code when the exception has been raised:


Pretty cool, isn’t it?! =)

Let’s just see how many actions do we need to do this? Saying it before, i wanted to reuse standard SAP UI without own screen creation.

1. We need 3 SET/GET parameters.

Go to SE80.

Edit object (Shift+F5) -> Enhanced options -> SET/GET parameter ID -> type zcw_nav_prog -> Create (F5).

repeat these steps for zcw_nav_incl and zcw_nav_line parameters.

2. Go to SE38 and create a very simple program:

program zcw_navigate_to_source.
  p_prog type syrepid memory id zcw_nav_prog,
  p_incl type syrepid memory id zcw_nav_incl,
  p_line type num10 memory id zcw_nav_line.
  /iwfnd/cl_sutil_moni=>get_instance( )->show_source(
      iv_program    = p_prog    " Source Program
      iv_include    = p_incl    " Source Include
      iv_line       = conv #( p_line )   " Source Line
      iv_new_window = ''    " New Window

I really hope you have this component. If not – you can find something similar in where-used-list for ‘RS_ACCESS_TOOL’ FM

3. Create ZCW_NAV_SRC transaction in SE93.

Choose report transaction and assign ZCW_NAVIGATE_TO_SOURCE report to it.

4. We need a real SE91 message.

Just create some message with the text &1&2&3&4. Remove self-explanatory flag and go to long text.

Put the cursor where you wish to place a link ->Insert menu -> Link

Choose “Link to transaction and skip first screen” as Document class, use the transaction from step 3.

“Name in Document” is the real text that you see on the screen like “Navigate to source”.

5. Now we’re ready to code.

  do_something( ).
catch cx_root into data(lo_cx).
" get source code position
          program_name =  data(lv_prog)   " ABAP Program: Current Main Program
          include_name =  data(lv_incl)
          source_line  =  data(lv_line)
      " it's not possible to store integer as parameter value
      data(lv_line_c) = conv num10( lv_line ).
      " export parameter values
      set parameter id 'ZCW_NAV_PROG' field lv_prog.
      set parameter id 'ZCW_NAV_INCL' field lv_incl.
      set parameter id 'ZCW_NAV_LINE' field lv_line_c.
          begin of message_ts ,
             msgv1 type bal_s_msg-msgv1,
             msgv2 type bal_s_msg-msgv2,
             msgv3 type bal_s_msg-msgv3,
             msgv4 type bal_s_msg-msgv4,
           end of message_ts .
      " parse our string to message format
      data(ls_message) = conv message_ts( lo_cx->get_text( ) ).
      " Output, don't forget we always use static message definition
      " Put here message created in Step 4.
      message id 'ZCW_COMMON' type 'I' number 124
        with ls_message-msgv1

That’s it! What I actually did – I put this handling logic into a minimalistic method ZCL_MSG=>CX( lo_cx ) and actively use it in my code.

I hope you enjoyed it.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sergio Fraga
      Sergio Fraga

      Amazing work Petr.

      I am just wondering how to avoid the SET/GET to memory just because I don't like to use them..

      I was wondering if a songleton instace class with SET/GET methods could do it but I don't think so since as soon we have output we loose the context.

      Nevertheless I will try and share the results.

      Thanks for the contribution, I will definetily use it!


      Author's profile photo Petr Plenkov
      Petr Plenkov
      Blog Post Author

      Thanks Sergio.

      To be honest I do not like them neither.

      But here the point - we're able to add the link only to transaction or report to submit.

      In both variants new session is started and it's not possible to use global context.

      Moreover, report call doesn't even support SET/GET parameters. So that's why I've chosen transaction.

      Author's profile photo Tamás Holics
      Tamás Holics

      Hi Petr,

      Thank you for this post, you gave me an idea to include a similar feature in our certified SAP add-on. Now all these source code details can be saved to tickets in external ITSM platforms or directly to SAP Solution Manager tickets.

      You can see how this works here:

      All the best,