Skip to Content


Aug 24, 2017 at 03:07 PM


avatar image


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?


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Bertrand DELVALLEE 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


Show 2 Share
10 |10000 characters needed characters left characters exceeded


Thank you for the response. I have that exact thing in my code right now, but it still crashes it. It doesn't seem to catch the dump before it happens unfortunately.

Any other ideas?




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.


Sandra Rossi 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)).

10 |10000 characters needed characters left characters exceeded
Horst Keller
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).

Show 2 Share
10 |10000 characters needed characters left characters exceeded

I'm not sure what you mean by that. I check every single program with the RS_SYNTAX_CHECK function, and it does catch some of them, but there are some that it doesn't catch.

For example, one of the programs that fails, I just stepped through the code at the RS_VARIANT_CONTENTS on that program, and it dumped out 2 steps in with a CX_SY_IMPORT_MISMATCH_ERROR on that program. You would assume that RS_SYNTAX_CHECK would've caught something like that, but it doesn't. And also the TRY CATCH cx-root I have doesn't get it either. It's just a dump and the program closes out after that.


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 ...).