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

generated constructor in exception classes - ommitted textid in superclass

rainer_hbenthal
Active Contributor
0 Likes
458

Hi,

debugging another program i stopped in the constructor of one of my own exception classes. Starring at the code one questoion arised

method constructor.
call method super->constructor
exporting
textid = textid
previous = previous
.
 if textid is initial.
   me->textid = zcx_xi .
 endif.
me->errortext = errortext .
me->sysid = sysid .
endmethod.

First of all i would use

if textid is *supplied*.
   me->textid = zcx_xi .
 endif.

But this is not my question. If i'm raising this exception without supplying the textid the superclass is call with an initial textid, which is filled later pn with the predefined class named textid.

If i'm raising this exception specifying the textid as

raise exception type zcx_xi exporting textid = zcx_xi=>zcx_xi errortext = message.

the super class will not get an intial textid but the predefined one.

Both versions are working well delivering the errortext by the get_text( ) method in the catch branch.

But... is there really no difference calling the super class with initial value or given value?

1 REPLY 1
Read only

naimesh_patel
Active Contributor
0 Likes
301

It looks like there is no difference.

This code replaces any existing TEXTID set by Super class when we don't pass any TEXTID.


 IF textid IS INITIAL.
   me->textid = CX_SY_ZERODIVIDE .
 ENDIF.

If the code uses the attribute TEXTID (me->textid) instead of the importing parameter TEXTID, than it would make a lot difference.


 IF ME->textid IS INITIAL.   " Attribute TEXTID 
   me->textid = CX_SY_ZERODIVIDE .
 ENDIF.

I guess, we need some SAP Official response before going ahead.

Regards,

Naimesh Patel