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

Doubt in Select statement

Former Member
0 Likes
596

Hi,

I want to select last record from the standard table. ie i want to select the record from pbhi using bdzei and pdatu. if i used that in where condition its fetching the records but i expect last record from the PBHI table. can any one plz give soln.

Point will be sure.

Gowri

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
568

Hi,

Sort the internal table by bdzei pdatu acsending order and read the valule.

Ex : sort itab descending by <field>.

read table itab <field> index 1.

val = itab-field.

Thanks,

Sriram Ponna.

5 REPLIES 5
Read only

Azeemquadri
Contributor
0 Likes
568

select data in itab.

sort the itab by pdatu descending.

and pick the first record .

Read only

former_member189059
Active Contributor
0 Likes
568

Select into workarea

endselect

append workarea to itab

Read only

Former Member
0 Likes
568

Hi Gowri,

Once you retrived the whole data into an internal table do like this

describe table itab lines gv_lines.

 read table itab into wa index gv_lines.
 if sy-subrc = 0.
  delete itab.
  append wa to itab.
  clear wa.
 endif.

<b>Reward points for helpful answers</b>

Satish

Read only

Former Member
0 Likes
569

Hi,

Sort the internal table by bdzei pdatu acsending order and read the valule.

Ex : sort itab descending by <field>.

read table itab <field> index 1.

val = itab-field.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
568

Do this:

SELECT        * FROM  pbhi
  UP TO 1 ROWS
  ORDER BY bdzei DESCENDING
           pdatu  DESCENDING.

ENDSELECT.

Rob