Skip to Content
author's profile photo Former Member
Former Member

internal table

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    Posted on Jan 09, 2008 at 08:45 AM

    hi,

    SORT itab BY matnr ...

    DELETE ADJACENT DUPLICATES itab COMPARING matnr.

    ec

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 08:45 AM

    Hi,

    Data: check type matnr.

    Loop at itab.

    if itab-matnr = check.

    delete itab.

    endif.

    check = itab-matnr.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 08: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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 08: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 08: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 08: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 08:43 AM

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

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 08:44 AM

    Hi Subramanaian,

    Use APPEND in ur code.

    Thankyou,

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.