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

cl_alv_table_create=>create_dynamic_table error

Former Member
0 Likes
1,929

Hi Gurus,

Method cl_alv_table_create=>create_dynamic_table

is giving dump.When i am trying to create internal table from fieldcatalog values.Program" "not found.

Please suggest some solution.

Good answers will be rewarded with points.

Thanks,

Twinkle

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,114

Check this program as reference .



report zrich_0002.

type-pools: slis.

field-symbols: <dyn_table> type standard table,
               <dyn_wa>,
               <dyn_field>.

data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.

type-pools : abap.

data : it_details type abap_compdescr_tab,
       wa_details type abap_compdescr.

data : ref_descr type ref to cl_abap_structdescr.

data: new_table type ref to data,
      new_line  type ref to data,
      wa_it_fldcat type lvc_s_fcat.

selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.


* Get the structure of the table.
ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
it_details[] = ref_descr->components[].

loop at it_details into wa_details.
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname = wa_details-name .
  wa_it_fldcat-datatype = wa_details-type_kind.
  wa_it_fldcat-inttype = wa_details-type_kind.
  wa_it_fldcat-intlen = wa_details-length.
  wa_it_fldcat-decimals = wa_details-decimals.
  append wa_it_fldcat to it_fldcat .
endloop.

* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
             exporting
                it_fieldcatalog = it_fldcat
             importing
                ep_table        = new_table.

assign new_table->* to <dyn_table>.

* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.

* Select Data from table.
select * into corresponding fields of table <dyn_table>
           from (p_table).

* Write out data from table.
loop at <dyn_table> into <dyn_wa>.
  do.
    assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
    if sy-subrc <> 0.
      exit.
    endif.
    if sy-index = 1.
      write:/ <dyn_field>.
    else.
      write: <dyn_field>.
    endif.
  enddo.
endloop.

Regards,

Rich Heilman

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,115

Check this program as reference .



report zrich_0002.

type-pools: slis.

field-symbols: <dyn_table> type standard table,
               <dyn_wa>,
               <dyn_field>.

data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.

type-pools : abap.

data : it_details type abap_compdescr_tab,
       wa_details type abap_compdescr.

data : ref_descr type ref to cl_abap_structdescr.

data: new_table type ref to data,
      new_line  type ref to data,
      wa_it_fldcat type lvc_s_fcat.

selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.


* Get the structure of the table.
ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
it_details[] = ref_descr->components[].

loop at it_details into wa_details.
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname = wa_details-name .
  wa_it_fldcat-datatype = wa_details-type_kind.
  wa_it_fldcat-inttype = wa_details-type_kind.
  wa_it_fldcat-intlen = wa_details-length.
  wa_it_fldcat-decimals = wa_details-decimals.
  append wa_it_fldcat to it_fldcat .
endloop.

* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
             exporting
                it_fieldcatalog = it_fldcat
             importing
                ep_table        = new_table.

assign new_table->* to <dyn_table>.

* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.

* Select Data from table.
select * into corresponding fields of table <dyn_table>
           from (p_table).

* Write out data from table.
loop at <dyn_table> into <dyn_wa>.
  do.
    assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
    if sy-subrc <> 0.
      exit.
    endif.
    if sy-index = 1.
      write:/ <dyn_field>.
    else.
      write: <dyn_field>.
    endif.
  enddo.
endloop.

Regards,

Rich Heilman

Read only

0 Likes
1,114

Hi Reich,

I have created a dynamic ITAB from 1 Row of Excel Sheet

LOOP AT ist_excel INTO w_excel WHERE row = 2. " Contains the Values provided in 2nd row of Excel
    APPEND w_excel TO row1.
  ENDLOOP.
  LOOP AT ist_excel INTO w_excel WHERE row = 3. " Contains the Values provided in 3rd row of Excel
    APPEND w_excel TO row2.
  ENDLOOP.
  LOOP AT ist_excel INTO w_excel WHERE row = 4." Contains the Values provided in 4th row of Excel Etc
    APPEND w_excel TO row3.
  ENDLOOP.

  LOOP AT row1 INTO w_excel.
    CLEAR wa_it_fldcat.
    wa_it_fldcat-fieldname = w_excel-value .
    wa_it_fldcat-datatype = 'C'.
    wa_it_fldcat-inttype = wa_details-type_kind.
    wa_it_fldcat-intlen = 40.
*  wa_it_fldcat-decimals = wa_details-decimals.
    APPEND wa_it_fldcat TO it_fldcat .
  ENDLOOP.

* Create dynamic internal table and assign to FS
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fldcat
    IMPORTING
      ep_table        = new_table.

  ASSIGN new_table->* TO <dyn_table>.

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

I followed the Link provided by to create a Dynamic ITAB
Please guide me how to pass these Value from excel to Dynamic Internal Table

Warm Regards

Ramchander Rao.K