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

internal table

Former Member
0 Likes
580

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
Read only

Former Member
0 Likes
555

Hi,

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

Ashvender

5 REPLIES 5
Read only

Former Member
0 Likes
555

u can't

Read only

Former Member
0 Likes
555

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

Read only

Former Member
0 Likes
555

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'.

Read only

Former Member
0 Likes
555

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.

Read only

Former Member
0 Likes
556

Hi,

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

Ashvender