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

Multiple Try END Try

Former Member
0 Likes
2,041

Dear Abapers,

I need some help in Try/End Try block. My requirement is that I need to check out of 3 FM's which exists in the system and depending on the FM which exists I need to set a particular flag and call that FM.

So can I try some algorithm like this.

TRY

CALL FM1

Catch

TRY CALL FM2

catch CALL FM 3

ENDTRY.

I need to know how to use multiple try...end try blocks...

Please let me know, it would be of great help.

Thanks & Warm Regards, Vinay

4 REPLIES 4
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
970

Hi,

Execute a select query on the table with List of FM's and then based on that call your FM.

You need to se TRY ENDTRY. Just check SY-SUBRC after the select query.

<b><b>DATA: WA_TFDIR TYPE TFDIR.

SELECT * FROM TFDIR INTO WA_TFDIR WHERE FUNCNAME = 'FM NAME1'.</b>

IF Sy-SUBRC = 0.

CALL FM.

ELSE.

SELECT * FROM TFDIR INTO WA_TFDIR WHERE FUNCNAME = 'FM NAME2'.

IF Sy-SUBRC = 0.

CALL FM.

ELSE.

SELECT * FROM TFDIR INTO WA_TFDIR WHERE FUNCNAME = 'FM NAME3'.

IF Sy-SUBRC = 0.

CALL FM.

ENDIF.

ENDIF.

ENDIF.</b>

Regards,

Sesh

Read only

0 Likes
970

just use the following code.....

try

Read only

0 Likes
970

just use the following code

try .

call fm1.

try .

call fm2.

try .

call fm3.

catch .

catch .

catch.

this what ua call nested try catch blocks. try it it will solvw the prob.

Read only

Former Member
0 Likes
970

Hi,

*Syntax for TRY .. ENDTRY construct

TRY.

CALL METHOD o1->m1.

PERFORM f1.

CATCH cx_root. "Handler for all exceptions

" ABAP code(What to do when error occures)........

ENDTRY.

FORM f1 RAISING cx_my.

TRY.

IF ...... RAISE EXCEPTION TYPE cx_my2. ENDIF.

CALL METHOD o1->m3.

CATCH cx_my1 cx_my3 INTO ex.

RAISE EXCEPTION TYPE cx_my4.

CATCH cx_my4.

"Handler for exceptions of type cx_my4

" ABAP code(What to do when error occures)........

CLEANUP.

"Cleanup section, used to restore to a consistant state

" ABAP code........

ENDTRY.

ENDFORM.

Pls do reward points.

Regards,

Ameet