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

ABAP INSERT and SUBMIT REPORT --> Catch SYNTAX_ERROR

Former Member
0 Likes
2,844

Hi everybody,

I wrote an ABAP to create dynamically another ABAP and SUBMIT it.

When the is an SYNTAX_ERROR I would like to catch this exception.

Does anybody know how to catch an SYNTAX_ERROR exception to avoid the short dump?

Thanks, Regards

Mario

1 ACCEPTED SOLUTION
Read only

Nawazuddin
Explorer
0 Likes
2,426

This message was moderated.

10 REPLIES 10
Read only

Nawazuddin
Explorer
0 Likes
2,427

This message was moderated.

Read only

Former Member
0 Likes
2,426

Hi,

Keep the submit statement in try endtry block. The exception to catch is : CX_SY_SYNTAX_ERROR

TRY.

SUBMIT program.

CATCH CX_SY_SYNTAX_ERROR.

MESSAGE 'syntax error' TYPE 'E'.

ENDTRY.

Read only

0 Likes
2,426


Hi Bronze

I tried your coding. But it does not work.

Regards

Mario

Read only

0 Likes
2,425

Hi,

Please replace the exception name CX_SY_SYNTAX_ERROR with the one you are getting in the dump.

Regards,

Ashish

Read only

0 Likes
2,425

Hi Ashish,

the Exception is:  SYNTAX_ERROR

I tried this. Bit this does also not work.

Regards

Mario

Read only

0 Likes
2,425

It is the exception name, there will also be an exception class mentioned...CX_ or CY_ something....use that.

Read only

former_member201275
Active Contributor
0 Likes
2,425

I think there is no catchable exceptions for the SUBMIT statement so you are going to have to instead do something with sy-subrc instead. For example:

REPORT ZPROGRAM1

data: rc type sy-subrc.

SUBMIT ZPROGRAM2 and return.

import rc from memory-id Z_PROG2.

if rc is not initial.

·      *  error handling here

else.

* normal processing

endif.

now:

REPORT ZPROGRAM2.

data: rc type sy-subrc.

do all your program stuff here

catch errors and move value to rc, or, rc = sy-subrc.

EXPORT rc to memory id ‘Z_PROG2’.

Read only

0 Likes
2,425

Hi Glen,

this will not work

When

SUBMIT ZPROGRAM2 and return.  --> Throws an error.

Than the line

          import rc from memory-id Z_PROG2.

will not be processed.

Thx, Mario

Read only

0 Likes
2,425

If you "catch" the error correctly in Program 2 then it will.

Read only

C5269009
Associate
Associate
0 Likes
2,098

Hi,
try to use 'cl_abap_typedescr=>describe_by_name( )'
and 'CATCH cx_sy_rtti_syntax_error'.