08-21-2008 5:11 AM
Hello All,
I got a req where i have to get records from a Single table where the where clause changes every time
how can i acheive this with a single hit on the table?
please help.
i.e,
select *
from (Table name)
where (Fieldname) = 1
select *
from (Table name)
where (Fieldname) = 2
08-21-2008 5:14 AM
Hi....
Declare one parameter...!!
Data: p_var like <table-field>.
select ....... where field = p_var.
you can give 1 or 2 or any.... in slection screen.... !
Thanks,
Naveen.I
08-21-2008 5:15 AM
Hi ,
You should use FIELD SYMBOLS in the place of fieldnames.
(Or)
If your intention is to relate several values for same field,
then yu can use SELECT-OPTIONS or RANGES and use
Select-options: s_var for table-field
Select ........... INTO TABLE ITAB FROM XTABLE
WHERE field IN S_VAR.
Bhupal
08-21-2008 5:17 AM
hi.
check this query
select * from mara into CORRESPONDING FIELDS OF table itab where matnr = '000000000000000007' or matnr = '000000000000000060'.
08-21-2008 5:18 AM
Hi,
Please go through the following link, this is covered as part of Dynamic Open SQL,
[http://www.susanto.id.au/papers/DynOpenSQL.asp]
This is even covered in SAP online help,
[http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm]
08-21-2008 5:21 AM
08-21-2008 5:22 AM
Firslty select the relative data from that table based on that field in an internal table now put a read to read your required result from that internal table as shown in example
Pass your whole data in range
Data : R type range .
move your data in a range
select *
from (Table name) into table itab
where (Fieldname) in r
(Tjhis gives you good performance)
Now Read itab based on your requirement
~hitesh