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

Moving values from one internal table to another internal table

Hi friends,

i have a reeuirement.

In my internal table ITAB1 in that i have the followind data.

EBELN EBELP MATNR

2000 10 100

2000 20 200

2000 30 100

3000 10 100

3000 20 200

3000 20 300

4000 10 200

4000 20 100

4000 20 300

now my requirement is when iam looping that ITAB1

the ist line should go into one internal table ITAB2

And now since the ebeln is same for next 2 records the next 2 records incluiding the ist record shuld go into another internal table itab3.

ie :

my itab2 and itab3 should be in this format.

itab2

2000 10 100

3000 10 100

4000 10 200

itab3

2000 10 100

2000 20 200

2000 30 100

3000 10 100

3000 20 200

3000 20 300

4000 10 200

4000 20 100

4000 20 300

How can i do that.

can any one suggest me.

Regards

Priyanka.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    Posted on Nov 12, 2008 at 03:53 PM

    something like:

    SORT itab1.
    APPEND LINES OF itab1 TO itab3.
    LOOP AT itab1 INTO wa1.
    wa_temp = wa1.
    AT NEW ebeln.
    APPEND wa_temp TO itab2.
    ENDAT.
    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 12, 2008 at 03:52 PM

    Hi Hope this helps

    field-symbols: <fs_itab2> like line of itab2,
                        <fs_itab3> like line of itab3.
    
    sort itab1.
    
    loop at itab1.
    at new itab1-ebeln.
    <fs_itab2>-EBELN = itab1-EBELN
    <fs_itab2>-EBELP = itab1-EBELP 
    <fs_itab2>-MATNR = itab1-MATNR
    append itab2 from <fs_itab2>.
    endat.
    <fs_itab3>-EBELN = itab1-EBELN
    <fs_itab3>-EBELP = itab1-EBELP 
    <fs_itab3>-MATNR = itab1-MATNR
    append itab2 from <fs_itab3>.
    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 12, 2008 at 03:54 PM

    Your code looks similer to this way.

    sort:itab1 by ebeln.
    Loop at itb1.
    at new ebeln.
    itab2 = itab1.
    append itab2.
    endat.
    itab3 = itab1.
    append itab3
    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 12, 2008 at 04:08 PM

    <<deleted_by_moderator>>

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 12, 2008 at 04:09 PM
    data: i_pos type i,
                     tmp_eben like itab1-eben.
    
    Loop at itab1.
       at new EBELN.
       itab2 = itab1.
       append itab2.      "only first entries  from itab1 will be move to in itab2
       i_pos = sy-tabix.   "remember position
       tmp_eben = itab1-eben. "remember eben
       endat.
      
       add 2 to i_pos.
       if sy-tabix le i_pos and itab1-eben eq tmp_eben.    "rewrite only if eben is equal (only for next two indexes)
         itab3 = itab1.
         append itab3.
       endif.
    endloop.
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 12, 2008 at 04:22 PM

    Hi Amit,

    it Seems so but not actually...

    In general...if you want to declare 3 internal tables then it ll be starting with itab only..

    You can check above also..

    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.