Skip to Content
Personal Insights
Author's profile photo Joachim Rees

Ranges and logging. A solution: log_selection_range.

When programming (for me it’s EWM but surely it applies in my fields), I sometimes use ranges.
I use logging (SLG1) and want those ranges’ content to also be logged.
I want clean code and not so much typing.

So this is what I use:

    METHODS log_selection_range IMPORTING iv_name  TYPE string
                                          ir_range TYPE rseloption.
  METHOD log_selection_range.
*Selection / range for &1:
    MESSAGE s014 WITH iv_name.
    log->add_message( ).
    LOOP AT ir_range ASSIGNING FIELD-SYMBOL(<range>).
*&1 &2 &3 &4.
      MESSAGE s015 WITH <range>-sign
      log->add_message( ).

And this is how I use it:

    "(1. fill ranges - not in picture)
    "2. log ranges:
    log_selection_range( iv_name = 'MATNR' ir_range = lr_matnr ).
    log_selection_range( iv_name = 'LGTYP' ir_range = lr_lgtyp ).
    "3. use ranges:
    srv_hu->hu_select_gen( EXPORTING ir_matnr = lr_matnr
                                     ir_lgtyp = lr_lgtyp
                           IMPORTING et_huitm = DATA(lt_hu_item) ). 

What do you think?
How do you handle logging and ranges?


Assigned Tags

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

      Just curious why you are logging Selections?
      Is this a report that you log to document that it was executed and executed with these parameters?

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      I have the same question as Ken: why do you need logging of ranges?

      To answer your question "How do you handle logging and ranges?" - I don't. 🙂 When I use logging, it is to log a specific situation, so there will usually be some kind of ID present. I can only imagine the need to capture ranges when a report is executed in background and you need to capture what was on the selection screen. But I wouldn't put this in the system log. I usually add this information using MESSAGE, so that it's available in the job log.

      I'm having hard time imagining a scenario that would really, really need a range to be logged in the system log.