‎2007 Aug 15 4:37 PM
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
‎2007 Aug 15 4:41 PM
HI,
Select * from <table> into itab where mode in ( 'X','Y' )
and matnr in ('123','234').
Thanks
Mahesh
‎2007 Aug 15 4:41 PM
HI,
Select * from <table> into itab where mode in ( 'X','Y' )
and matnr in ('123','234').
Thanks
Mahesh
‎2007 Aug 15 4:43 PM
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
‎2007 Aug 15 4:50 PM
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
‎2007 Aug 15 5:03 PM
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
‎2007 Aug 15 4:51 PM
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