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

filtering internal table using select-option values

Former Member
0 Likes
4,476

Hi,

I got an internal table with select-option values. for eg. it_perno with the values I BT 000160 000170.

Now i got another second internal table which is have the person number. Now i need to filter this second internal table based on the values from the select option table. my question is

i can collect all the values from 160 to 170 in a separate table by looping over the select option table. and then based on the values filter the second internal table person number.

But what would be the case if the select option contains both intervals and multiple options. For eg.

I BT 000160 000170.

I EQ 000185.

So can you suggest any good solution, that based on this select option table i need to filter the second internal table Person number.

Thanks in advance.

Regards,

anbu.

1 ACCEPTED SOLUTION
Read only

Former Member
2,029

Hi,

Can you not use the select-options in the Select query while populating the internal table.

SELECT pernr FROM pa0000 INTO it_tab WHERE pernr IN s_pernr.

If you cannot do this and you do not want to delete the unwanted entries, then you can use the WHERE clause in the LOOP statement to process the specific entries required:

LOOP AT it_tab INTO wa_tab WHERE pernr IN s_pernr.

Regards,

Aparna Alashe.

2 REPLIES 2
Read only

Former Member
0 Likes
2,029

Hi Anbu,

If you have the SELECT-OPTION table, use it directly in DELETE statement

TABLES SCARR.

SELECT-OPTIONS
     : S_CAR  FOR SCARR-CARRID.

DATA
     : IT_SCARR TYPE TABLE OF SCARR,
       WA_SCARR TYPE SCARR.

SELECT *
FROM SCARR
INTO TABLE IT_SCARR.

DELETE IT_SCARR WHERE CARRID NOT IN S_CAR.

LOOP AT IT_SCARR INTO WA_SCARR.
WRITE / wa_scarr-carrid.
ENDLOOP.

Regards

Read only

Former Member
2,030

Hi,

Can you not use the select-options in the Select query while populating the internal table.

SELECT pernr FROM pa0000 INTO it_tab WHERE pernr IN s_pernr.

If you cannot do this and you do not want to delete the unwanted entries, then you can use the WHERE clause in the LOOP statement to process the specific entries required:

LOOP AT it_tab INTO wa_tab WHERE pernr IN s_pernr.

Regards,

Aparna Alashe.