‎2014 Nov 27 6:51 AM
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
‎2014 Nov 27 7:05 AM
‎2014 Nov 27 7:05 AM
‎2014 Nov 27 7:06 AM
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.
‎2014 Nov 27 7:16 AM
‎2014 Nov 27 8:42 AM
Hi,
Please replace the exception name CX_SY_SYNTAX_ERROR with the one you are getting in the dump.
Regards,
Ashish
‎2014 Nov 27 9:06 AM
Hi Ashish,
the Exception is: SYNTAX_ERROR
I tried this. Bit this does also not work.
Regards
Mario
‎2014 Nov 27 9:26 AM
It is the exception name, there will also be an exception class mentioned...CX_ or CY_ something....use that.
‎2014 Nov 27 7:54 AM
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’.
‎2014 Nov 27 9:07 AM
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
‎2014 Nov 27 9:37 AM
If you "catch" the error correctly in Program 2 then it will.
‎2025 Jan 22 10:48 AM
Hi,
try to use 'cl_abap_typedescr=>describe_by_name( )'
and 'CATCH cx_sy_rtti_syntax_error'.