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

internal table manipulation..

former_member185116
Active Participant
0 Likes
1,090

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
Read only

SimoneMilesi
Active Contributor
0 Likes
1,062

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
Read only

SimoneMilesi
Active Contributor
0 Likes
1,063

Hi Vinay

Try this


SORT table BY ptime DESCENDING.

READ TABLE table INTO wa_table INDEX1.

DELETE table WHERE ptime <> wa_table-ptime.

Read only

former_member249399
Active Participant
0 Likes
1,062

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.

Read only

Former Member
0 Likes
1,062

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

Read only

Former Member
0 Likes
1,062

try this

SORT table BY ptime DESCENDING.

DELETE table from 2 .

Read only

former_member185116
Active Participant
0 Likes
1,062

simone,

thanks for u r quick reply...