01-09-2008 8:42 AM
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.
01-09-2008 8:45 AM
hi,
SORT itab BY matnr ...
DELETE ADJACENT DUPLICATES itab COMPARING matnr.
ec
01-09-2008 8:43 AM
In your select query use Syntax Select Distinct MATNR....
Regards,
Satish
01-09-2008 8:44 AM
01-09-2008 8:45 AM
hi,
SORT itab BY matnr ...
DELETE ADJACENT DUPLICATES itab COMPARING matnr.
ec
01-09-2008 8:45 AM
Hi,
Data: check type matnr.
Loop at itab.
if itab-matnr = check.
delete itab.
endif.
check = itab-matnr.
endloop.
01-09-2008 8:45 AM
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.
01-09-2008 8:51 AM
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.
01-09-2008 8:50 AM
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
01-09-2008 8:51 AM
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.
01-09-2008 8:51 AM
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