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

How do I populate internal table data into another internal table <FS>.

Hi All,

I am selecting some data from a table, after processing the data I need to populate this data into an internal table represented by a field-symbol.

For example:

I have ITAB as:

ITAB

MATNR MTART MATKL MEINS MAKTX

1000 ZPRA 40000000 EA Test Material 1

1001 ZPRA 40000001 EA Test Material 2

1002 ZPRA 40000002 EA Test Material 3

I am able to create a dynamic internal table <F_ITAB> of the structure[This structure is dynamic and is not from se11]:

MATNR MTART MATKL MEINS MAKTX

Now, the problem am facing is, how will I populate the data of ITAB into <F_ITAB>?

Regards

Raj

Edited by: Rajasekhar Dinavahi on Jul 2, 2011 2:25 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jul 01, 2011 at 09:52 PM

    Here is a working example. Just rename "it_mara" for your internal table name. If the internal table has work area you will get an error.

    The key is declare the field symbol with TYPE ANY TABLE

    DATA: it_mara TYPE TABLE OF mara.
    
    FIELD-SYMBOLS: <fs> TYPE ANY TABLE.
    
    SELECT * UP TO 10 ROWS
      FROM mara
      INTO TABLE it_mara.
    
    ASSIGN it_mara TO <fs>.

    Here is the SAP help about this.

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 01, 2011 at 10:24 PM

    Hi Rodrigo,

    Thank you...

    Once I change my internal table declaration [no header line], am able to assign the internal table(along with data) to field symbol...

    Regards

    Raj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 02, 2011 at 02:04 PM

    Hi Rajasekhar Dinavahi,

    if I understand you right, your dynamic table has at least some fields the existing itab has also. Then it should be

    field-symbols:
      <rec_old> type any,
      <rec_new> type any.
    * loop at existing data
    loop at ITAB assigning <rec_old> .
    * create an initil record in the dynamic table and assign it to a field-symbol
      append initial line to <F_ITAB> assigning <rec_new>.
    * fill the new record with fields of ITAB
      move-corresponding <rec_old> to <rec_new>.
    endloop.

    Regards,

    Clemens

    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.