Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Rodrigo-Giner
Active Contributor
0 Kudos

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

3 REPLIES 3

Rodrigo-Giner
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Clemenss
Active Contributor
0 Kudos

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