Application Development 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: 

how does try...endtry work if try fails?

Former Member
0 Kudos

Hi Gurus,

I have a question. Will the code inside try...endtry be executed if TRY statement fails.

To be specific, see my scenario below. itab is an internal table with only one field 'line' of type c and length 100. cx_sy_conversion_codepage is used to handle unicode error. How will the code below work if itab-line has a unicode error?

Will it skip that particular line or will that line be moved to the unix file?

LOOP AT itab.

TRY.

TRANSFER itab-line TO unix_file.

CATCH cx_sy_conversion_codepage.

ENDTRY.

ENDLOOP.

Thank you,

Nobin

5 REPLIES 5

Former Member
0 Kudos

As per ur sample code. The exception will be caught. No DUMP will happen.

U can you that exception & raise a message or do the further processing.

Regards,

Bhargava

0 Kudos

Hi,

Will that particular record be moved to the unix file or will that be skipped?

Thanks

0 Kudos

Hi,

The record won't be moved if an exception occurs.

Regards,

Anand Patil.

0 Kudos

- No program will continue after the ENDTRY.(no code after CATCH)

- If you want to do something, it should be executed in the appropriate CATCH block

- TRY/CATCH will only disable the Dump, it will not correct the error causes

Regards,

Raymond

Former Member
0 Kudos

The catch statement will only handle the class-based exception in the try block, since the error in your case is not the class based one, it will not be handled. It is handled by the system in the same way as it is written outside the try block.