Skip to Content



I'm trying to call RS_VARIANT_CONTENTS on each of the report/variant combos from VARID. I have found that there are some programs out there that have been saved with syntax errors which causes RS_VARIANT_CONTENTS to crash when it is run. Unfortunately, there are thousands of variants in the system, so this takes a while to run and get results for each of the selection field values. I have attempted to just remove the programs that I know cause errors from the table before calling RS_VARIANT_CONTENTS, but each time I run it, there seems to be another program that pops up. Also, we are hoping to have this run somewhat frequently, so I'm looking for a solution that can work to catch programs in the future that would cause RS_VARIANT_CONTENTS to fail.

I have tried RS_SYNTAX_CHECK, which caught some of them, but there are still others out there that RS_SYNTAX_CHECK doesn't catch and they result in a runtime error dump.

Anyone have ideas for this?


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Aug 24, 2017 at 03:49 PM

    Hello Matthew,

    Did you try TRY/CATCH statements? This should prevent any dump and allow you to detect "bad" variant.

    * call function 'RS_VARIANT_CONTENTS' [...]
    CATCH cx_root.
    * mention a technical error in your report screen for that variant 

    Have a closer look to your dump screens in order to replace cx_root by a more precise error type.

    Best regards


    Add comment
    10|10000 characters needed characters exceeded

    • Hello,

      CX_SY_IMPORT_MISMATCH_ERROR could indicate that error come from old variants created in a previous version of SAP. Did your machine upgraded from a 4.6 (or non unicode system)?

      If so, you could run RS_VARIANT_INFO (with prog_range = [I,EQ,progname, ]) and for old variants (previous to upgrade) call RS_VARIANT_CONTENTS with NO_IMPORT = 'X' and analyse their parameters list in debug. May be this way you will find a way to identify bad variants (and build an algorithm).

      Another way to prevent uncatchable dump is to run a dedicated external specific program in a job/batch (or call FM in a new task may be, I've never tried for that purpose). Retreive data from its spool, no data means dump happened, deal with it.


  • Aug 26, 2017 at 09:23 AM

    It may be useful to run the function module RS_VARIANT_CONTENTS with parameter EXECUTE_DIRECT = 'X' and use EXCEPTIONS ERROR_MESSAGE = 99, otherwise it does a SUBMIT to retrieve the variant contents (so you can't handle any exception), and any error message sent with type 'A' will terminate your program (it may execute MESSAGE A093(DB)).

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 24, 2017 at 04:27 PM

    Write a little helper program that reads the respective programs into an internal table and execute the SYNTAX-CHECK statement for each of them? That's what I would do (and in fact do, e.g. every night for all the examples of the ABAP Documentation).

    Add comment
    10|10000 characters needed characters exceeded

    • Well that's a different story. You don't have syntax but runtime errors! And those cannot be found by the syntax check of course.

      1 / num

      is syntactically correct but crashes if num contains 0.

      With TRY CATCH you can catch only the catchable exceptions. For uncatchable exceptions you always have to take care of the root cause.

      But in fact CX_SY_IMPORT_MISMATCH_ERROR is catchable. But note, that exceptions are not propagated outside of programs. Therefore there is no use to put a TRY CATCH around a submit. For such a kind of testing you might write a UNIT test (conceptually a misuse, but we'll ...).