2009 Jan 26 2:35 PM
Hi all,
I've got a simple task to ask for... I have to search in an itab for a particular (unique) work area that I can identify comparing some fields to my wanted values.
There's just one check I'm not able to code down, here it is:
the table has a field called EXT_DEM_POSID and I have a workarea in which this field has value '00020000000010'.
I need to find in my itab the entry that has the EXT_DEM_POSID field value equal to the first 5 digits of my workarea (in this case, '00020'). How can I simply formulate such a check in a WHERE statement?
Something like
LOOP AT itab INTO wa_wanted
WHERE .... AND EXT_DEM_POSID EQ first 5 digits of wa_item.
Another question: is there a way I can use directly a READ TABLE statement to do such a thing? Or must I loop the entire table since the condition is not just an equality one?
Thanks in advance
2009 Jan 26 2:43 PM
Hi
U can use both statament:
- LOOP/ENDLOOP
LOOP AT ITAB INTO WA_WANTED WHERE EXT_DEM_POSID EQ = WA_ITEM(5).
EXIT.
ENDLOOP.- READ TABLE
READ TABLE INTO WA_WANTED WITH KEY EXT_DEM_POSID EQ = WA_ITEM(5).Max
2009 Jan 26 2:41 PM
I the field is of type character string then u can specify the conditions as
WHERE field LIKE '00020%'.
кu03B1ятu03B9к
2009 Jan 26 2:43 PM
Hi
U can use both statament:
- LOOP/ENDLOOP
LOOP AT ITAB INTO WA_WANTED WHERE EXT_DEM_POSID EQ = WA_ITEM(5).
EXIT.
ENDLOOP.- READ TABLE
READ TABLE INTO WA_WANTED WITH KEY EXT_DEM_POSID EQ = WA_ITEM(5).Max
2009 Jan 26 2:43 PM
Try this
data lv_ext_dem_posid like itab -EXT_DEM_POSID.
lv_ext_dem_posid = wa_item+0(5) " first 5 characters of wa_item
LOOP AT itab INTO wa_wanted
WHERE .... AND EXT_DEM_POSID EQ lv_ext_dem_posid.
regards,
Advait