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

read table

Former Member
0 Likes
730

Hi,

I want to write a read stmt to select the row from itab where condition type (kschl) starts with 'J....'

And my loop at table doesnt have this field so i cant specify where clause there.

Read table itab into wa with key kschl = 'all condition types starting with J'

I tried writing

read table itab into wa with key kschl = 'J%'.

it didnt work.

Pls help me.

Message was edited by:

sonali shahasane

6 REPLIES 6
Read only

VXLozano
Active Contributor
0 Likes
694

From other post, answer from Rich Heilman

LOOP AT itab INTO wa WHERE kschl LIKE 'J%'. "or *, I cannot remember :P
  EXIT.
ENDLOOP.

Read only

Former Member
0 Likes
694

better to use where condition of loop statement.

loop at it where kschl like 'j%'.

.............

exit.

endloop.

don't forget to reward

Sameer

Read only

Former Member
0 Likes
694

Hi Sonali,

Change your code like,

read table itab into wa with key itab-kschl = 'J%'.

Thanks.

Read only

Former Member
0 Likes
694

Hi,

U can't read multiple records from the internal table using READ TABLE statement. In this case u can use loop at..where.

LOOP AT ITAB INTO WA WHERE KSCHL EQ 'J%'.

......

ENDLOOP.

Regards,

Sankar

Read only

0 Likes
694

hi Sanker,

thanks for ur reply,

but the problem is my loop at table doesnt have this field. Field is only in my read itab.

Read only

Former Member
0 Likes
694

hi sonali,

read statement requires that the comparison operator to be used must be "=" and for the value, it compares the entire string specified (in your case it will try to fetch if J% is actually present.

so, instead of trying to read a value, do select into a temporary internal table where kschl = all conditions starting with j.

like this...

DATA: TEMP(4) VALUE 'J%'.

SELECT * FROM KONP

INTO CORRESPONDING FIELDS OF TABLE IT_KONP

WHERE KSCHL LIKE TEMP.

and then do a read for whatever condition type is required.

reward points if it helps.