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: 

Eliminate the values from internal table

Former Member
0 Kudos

I have an internal table with fields..

begin of it occurs 0,

ebeln

matkl

werks

end of it.

its filled with values..

ebeln | matkl | werks |

12111 | A123 | LK

12111 | A123 | LK

12111 | A123 | LK

12111 | A123 | LK

12111 | A123 | LK

12111 | A123 | LN

12121 | A124 | LK

12121 | A124 | LK

12121 | A124 | LK

12122 | A125 | LK

12122 | A125 | LK

12122 | A125 | LK

12123 | A126 | LN

12123 | A126 | LN

Now I want to eliminate the values from the internal table where all ebeln and werks are different..for example..all 12111's should be eliminated from the internal table as the it has different werks assighned to one of the ebeln's..and I need only ebeln's with 12121 and 12123.

Any suggention would be helpful..

Thanks,

M/

5 REPLIES 5

Former Member
0 Kudos

Hi ,

Take a copy of your internal say IT1 .


IT1[] = IT[].

Loop at it .

loop at it1 with key ebeln = it_ebeln and werks <> it_werks.

flag = 'X'.
EXIT.

ENDloop.

if flag = ' X' .
clear .
delete table it where ebeln = it_ebeln .
ENDIF.

Endloop.

In this way your problem is solved

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Mar 4, 2008 11:03 AM

Former Member
0 Kudos

If I am correct in understanding,, you are trying to eliminate all the EBELN with werks = LN.

All the ebelns should be assigned to werks LK

Please confirm..

0 Kudos

Rahul,

I want to eliminate all EBLELN'S if all WERKS are not same..

0 Kudos

Write as :

sort it by ebeln werks.

Loop at it.

At new ebeln.

v_werks = it-werks. <--- get the first werks ...

endat.

if v_werks <> it-werks.

flag = 'X'.

endif.

at end of ebeln.

if flag = 'X'.

  • delete internal table it where ebeln = it-ebeln.

endif.

clear : flag , v_werks.

endat.

endloop.

Former Member
0 Kudos

Hi,

DATA : v_ebeln LIKE table name-ebeln,

v_werks LIKE table name--werks.

SORT itab BY ebeln werks .

LOOP AT ITAB.

ON CHANGE OF itab-ebeln.

Move : itab-ebeln TO v_ebeln,

itab-werks TO v_werks.

ENDON.

IF ITAB-ebeln NE v_ebeln OR

ITAB-werks NE v_werks.

DELETE ITAB WHERE ebeln EQ ITAB-ebeln .

clear : v_ebeln , v_werks.

ENDIF.

ENDLOOP.