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: 

internal table

Former Member
0 Kudos

Hi all,

in my internal table i don't want fields to be repeated with same material number. i.e. if a particular material number is there in table, it shouldn't get the same material number againg. how shall i do that.

kindly help me.

regards,

karthi.

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

hi,

SORT itab BY matnr ...

DELETE ADJACENT DUPLICATES itab COMPARING matnr.

ec

9 REPLIES 9

Former Member
0 Kudos

In your select query use Syntax Select Distinct MATNR....

Regards,

Satish

Former Member
0 Kudos

Hi Subramanaian,

Use APPEND in ur code.

Thankyou,

Regards.

JozsefSzikszai
Active Contributor
0 Kudos

hi,

SORT itab BY matnr ...

DELETE ADJACENT DUPLICATES itab COMPARING matnr.

ec

Former Member
0 Kudos

Hi,

Data: check type matnr.

Loop at itab.

if itab-matnr = check.

delete itab.

endif.

check = itab-matnr.

endloop.

Former Member
0 Kudos

Hi,

If you want unique material number in internal table

USe DELETE ADJACENT DUPLICATE statement .

If you are fetching Ztable data with internal table and u want unique material data then use FOR ALL ENTERIES

Select ....

From Ztable

FOR ALL ENTRIES IN itab

where matnr = itab-matnr.

FOR ALL ENTRIES will avoid duplicate values.

0 Kudos

Oh my goodness.... this can´t be serious!

"Loop at itab.

if itab-matnr = check.

delete itab.

endif.

check = itab-matnr.

endloop."

Use the DELETE ADJACENT statement but keep in mind that you MUST sort the table by material number first.

Former Member
0 Kudos

Hi Karthi,

Define your internal table as sorted internal table with unique key as MATNR. This will make sure your internal table will allow first entry to be appended - others will return non-zero sy-subrc..

Regards,

Mohaiyuddin

Former Member
0 Kudos

Hi,

You can use the key word distinct as mentioned in the above post or you can also

sort the table after selecting all the contents of the internal table using that material number

field then you can delete the adjacent entries in the table which will eliminate the duplicates

ex:-

SORT it_work BY arbpl.

DELETE ADJACENT DUPLICATES FROM it_work COMPARING arbpl.

Reward is useful.

Former Member
0 Kudos

Hi ,

If you want to have such a case then your internal table must be a sorthed table with unique key , but then you need to check/modify your code to satisfy the requirement of a sorted table , if you want to use a standard / normal internal ttable then you have to check for existance of the material in the table before you try to insert it.

Regards

Arun