‎2007 Aug 03 10:30 AM
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
‎2007 Aug 03 10:34 AM
From other post, answer from Rich Heilman
LOOP AT itab INTO wa WHERE kschl LIKE 'J%'. "or *, I cannot remember :P
EXIT.
ENDLOOP.
‎2007 Aug 03 10:35 AM
better to use where condition of loop statement.
loop at it where kschl like 'j%'.
.............
exit.
endloop.
don't forget to reward
Sameer
‎2007 Aug 03 10:35 AM
Hi Sonali,
Change your code like,
read table itab into wa with key itab-kschl = 'J%'.
Thanks.
‎2007 Aug 03 10:36 AM
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
‎2007 Aug 03 10:50 AM
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.
‎2007 Aug 03 10:45 AM
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.