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

Help collect

Hi,

Is it possible collect the internal table ignoring one field (mara-matnr)?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2008 at 08:02 AM

    Hi

    No!

    The collect collects all records having the same value for the all char fields.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2008 at 08:02 AM

    Hi,

    It is not possible, do one thing take another temporary internal table and make matnr field blank for all the records then do COLLECT.

    Rgds,

    Bujji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2008 at 08:03 AM

    hi...

    in your internal table do u have another field on which you can collect the data..??

    if yes then take another internal table with the same structure excluding matnr field.

    by looping 1st internal ,collect values in another internal table...

    hope this will solve your problem..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2008 at 08:03 AM

    Hi,

    Collect does'nt work for internal tables

    according to ur requirement take another internal table and make matnr field blank for all and then do collect.

    Lines are added to internal tables as follows:

    Standard tables

    If the COLLECT statement is the first statement to fill the standard table, the system creates a temporary hash administration that identifies existing entries in the table. The hash administration is retained until another statement changes the contents of key fields or changes the sequence of the lines in the internal table. After this, the system finds existing entries using a linear search. The runtime for this operation increases in linear relation to the number of existing table entries. The system field SY-TABIX contains the index of the line inserted or modified in the COLLECT statement.

    Sorted tables

    The system uses a binary search to locate existing lines. The runtime for the operation increases logarithmically with the number of existing lines. The system field SY-TABIX contains the index of the line inserted or modified in the COLLECT statement.

    Hashed tables

    The system finds existing lines using the hash algorithm of the internal table. After the COLLECT statement, the system field SY-TABIX has the value 0, since hashed tables have no linear index.

    Plz rewards points if helpful,

    Ganesh.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2008 at 08:05 AM

    Collect considers all the fields in the Internal table ...

    If All non-numeric fields are the same it adds the corresponding

    numeric fields ..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2008 at 08:05 AM

    Hi alfonso,

    consider this example from abapdocu.

    DATA: BEGIN OF seats,

    carrid TYPE sflight-carrid,

    connid TYPE sflight-connid,

    seatsocc TYPE sflight-seatsocc,

    END OF seats.

    DATA seats_tab LIKE HASHED TABLE OF seats

    WITH UNIQUE KEY carrid connid.

    SELECT carrid connid seatsocc

    FROM sflight

    INTO seats.

    COLLECT seats INTO seats_tab.

    ENDSELECT.

    while fetching the data from the database itself u can get the specific values ignoring the matnr in ur case.

    Otherwise if u have internal table with matnr. try to write the move-corresponding to the other internal table which is not having the field matnr and then write the collect statement.

    Regards...

    Arun.

    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.