Select statement

Question:
Hi,
I'm accessing one of the HR table. I have to take to second last record when condition meet in WHERE clause.
Can u guys let me know what the best way to code my requirement?
Pls Help.
Answer:
Hi !!
Select * from <table> into <itab> where .......
Sort <itab> by <key> descending.
Read <itab> index 2.
Regards,
Sudhir/Mohit
Answer:
Thanks 2Abapers
Answer:
Hi !!
Select * from <table> into <itab> where .......
Sort <itab> by <key> descending.
Read <itab> index 2.
Regards,
Sudhir/Mohit
Just a thought, and to rekindle the argument between select single and select .... up to.....
I have always argued that 'SELECT SINGLE' is different from 'SELECT ... UP TO 1 ROWS', in that select single returns the first record it comes across where as UP TO performs all the required processing and then returns the specified number of records from the result set, so how about this (and I haven't checked the syntax....)
Select ...
  into table t_table
  from tab
  up to 2 rows
  where .... condition
  ordered by sort-key descending.
Read t_table index 1.....     
Now... if Select Single and Select Up To 1 rows are identical, I'm pretty certain this wouldn't give you what you want....
Any comments ??
R
Answer:
Hi R !!
Your code does work and provides the reqd. ouput, by changing
Read t_table index 1.....     
to
Read t_table index 2.....     
But we guess thats just a typin mistake ....
Regards,
Sudhir/Mohit
[/code]

More Articles:

How to add search help in Report selection-screen?
ABAP & Java?
Maintenance View problem?
PP Enhance PPCO0012?
Search through multiple includes?
Opening 2 fields for input with AT SELECTION-SCREEN ON.?