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

Relational operators, help needed

matteo_montalto
Contributor
0 Likes
525

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
493

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

3 REPLIES 3
Read only

Former Member
0 Likes
493

I the field is of type character string then u can specify the conditions as

WHERE field LIKE '00020%'.

кu03B1ятu03B9к

Read only

Former Member
0 Likes
494

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

Read only

Former Member
0 Likes
493

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