Application Development and Automation 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: 
Read only

Link a static internal table with a dynamic internal table

Former Member
0 Likes
546

Hi Experts,

I have a static internal table which contains 20 columns.

Depending upon the conditions I might have 20-30 extra columns to be added to this internal table. For this i am using a dynamic internal table. This dynamic itab would fetch the column names and their values.

Now my query is, how to add this dynamic itab to the static itab and display the same.

For ex.

itab has the following fields..

A B C D E F G H I J K L. and rows conating the values/

dynamic i tab has following columns

M N O P Q R S T .. and rows containing the values.

my query is to add this dynamic itab to the static itab.

Please help.

Regards,

Sameep.

1 REPLY 1
Read only

Lukas_Weigelt
Active Contributor
0 Likes
346

Hi,

you will either have to create a third work area/table consisting of your two tables or make a deep structure, something like this:

TYPES: BEGIN OF concat_z,
stattab TYPE ref to data,
dyntab TYPE ref to data,
END OF concat_z.

TYPES: BEGIN OF static_z,
  a TYPE string,
  b TYPE string,
  c TYPE string,
  END OF static_z.

TYPES: BEGIN OF dynamic_z,
  d TYPE string,
  e TYPE string,
  f TYPE string,
  END OF dynamic_z.

TYPES: concat_tab TYPE table of concat_z.
TYPES: static_t TYPE table of static_z.
TYPES: dynamic_t TYPE table of dynamic_z.

DATA: c_itab TYPE concat_tab,
      s_itab TYPE static_t,
      d_itab TYPE dynamic_t.

DATA: c_wa type concat_z,
      s_wa TYPE static_z,
      d_wa TYPE dynamic_z.

s_wa-a = 'bli'.
s_wa-b = 'bla'.
s_wa-c = 'blub'.

APPEND s_wa TO s_itab.

d_wa-d = 'dum'.
d_wa-e = 'di'.
d_wa-f = 'dum'.

APPEND d_wa TO d_itab.

GET REFERENCE OF s_itab INTO c_wa-stattab.
GET REFERENCE OF d_itab INTO c_wa-dyntab.

APPEND c_wa to c_itab.

Not sure if this helps in any way. I don't know myself if there's a way to completely 'merge' two internal tables column-wise.

Regards, Lukas