‎2008 Aug 30 5:04 AM
Hi friends,
Iam getting a list of fields into internal table.
I have to fetch records from database using those fields, in where condition. How to put all those fields in where condition
from that internal table.
Performance wise we must not put that select statement in loop, then whats the solution.
Thankyou,
Ramesh.
‎2008 Aug 30 5:18 AM
Hi Ramesh,
You can use FOR ALL ENTRIES.
Declare another internal table with the fields you want to select from database table, eg:, itab2.
Then select the fields from the database table say, dbtab, using for all entries from the first internal table eg: itab1.
Select field1,
field2,
--
fieldn
from <dbtab>
into table <itab2>
for all entries in <itab1>
where field1 = itab1-field1
field2 = itab1-field2
--
fieldn = itab1-fieldn.Hope this helps you.
Any queries, get back to me.
Regards,
Chandra Sekhar
‎2008 Aug 30 5:18 AM
Hi Ramesh,
You can use FOR ALL ENTRIES.
Declare another internal table with the fields you want to select from database table, eg:, itab2.
Then select the fields from the database table say, dbtab, using for all entries from the first internal table eg: itab1.
Select field1,
field2,
--
fieldn
from <dbtab>
into table <itab2>
for all entries in <itab1>
where field1 = itab1-field1
field2 = itab1-field2
--
fieldn = itab1-fieldn.Hope this helps you.
Any queries, get back to me.
Regards,
Chandra Sekhar
‎2008 Aug 30 5:20 AM
Hi pagidala Ramesh,
Get the all data from database into internal table.
Now loop the first internal table and read the second internal table by checking those fields. and populated the records in another table.
or delete the records if the condition is not met in the second internal table.
Fetching the data once from database is better then hitting the database several times.
Best regards,
raam
‎2008 Aug 30 5:21 AM
Hi,
Use FOR ALL ENTRIES in this kind of scenario.
Use this type of select query
SELECT carrid
connid
fldate
FROM sflight
INTO TABLE t_flight
FOR ALL ENTRIES IN t_spfli
WHERE carrid = t_spfli-carrid
AND connid = t_spfli-connid.
Regards
Abhijeet