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

Simple loop question

Former Member
0 Likes
498

I have an internal table called table1 with data as below:

col1

-


123

234

456

I would like to write a an one line condition check like this: (i.e. replace words between brackets with code)

IF (table1 has col1 with the data '234').

" do this code

ENDIF.

I'm not sure which function to use to do this. Do I have to first read the data then check the result count or can I just put it on one line like this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
482

use



read table table1 with key col1 = 'xxxx'.
if sy-subrc = 0.

endif.

3 REPLIES 3
Read only

Former Member
0 Likes
483

use



read table table1 with key col1 = 'xxxx'.
if sy-subrc = 0.

endif.

Read only

0 Likes
482

ok, so it looks like I do need two lines. Thanks for your help.

Read only

Former Member
0 Likes
482
Loop at itb1.
If itab1-col1 = '234'.
Do this.
else.
Do this.
endif.
Endloop.