Skip to Content

Local exception class in global class

Hi,

in SE24, tab "local types", the comment given by SAP says:

*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature

Now I've defined a local exception class in this tab:

CLASS lcx_my_exception DEFINITION INHERITING FROM cx_static_check.

ENDCLASS.

So far no error occurs.

But when trying to use it in the signature of a private! class, it is not known and I'm asked wether I like to create it as a global exception class.

Why isn't the exception class recognized?

My mistake or a bug?

Regards,

Dirk

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Oct 22, 2012 at 07:44 AM

    Hello Dirk,

    i cant follow that problem.

    I tried the following:

    • Created a global class.
    • Entered the following under Local Types:

    *"* use this source file for any type declarations (class
    *"* definitions, interfaces or data types) you need for method
    *"* implementation or private method's signature

    CLASS lcl_cx DEFINITION INHERITING FROM cx_static_check.

    ENDCLASS. "lcl_cx DEFINITION


    • Declared the exception in a private testmethod with the following code:

    METHOD i_raise_it.

    RAISE lcl_cx.

    ENDMETHOD.

    No error occurs.

    Even if I make the method public, it works.

    I did this in ECC 6.0.

    Maybe this works not until a special version?

    Regards,

    Stefan Wolf

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 05, 2012 at 07:37 AM

    Your mistake. Class based exceptions for methods must be globally defined exceptions. It'd be kind of nice if you could use private ones though.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 22, 2013 at 01:44 AM

    Hi Dirk,

    I've been trough the same issue and "solved" it by declaring the super class (CX_DYNAMIC_CHECK in my case) in the signature of my private method.

    Works fine for me.

    Cheers,

    Custodio

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.