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

Get One Column from an internal table without looping

Hi All,

I have a Huge Internal Table with several columns and would like to get Just two columns from it to another internal table that has just two columns.

Something like this:

Table A;
	
Fld1	Fld2	Fld3	Fld4
1	11	21	31
2	12	22	32
3	13	23	33
4	14	24	34
5	15	25	35
6	16	26	36

And the resulting second table after the move.

Table B;

Fld1	Fld2	
1	11	
2	12	
3	13	
4	14	
5	15	
6	16

But as the Table A is huge with about a 100,000 records; Looping through takes up a lot of resources. And

TableA[] = TableB[] doesn't work for me as the Flds have a different structure in the two tables.

Is there any other way to get around this.?

Thanks in advance..!

Jr

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2006 at 02:18 PM

    Hi

    The answer is NO. Cant achieve that without looping at the huge table.

    But, looping on that internal table and populating the second table will not have any issues if records are more...

    Regards,

    Raj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 15, 2006 at 02:18 PM

    I guess you have to loop it .there is no other way.

    Anyway, you must have already looped some other table when you have built the first table. Populate the second table as well in the same step.

    regards,

    ravi

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi,

      i have tried it like this,

      data : begin of it_ekko occurs 0,
              ebeln type ebeln,
              bstyp type bstyp,
              bsart type bsart,
              statu type statu,
             end of it_ekko.
      data : begin of t_ekko occurs 0,
              ebeln type ebeln,
             end of t_ekko.  
      
      start-of-selection.
        SELECT EBELN
               BSTYP
               BSART
               STATU
          FROM EKKO
          INTO TABLE IT_EKKO
         WHERE EBELN IN S_EBELN.
      
         t_ekko[] = it_ekko[].

      it assign the ebeln to t_ekko.

      it is working fine. if you are having different field then how can you assign different fields.

      Regards,

      Richa

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2006 at 02:19 PM

    Hi

    I don't believe you can do it without looping the table

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2006 at 02:31 PM

    try this .... not sure

    <b>

    APPEND LINES OF ITAB1 to ITAB2.

    </b>

    but as the structures are differnt it may not waor , anywayz give it a try

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2006 at 02:36 PM

    Hi jr,

    1. It can be done.

    2. Provided the following simple things are fulfilled.

    a) Table A should have also have

    FIELD1, FIELD2 (of internal table B)

    As the FIRST TWO FIELDS (Starting from Left)

    3. Then

    tableb[] = tablea[]

    will work PERFECTLY FINE.

    4. To get a taste of it, just copy paste

    5.

    report abc.

    data : t001 like t001 occurs 0 with header line.

    data : begin of itab occurs 0,

    mandt like t001-mandt,

    bukrs like t001-bukrs,

    end of itab.

    *-------

    select * from t001

    into table t001.

    itab[] = t001[].

    break-point.

    regards,

    amit m.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi

      Some guys are right and I was wrong.

      I tried this code and worked fine:

      DATA: BEGIN OF ITAB1 OCCURS 0,

      FIELD1(4) TYPE N,

      FIELD2(4) TYPE N,

      FIELD3(4) TYPE N,

      FIELD4(4) TYPE N,

      END OF ITAB1.

      DATA: BEGIN OF ITAB2 OCCURS 0,

      FIELD1(4) TYPE N,

      FIELD2(4) TYPE N,

      END OF ITAB2.

      DO 1000 TIMES.

      MOVE SY-INDEX TO ITAB1-FIELD1.

      ITAB1-FIELD2 = ITAB1-FIELD3 = ITAB1-FIELD4 = ITAB1-FIELD1.

      APPEND ITAB1.

      ENDDO.

      ITAB2[] = ITAB1[].

      LOOP AT ITAB2.

      WRITE: / ITAB2.

      ENDLOOP.

      Max

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2006 at 02:49 PM

    HI

    Try out this code. Its working fine.

    Data : begin of it_vbak occurs 0,

    vbeln like vbak-vbeln,

    ernam like vbak-ernam,

    end of it_vbak.

    Data : begin of it_final occurs 0,

    vbeln like vbak-vbeln,

    end of it_final.

    select vbeln ernam from vbak into table it_vbak.

    it_final[] = it_vbak[].

    loop at it_final.

    write:/ it_final-vbeln.

    endloop.

    Regards

    Haritha

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Ravikanth Talagana

      Hi Ravi,

      Yes i agree looping is a way but i want to know any other method apart from looping like some direct one line statements like ITAB1 IN ITAB2 etc.. which should give me the common values of both the internal table . and here both the internal table have same structure also

      Rgds

      Mohit

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2006 at 02:56 PM

    Hi,

    If in both the internal tables if the common columns are placed leftmost of their structure you can directly use the body operator..THis will work fine..

    TABLEB[] = TABLEA[].

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 08:39 AM

    Hi ,

    I have some what same scenario where i have two internal tables of exactly the same structure and i want to get only the common data of the two internal table.

    apart from looping is thier any other way.

    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.