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

Select statement

Former Member
0 Likes
1,026

Hi all,

I have a condition where I need to select all the record from it_tab that meet all the below conditions:

mode = X or Y

matnr = 123 or 234

can you just tell me how to execute this condition.

Thanks

Rajeev Gupta

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,000

HI,

Select * from <table> into itab where mode in ( 'X','Y' )

and matnr in ('123','234').

Thanks

Mahesh

5 REPLIES 5
Read only

Former Member
0 Likes
1,001

HI,

Select * from <table> into itab where mode in ( 'X','Y' )

and matnr in ('123','234').

Thanks

Mahesh

Read only

0 Likes
1,000

Thanks Mahesh

Do I need to first read that table from which i need to select records or I can diresctly select the records.

Thanks

Rajeev Gupta

Read only

0 Likes
1,000

If you want to query a database table based on some criteria i.e. mode in X or Y Matnr in 123 or 234, first you should know whether these can be hardocded or do you have them in an internal table or variables. In your example you have given they are hardcoded therefore mode and matnr values are hardcoded in the query.

If you want them to be dynamic create some internal table or range where in you have the values available and use that internal table in your selection criteria.

Select * from MARA for all entries in itab where MATNR = itab-matnr.

or create a range and use it

Select * from MARA MATNR in matnr_range.

-Kriss

Read only

0 Likes
1,000

Hey rajeev,

What is ur requirment do you want to select the records from a data base table or you already have a internal table with data and out of that you want to select the records with this condition

1) if from db table .

select * from table into itab where mode in ('x','y') and matnr in ('123','234')

2) from internal table

loop at itab where mode in ('x','y') and matnr in ('123' ,'234').

jtab = itab.

append jtab.

endloop.

after this jtab will contain all the required entries.

or

jtab[] = itab[].

delete jtab where not in ('x','y') and matnr not in ('123',234')

Thanks

Mahesh

Read only

Former Member
0 Likes
1,000

Hi Rajeev,

Use the below select statement before the loop:

Select * from (respective table) into it_itab where mode in ( 'X','Y' )

and matnr in ('123','234').

If you want to display the data, then simple use the write statement within a loop.

Hope this helps.

Please reward if useful.

Thanks,

Srinivasa