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

internal table

Former Member
0 Likes
844

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
Read only

JozsefSzikszai
Active Contributor
0 Likes
793

hi,

SORT itab BY matnr ...

DELETE ADJACENT DUPLICATES itab COMPARING matnr.

ec

9 REPLIES 9
Read only

Former Member
0 Likes
793

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

Regards,

Satish

Read only

Former Member
0 Likes
793

Hi Subramanaian,

Use APPEND in ur code.

Thankyou,

Regards.

Read only

JozsefSzikszai
Active Contributor
0 Likes
794

hi,

SORT itab BY matnr ...

DELETE ADJACENT DUPLICATES itab COMPARING matnr.

ec

Read only

Former Member
0 Likes
793

Hi,

Data: check type matnr.

Loop at itab.

if itab-matnr = check.

delete itab.

endif.

check = itab-matnr.

endloop.

Read only

Former Member
0 Likes
793

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.

Read only

0 Likes
793

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.

Read only

Former Member
0 Likes
793

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

Read only

Former Member
0 Likes
793

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.

Read only

Former Member
0 Likes
793

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