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: 

exceptions handling for "submit of Insert Report "

Former Member
0 Kudos
190

Dear Experts,

i need to handle Exception "syntax Error" when Submit the inserted report.

i tried " try and Catch " but failed to catch Dump Error.

for example:

Data CODE TYPE TABLE OF String .

APPEND 'REPORT ZDYN.' TO Code .

APPEND 'Data Var1 type I .' TO Code .

append 'if var > 10 ' to Code .

append 'Write ''Success'' . ' to Code .

append 'else. ' to Code .

append 'Write ''Failed'' . ' to Code .

append 'EndIf . ' to Code .

TRY .

data Prog TYPE c LENGTH 50 VALUE 'ZDYN'.

INSERT REPORT Prog FROM CODE .

SUBMIT Prog AND RETURN .

CATCH CX_ROOT .

raise SYNTAX_ERROR .

ENDTRY.

" in the inserted Report the Variable Name is Var1 NOT Var So it will be Syntax error " DUMP Error ".

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos
77

Dear Srini,

first I would like to thank you for your answer.

about the Issue,

the Condition (If Condition" Var > 10 " ) is Dynamic form Data base table not static.

so it maybe has syntax error I need to handle the exception.

I Used Insert Report " Dynamic Programing " to solve the problem of Dynamic if Condition. and am tried the "" GENERATE SUBROUTINE POOL "" but it we can't generate more than 36 SUBROUTINE POOL in the same program but I need to generate More that But it's ""Sy-subec = 4"" if the Code has Syntax Error .

Then i used Insert Report "" Not Limited " but i Can't handle Syntax Exception.

4 REPLIES 4

Former Member
0 Kudos
77

Hi,

First write the code in a program and check what error you get and try to handle that particular error.

Also a full stop is missing in the code ...

REPORT ZDYN.

Data Var1 type I.

if var > 10 .

.

.

.

.

Data CODE TYPE TABLE OF String .

APPEND 'REPORT ZDYN.' TO Code .

APPEND 'Data Var1 type I .' TO Code .

append 'if var > 10 .' to Code . <-- Put a full stop here ..

append 'Write ''Success'' . ' to Code .

append 'else. ' to Code .

append 'Write ''Failed'' . ' to Code .

append 'EndIf . ' to Code .

.

.

.

.

Regards,

Srini.

Former Member
0 Kudos
78

Dear Srini,

first I would like to thank you for your answer.

about the Issue,

the Condition (If Condition" Var > 10 " ) is Dynamic form Data base table not static.

so it maybe has syntax error I need to handle the exception.

I Used Insert Report " Dynamic Programing " to solve the problem of Dynamic if Condition. and am tried the "" GENERATE SUBROUTINE POOL "" but it we can't generate more than 36 SUBROUTINE POOL in the same program but I need to generate More that But it's ""Sy-subec = 4"" if the Code has Syntax Error .

Then i used Insert Report "" Not Limited " but i Can't handle Syntax Exception.

0 Kudos
77

There is a not so well known ABAP statement SYNTAX-CHECK for this purpose, please read the respective F1 help.

Also be aware that what you are building there can be a huge security risk. What if the database contains e.g. 'DELETE FROM BSEG WHERE BUKRS IS NOT INITIAL' and you generate and run a program from it?

Thomas

0 Kudos
77

Dear Thomas,

Thank you very Much. that was helpful for me Thank You again .