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

Internal Table (Consolidation)

Hi Friends...

I got this problem. Imagine I have this Internal Table.

Table1

mandt datum repid dumpid

200 26052008 Ztest2 errorA

200 26052008 Ztest1 errorA

200 26052008 Ztest1 errorA

200 26052008 Ztest2 errorA

200 26052008 Ztest2 errorA

200 26052008 Ztest2 errorA

200 26052008 Ztest1 errorB

200 26052008 Ztest1 errorA

And I Need to "consolidated" this table and generate another table like this.

Table2

mandt datum repid dumpid QTD

200 26052008 Ztest1 errorA 3

200 26052008 Ztest1 errorB 1

200 26052008 Ztest2 errorA 4

My first step was to sort the main table by repid and dumpid.

mandt datum repid dumpid

200 26052008 Ztest1 errorA

200 26052008 Ztest1 errorA

200 26052008 Ztest1 errorA

200 26052008 Ztest1 errorB

200 26052008 Ztest2 errorA

200 26052008 Ztest2 errorA

200 26052008 Ztest2 errorA

200 26052008 Ztest2 errorA

But Im having problem with the loop. (using at end of).

Data: l_count type i.

loop at table1.

at new repid.

clear l_cont.

endat.

l_count = l_count + 1.

at end of dumpid.

table2-mandt = table1-mandt.

table2-datum = table1-datum.

table2-repid = table1-repid.

table2-dumpid = table1-dumpid.

table2-qtd = l_count.

append table2.

endat.

endloop.

But my l_count always get "cleared", because always enter at "at new repid". Am i forgeting something?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 06:19 PM

    Yeah... its working.... now my table2 have only one registry of each. But my qtd remains 1 for all. 😔

    trying

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 05:45 PM

    Hello,

    Try this:

    SORT table1 BY mandt datum repid dumpid.
    
    LOOP AT table1.
      MOVE-CORRESPONDING table1 TO table2.
      table2-qtd = 1.
      COLLECT table2.
    ENDLOOP.
    

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 27, 2008 at 05:46 PM

    Instead of your LOOP, use this loop with COLLECT statement.

    loop at table1.
    table2-mandt = table1-mandt.
    table2-datum = table1-datum.
    table2-repid = table1-repid.
    table2-dumpid = table1-dumpid.
    table2-qtd = 1.
    collect table2.
    clear   table2.
    endloop.
    

    Regards,

    Naimeh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 05:57 PM

    Trying solutions provided.

    Well, I think my dificult will be because those tables are differente then one another. Table 1 have a lot of others fields I dont need at table 2.

    trying

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 06:06 PM

    Still not working... Maybe It is need to declare some fields of my internal table as unique key to collect work properly?

    trying

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 06:22 PM

    Return to use standard table without unique key and it worked fine. -

    Wow. Thank you.

    rewarding

    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.