Application Development 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: 

internal table manipulation..

former_member185116
Active Participant
0 Kudos
92

hell all,

in have an internal table consisting of 4 records ..

the internal table has field called PTIME,

now my question is i need to get the record whose PTIME is highest and delete remaining records,

how do i achieve this,...

1 ACCEPTED SOLUTION

SimoneMilesi
Active Contributor
0 Kudos
64

Hi Vinay

Try this


SORT table BY ptime DESCENDING.

READ TABLE table INTO wa_table INDEX1.

DELETE table WHERE ptime <> wa_table-ptime.

5 REPLIES 5

SimoneMilesi
Active Contributor
0 Kudos
65

Hi Vinay

Try this


SORT table BY ptime DESCENDING.

READ TABLE table INTO wa_table INDEX1.

DELETE table WHERE ptime <> wa_table-ptime.

former_member249399
Active Participant
0 Kudos
64

Hi,

sort your internal table  with PTIME descending,

read table itab1 index 1.   "itab1 : internal table

get data into structur / variable. store data into new table.

You can delete table.

Former Member
0 Kudos
64

declare two workareas wa1 and wa2 of the same type Internal table (PTIME)

loop at itab into wa1.

read table itab into wa2 with index sy-index + 1.

if wa2-PTIME > wa1-PTIME.

PTIME_HIGHEST = wa2-PTIME.

endif.

endloop.

This will give highest PTIME value.

DELETE from itab where PTIME <> PTIME_HIGHEST.

Do hope it helps.

Reward points if helpful

Former Member
0 Kudos
64

try this

SORT table BY ptime DESCENDING.

DELETE table from 2 .

former_member185116
Active Participant
0 Kudos
64

simone,

thanks for u r quick reply...