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

Check for entry in internal table

Former Member
0 Likes
1,041

I have made an internal table. I would like to check a specific field in this table if it has a specific input.

How shall I do the checking using abap commants?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
961
LOOP AT ITAB WHERE ITAB-FIELD = 'ABCD'.
             FLAG = 'X'.
           ENDLOOP.
           IF FLAG = 'X'
            FOUND.
           ELSE.
            NOT FOUND.
           ENDIF.

I have made an internal table. I would like to check a specific field in this table if it has a specific input.

How shall I do the checking using abap commants?

6 REPLIES 6
Read only

GauthamV
Active Contributor
0 Likes
961

Something like this.



LOOP AT gt_itab into gtt_wa.

If gtt_wa-lvorm Eq 'X'.

gtt_outtab-status = 'Released'.

endif.

ENDLOOP.

Read only

Former Member
0 Likes
961

>

> LOOP AT gt_itab into gtt_wa.

> If gtt_wa-lvorm Eq 'X'.

> gtt_outtab-status = 'Released'.

> endif.

> ENDLOOP.

>

{quote}

Looping at gt_itab and altering the values of gtt_outtab without having any read/modify statements for gtt_outtab?

The correct snippet should look like:

LOOP AT gt_itab into gtt_wa.

If gtt_wa-lvorm Eq 'X'.

gtt_wa-status = 'Released'.

modify gt_itab from gt_wa.

endif.

ENDLOOP.



or 

LOOP AT gt_itab into gtt_wa.

If gtt_wa-lvorm Eq 'X'.

read table gtt_outtab into gtt_wa with key XYZ = gt_itab-XYZ binary search."sort gtt_outtab by XYZ

gtt_outtab-status = 'Released'.

modify gtt_outtab index sy-tabix.

endif.

ENDLOOP.

Cheers

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
961

Good one buddy

Read only

Former Member
0 Likes
961

Hi

READ TABLE ITBA WITH KEY CARRID = 'AA'.
IF sy-subrc = 0.
" Means the Value you are looking for is there
else.
Message 'No Value found' "Etc any message or it means Not found
endif.

Cheerz

Ram

Read only

0 Likes
961

how shall I give the "key" to my field?

Read only

Former Member
0 Likes
962
LOOP AT ITAB WHERE ITAB-FIELD = 'ABCD'.
             FLAG = 'X'.
           ENDLOOP.
           IF FLAG = 'X'
            FOUND.
           ELSE.
            NOT FOUND.
           ENDIF.