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

error message in the loop statement

Former Member
0 Likes
5,756

Hi Experts:

In my ABAP program,

In the loop of internal table,when match some condition,the system give error message, or go on.

Now,if the internal table has ten records, three records match some condition,the others need

process going on.

But in my program,if finds error record,giving error message,can't process other records.

I want it can not only show error message,but also process other records.

Pls give me some advice,tks!

1 ACCEPTED SOLUTION
Read only

bbalci
Contributor
0 Likes
2,774

Hello Stephen

As Thien said message with type E terminates your program,

You can use DISPLAY LIKE addition on your message command like this :

>MESSAGE ID '00' TYPE 'S' NUMBER '398' DISPLAY LIKE 'E'.

By this way your message will be displayed as en error in RED color

but will not terminate your program.

Or you can use an application log to display messages for loop steps

by using functions BAL_LOG_CREATE , BAL_LOG_MSG_ADD , BAL_DSP_LOG_DISPLAY.

I hope it helps.

6 REPLIES 6
Read only

Former Member
0 Likes
2,774

Hi Stephen,

Did you give message type 'E' for displaying error? if yes, it can terminate your program at that line.

So, create a variable like flag to check error:


Loop at itab.

if found_error.
flag = 'X'
continue.
endif.
endloop.

* at exit loop
if flag = 'X'.
message to user.
endif.

hope it helps,

regards

Read only

bbalci
Contributor
0 Likes
2,775

Hello Stephen

As Thien said message with type E terminates your program,

You can use DISPLAY LIKE addition on your message command like this :

>MESSAGE ID '00' TYPE 'S' NUMBER '398' DISPLAY LIKE 'E'.

By this way your message will be displayed as en error in RED color

but will not terminate your program.

Or you can use an application log to display messages for loop steps

by using functions BAL_LOG_CREATE , BAL_LOG_MSG_ADD , BAL_DSP_LOG_DISPLAY.

I hope it helps.

Read only

Former Member
0 Likes
2,774

Hello Bulent:

'Diaplay Like' addtion on the message command can't work in R/3,but it works fine in IDES ECC6.0.

because of the systerm version,the message statement has difference in ABAP?

Thanks for your replay.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,774

Which version of SAP are you using ?

Read only

0 Likes
2,774

Hi Stephen,

Press F1 button on MESSAGE command in your editor and display help for this command

if you don't see addition the DISPLAY LIKE in help window as an option

it means that your version doesn't support.

You'r welcome .

Read only

Former Member
0 Likes
2,774

Hi,

Message type E is error type and it will terminate your program.

So either we can declare the message type E as information message or status or we can add a varaible flag which can be set on error.

So that it would not terminate the program.

Example :

Loop at inttable1.
 
if condition for error

flag = 'X'.

continue.

endif.

endloop.

Outside the loop.

if flag = 'X'.

message in other internal table with details.

endif

.

Hope this helps.

Thanks,