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

HELP IN TRY

Former Member
0 Likes
440

HI,

i wont to catch error when the table that i receive is empty ,

how i can do it with try@catch,

i new with try and catch.

Regards

DATA:  eref TYPE REF TO cx_root.

  CREATE OBJECT oref.

  TRY.

      CALL METHOD oref->fin
        EXPORTING
          znodefather = znode
        RECEIVING
          node_tab    = no.

    CATCH cx_root INTO eref.

  ENDTRY.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
421

Unless it is an error - i.e. you don't expect it to come back empty - it is bad programming practice to use exceptions to control program flow.

Why not use IF mytab IS INITIAL instead?

In any case, you'll have to use that. With your example, the method oref->fin will need some code like:

IF mytab IS INITIAL.
  RAISE my_exception.
ENDIF.

matt

3 REPLIES 3
Read only

Former Member
0 Likes
421
Read only

matt
Active Contributor
0 Likes
422

Unless it is an error - i.e. you don't expect it to come back empty - it is bad programming practice to use exceptions to control program flow.

Why not use IF mytab IS INITIAL instead?

In any case, you'll have to use that. With your example, the method oref->fin will need some code like:

IF mytab IS INITIAL.
  RAISE my_exception.
ENDIF.

matt