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

create a dynamic structure

Former Member
0 Likes
538

Hi All,

I have a an internal table with 1 column and 66 rows say A,B.C....

Now I need to convert this into a structure having 66 columns.

How can I achieve this ?

Please help,

Faiz

4 REPLIES 4
Read only

Kartik2
Contributor
0 Likes
510

Hi,

You can do as following

loop at lt_table into ls_area.

     wa_fc-fieldname = ls_area-column1.
     wa_fc-datatype  = 'STRG'.

     append wa_fc to it_fc.
     clear wa_fc.

endloop.

*  Create dynamic internal table and assign to FS
  CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
               it_fieldcatalog  = it_fc
               i_length_in_byte = 'X'
        IMPORTING
               ep_table         = dy_table.

  ASSIGN dy_table->* TO <dyn_table>.

Now that creates an internal table, if you want work area you could do that following

*  Create dynamic work area and assign to FS
  CREATE DATA dy_line LIKE LINE OF <dyn_table>.
  ASSIGN dy_line->* TO <dyn_wa>.

Regards,

Kartik

Read only

Former Member
0 Likes
510

Hi Karthik,

what should be the data type of wa_fc ?

Read only

0 Likes
510

Hi,

If you observe the parameters of mentioned method, it is clear that

It_fc should be of type LVC_T_FCAT,

wa_fc should be of type LVC_S_FCAT

Regards,

Kartik

Read only

Former Member
0 Likes
510

Hi,

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.

DATA: dy_table TYPE REF TO data,

   * Create dynamic internal table structure

   CREATE DATA dy_table TYPE TABLE OF (p_table).

   ASSIGN dy_table->* TO <dyn_table>.

* p_table required Table name

Regards,

satish sudani