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

Query

Former Member
0 Likes
909

Dear gurus,

I have a table like this

id counter text

001 001 AAA

001 002 BBB

002 001 AAA

002 002 BBB

002 003 CCC

I want to have a o/p like this

001 002 BBB

002 003 CCC

it it should fetch the latest counter of the id text

please help me out regards this query

thank in advance

Senthil

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
885
sort itab by id counter descending.

loop at itab.
 at new itab.
 read table itab index sy-tabix.
 move-corresponding itab to itab1.  " Declare itab1 same as itab
 append itab1.
endat.
endloop.
8 REPLIES 8
Read only

Former Member
0 Likes
885

hi

use <b>delete duplicate</b>.

regards,

pankaj singh

Read only

Former Member
0 Likes
885

Hi Senthil,

You can do two ways.

One is

AT END OF id
ENDAT.

Other is


Sort itab by text decending.
delete adjacent duplicates itab comparing id.

Regards

Bhupal Reddy

Read only

Former Member
0 Likes
885

hi..

u must use the following command in order to delete the repeated values:

<b> delete adjacent duplicates</b>.

try out this command in ur code..

all the best

Read only

Former Member
0 Likes
885

sort itab by id.

itab1[] = itab[].

delete adjacent duplicates from itab comparing id.

loop at itab.

loop at itab1 into itab3 whre id = itab-id.

append itab3.

endloop.

sort itab3 by id descending.

move itab3 to out.

append out.

refresh: itab3.

endloop.

Read only

Former Member
0 Likes
885

sort itab by id.

itab1[] = itab[].

delete adjacent duplicates from itab comparing id.

loop at itab.

loop at itab1 into itab3 whre id = itab-id.

append itab3.

endloop.

sort itab3 by id descending.

read table itab3 index 1.

move itab3 to out.

append out.

refresh: itab3.

endloop.

Read only

Former Member
0 Likes
885

Hi Senthil ,

The code woule be like this


Data : wa_1 like line of it_1.
sort it_1 by id counter descending .
Loop at it_1.
wa_1 = it_1.    " Please dont forget to do this
at new id
 write: / it_1-id  , wa_1-counter  , WA_1-TEXT.
endat.


ENDLOOP

Regards

Arun

Message was edited by:

Arun Ramachandran

Read only

Former Member
0 Likes
886
sort itab by id counter descending.

loop at itab.
 at new itab.
 read table itab index sy-tabix.
 move-corresponding itab to itab1.  " Declare itab1 same as itab
 append itab1.
endat.
endloop.
Read only

0 Likes
885

thanx for all u r replies

senthil