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

Techincal Issue

Former Member
0 Likes
388

Hi,

I have got as internal table filled with

DATA: BEGIN OF I_TAB OCCURS 0,

CLASS(05) TYPE C,

BREAK_LEVEL(2) TYPE C,

RAW_DESC(30) TYPE C,

END OF I_TAB.

DATA: BEGIN OF I_TAB1 OCCURS 0,

CLASS(10) TYPE C,

BREAK_LEVEL(2) TYPE C,

RAW_DESC(30) TYPE C,

END OF I_TAB1.

The I_TAB is filled as follows...

113DP DV MANIFOLD AND CHANGEOVER VALVES

113DP DG Proc Conn Flange/Compress Fitt

132PP EA Parts For CompactD/P

132PP CS ACCESSORIES FOR PRESSURE TRAN

132PP EA ACCESSORIES FOR COMPACT D/P

132PP CS Parts For Pressure Transmitt

133DP DV MANIFOLD AND CHANGEOVER VALVES

133DP DG Proc Conn Flange/Compress Fitt

133PP DV Parts For CompactD/P ........

133PP CS ACCESSORIES FOR PRESSURE T

133PK EA ACCESSORIES FOR COMPACT D/P

133PK EA Parts For Pressure Transmitt

I need to modify the Internal table I_TAB in such a way that the if the Class and break level is same then the duplicate should be removed from I_tab and should be placed in the new internal table i_tab1.

Any idea of doing I would really appreciate it.

Thanks and Best Regards,

Mark

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
361

Mark, check out this example.




report zrich_0001.




types: begin of t_tab  ,
       class(05) type c,
       break_level(2) type c,
       raw_desc(30) type c,
       end of t_tab.

data: counter type i.
data: i_tab  type table of t_tab with header line.
data: i_tabx type table of t_tab with header line.
data: i_tab1 type table of t_tab with header line.

* Fill I_TAB with data here.



* Give me a copy of i_tab.
i_tabx[] = i_tab[].

* Get rid of the duplicates.
sort i_tab ascending by class break_level.
delete adjacent duplicates from i_tab comparing class break_level.

* Now check each for duplicates, if found delete from i_tab 
* and add to I_TAB1.
loop at i_tab.

  clear counter.
  loop at i_tabx where class = i_tab-class
                   and break_level = i_tab-break_level.
    counter = counter + 1.
  endloop.

  if counter > 1.
    delete i_tab.    " Delete  the dup
    i_tab1 = i_tab.  " add to i_tab1
    append i_tab1.
  endif.

endloop.



Regards,

Rich Heilman

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
362

Mark, check out this example.




report zrich_0001.




types: begin of t_tab  ,
       class(05) type c,
       break_level(2) type c,
       raw_desc(30) type c,
       end of t_tab.

data: counter type i.
data: i_tab  type table of t_tab with header line.
data: i_tabx type table of t_tab with header line.
data: i_tab1 type table of t_tab with header line.

* Fill I_TAB with data here.



* Give me a copy of i_tab.
i_tabx[] = i_tab[].

* Get rid of the duplicates.
sort i_tab ascending by class break_level.
delete adjacent duplicates from i_tab comparing class break_level.

* Now check each for duplicates, if found delete from i_tab 
* and add to I_TAB1.
loop at i_tab.

  clear counter.
  loop at i_tabx where class = i_tab-class
                   and break_level = i_tab-break_level.
    counter = counter + 1.
  endloop.

  if counter > 1.
    delete i_tab.    " Delete  the dup
    i_tab1 = i_tab.  " add to i_tab1
    append i_tab1.
  endif.

endloop.



Regards,

Rich Heilman

Read only

Former Member
0 Likes
361

Hi Mark,

Pls use the following code :

DATA: BEGIN OF I_TAB OCCURS 0,

CLASS(05) TYPE C,

BREAK_LEVEL(2) TYPE C,

RAW_DESC(30) TYPE C,

END OF I_TAB.

DATA: BEGIN OF I_TAB1 OCCURS 0,

CLASS(10) TYPE C,

BREAK_LEVEL(2) TYPE C,

RAW_DESC(30) TYPE C,

END OF I_TAB1.

data: flag(10) type c "Flag

loop at i_tab.

clear flag.

at new break_level.

flag = 'X'

endat.

if flag <> 'X'

itab1 = itab.

append itab1.

delete i_tab.

endif.

endloop.

Cheers,

Vikram

Pls reward for helpful replies!!