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 help

Former Member
0 Likes
605

Hi,

i create exception class like it write in the sap help and when i want to send the exception with parameters to the ABOVE METHODS i don't susses i just get the message without the parameter ?

there is simple guideline how o transfer the exception with parameters?

br

Ricardo

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
565

Hello Ricardo

When you trigger the exception you need to feed the EXPORTING parameters with the values:


report  DEMO_RAISE_EXCEPTIONS.

data OREF type ref to CX_ROOT.
data TEXT type STRING.

try.
  try.
    raise exception type CX_DEMO_CONSTRUCTOR
          exporting MY_TEXT = SY-REPID.  " <<<
    catch CX_DEMO_CONSTRUCTOR into OREF.
      TEXT = OREF->GET_TEXT( ).
      write / TEXT.
      raise exception OREF.
  endtry.
  catch CX_DEMO_CONSTRUCTOR into OREF.
    TEXT = OREF->GET_TEXT( ).
    write / TEXT.
endtry.

Regards

Uwe

Read only

0 Likes
565

HI Uwe,

Thanks,

This is my sample code:

This is the first method on the tree:

the method name is create .

 ....
INSERT (lt_table_name) FROM <ls_obj>.
    IF sy-subrc <> 0.
      RAISE EXCEPTION TYPE /cx_db_db_error
        EXPORTING
          textid     = cx_db_error=>create_failed
          table_name = lt_table_name.
    ENDIF.

this method call to the above method - create .


...
 TRY.
        CALL METHOD lo_obj_create->create
          CHANGING
            is_bound_object = ls_obj_user.

      CATCH cx_db_error INTO lo_exc.
        "Create user failed. Throw an exception.
        RAISE EXCEPTION TYPE cx_db_error
          EXPORTING
            textid     = cx_db_error=>create_user_error
            previous   = lo_exc.
        result = lo_exc->get_text( ).

    ENDTRY.

here in result i just get the massage without the table name that i export in the first method ,what i miss here ?

Best Regards

Ricardo

Read only

0 Likes
565

(deleted - misread post)

Edited by: Pascal Schlecht on Jul 16, 2009 2:27 PM

Read only

Former Member
0 Likes
565

This message was moderated.