Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Exception class with SY-message

alejiandro_sensejl
Active Participant
0 Likes
2,849

Hello everyone,

Iu2019m playing around with this new-fashioned exception stuff called exception classes. To start with I want to create a common class that handles u201Cold schoolu201D exceptions of function modules.

This exception class should read the message from the syst fields automatically and return it later via (already existing interface) method GET_TEXT. Iu2019d like to avoid filling the message manually at the constructor, because I think this isnu2019t something that needs be implemented every time I use the exception, but rather be handled by the class itself. It would also be an advantage to get this done without any data definitions in the routine that invokes (RAISE EXCEPTION TYPE u2026) the exception!

Is there any way or best practice to achieve this without some intricate using of the TEXTID (of type IF_T100_MESSAGE=>T100KEY)?

I hope you can understand what Iu2019m trying to do!

Thanks in advance and kind regards,

Alej

3 REPLIES 3
Read only

Former Member
0 Likes
1,169

Hi,

I am not really sure...but well if I understand you want the message to be in sy-* structure and raise the exception class...the best way to do is...

message XXX in l_dummy.

Raise exception type cx_***

now in exception class constructor or catch clause you can access sy-* structure to access the message.

I hope I cold answer this.

Regards,

Jemin Tanna

Read only

alejiandro_sensejl
Active Participant
0 Likes
1,169

After a while I gave up and forgot about this

Someone has an idea one year later?

Read only

0 Likes
1,169

I'm currently doing something like this:

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO ld_message.
RAISE EXCEPTION TYPE zcx_exception EXPORTING text = ld_message.