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: 

Filtering the data in internal table

Former Member
0 Kudos

Hi,

I facing one problem. The issue is that i have to filter the data in an internal table. The sample is as shown:

AUFNR MATNR SER_NAME

sv1 mat1 ser_name1

sv1 mat2 ser_name2

sv1 mat3 ser_name3

sv2 mat21 ser_name21

sv2 mat21 ser_name22

sv2 mat22 ser_name23

As depited, the record, SV2 has the same matnr( mat21 ). The result should be

AUFNR MATNR SER_NAME

sv1 mat1 ser_name1

sv1 mat2 ser_name2

sv1 mat3 ser_name3

sv2 mat21 ser_name21, ser_name22

sv2 mat22 ser_name23

The ser_name for 'mat21' should be concatenated and the other record should be deleted or I can prepare another table

for storing the result set(this i want to avoid .. )

Kindly suggest..

If the scenario is not clear kindly let me know...:)

Regards

s.a.k

1 ACCEPTED SOLUTION

nikhil_chitre
Active Participant
0 Kudos

hello

try using the syntax:

DELETE ADJACENT DUPLICATES FROM (internal table) COMPARING ( field1, field2)

Regards,

Nikhil

4 REPLIES 4

Former Member
0 Kudos

Hi,

You can do the processing within the same internal table itself. Try like this,


data: v_ind type i.
data: wa like itab.

loop at itab.
v_ind = sy-tabix + 1.
read table itab into wa index v_ind.
if itab-matnr = wa-matnr.
delete itab where aufnr = wa-aufnr matnr = wa-matnr ser_name = wa-ser_name.
concatenate itab-ser_name wa-ser_name into itab-ser_name.
modify itab.
clear wa.
endif.
endloop.

Regards,

Vikranth

Edited by: Vikranth.Reddy on Sep 29, 2009 5:33 PM Edited the read statement

0 Kudos

Hi Vikranth,

Thank you very much..:) it was really helpful..

And also thanks to my other friends as well...:)

Regards

s.a.k

Former Member
0 Kudos

first sort the itab properly by sernr and material.

loop at itab into is1.
 index = sy-index + 1.
 at last. " this is needed to remove the dump at the last line read
  exit.
 endat. 
 read table itab into is2 index index.
 if sy-subrc = 0.
   if is1-matnr = is2-matnr and is1-sernr = is2 sernr.
     concatenate is1-sur_name is2-sur_name into is1-surname,
   endif.
   modify itab from is1.
   delete itab index index.
 endif
 endloop.

nikhil_chitre
Active Participant
0 Kudos

hello

try using the syntax:

DELETE ADJACENT DUPLICATES FROM (internal table) COMPARING ( field1, field2)

Regards,

Nikhil