Application Development 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: 

internal table

Former Member
0 Kudos

Hi Experts,

How to check whether an internal table's (it1) field val contains value 'a'.

without looping how can i do this?

Points will be rewarded.

Regards,

Soumya.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

If you dont want to use Loop statement then you can use READ TABLE Statement.

Ashvender

5 REPLIES 5

Former Member
0 Kudos

u can't

Former Member
0 Kudos

Use FIND statement : check below code


DATA:  BEGIN OF itab OCCURS 0,
         f1(10) TYPE c,
         f2(10) TYPE c,
       END OF itab.

itab-f1 = '3'.
itab-f2 = 'S'.
APPEND itab.

itab-f1 = '2'.
itab-f2 = 'T'.
APPEND itab.

itab-f1 = '4'.
itab-f2 = 'S'.
APPEND itab.

itab-f1 = '4'.
itab-f2 = 'P'.
APPEND itab.

itab-f1 = '2'.
itab-f2 = 'S'.
APPEND itab.

FIND FIRST OCCURRENCE OF 'P' IN TABLE itab IN CHARACTER MODE.
IF sy-subrc EQ 0.
  MESSAGE 'Yes' TYPE 'I'.
ENDIF.

Reward if useful

Regards

Pradeep

Former Member
0 Kudos

You can use READ TABLE.

DATA: BEGIN OF TEST OCCURS 3,

VALUE TYPE C,

END OF TEST.

APPEND 'a' TO TEST.

APPEND 'b' TO TEST.

APPEND 'c' TO TEST.

READ TABLE TEST WITH KEY VALUE = 'a'.

Former Member
0 Kudos

Hi

Use Read statement if u dont want to use loop.

Write like this

Data: Begin of itab occurs 0,

it1(10) type c,

End of itab,

sno type i value 1.

itab-it1 = 'abcd'.

append itab.

itab-it1 = 'bcd'.

append itab.

itab-it1 = 'bcd'.

append itab.

itab-it1 = 'bacd'.

append itab.

loop at itab.

endloop.

sort itab by it1.

do sy-tfill times.

read table itab index sno.

if itab-it1 ca 'a'.

write:/ 'Found'.

else.

write:/ 'Not Found'.

endif.

sno = sno + 1.

enddo.

Regards

Haritha.

Former Member
0 Kudos

Hi,

If you dont want to use Loop statement then you can use READ TABLE Statement.

Ashvender