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 dynamic internal table

Former Member
0 Likes
437

Hi,

I am creating a dynamic internal table which has 164 columns. 34 columns (Sales area)repeating 4 times.I am able to form a field catelao, but the method CALL METHOD cl_alv_table_create=>create_dynamic_table gives the short dump 'LOAD_PROGRAM_NOT_FOUND' Program " " not found.

here is my code:

FORM get_dynamic_table .

DATA:

my_data TYPE ty_general_data,

my_data1 TYPE ty_sales,

descr_ref TYPE ref to cl_abap_structdescr,

descr_ref1 TYPE ref to cl_abap_structdescr.

FIELD-SYMBOLS:

<comp_wa> TYPE abap_compdescr.

descr_ref ?= cl_abap_typedescr=>describe_by_data( my_data ).

descr_ref1 ?= cl_abap_typedescr=>describe_by_data( my_data1 ).

*DATA: v_fieldname TYPE char30.

*DATA: v_char TYPE numc3.

DATA: it_fldcat TYPE lvc_t_fcat.

DATA: wa_it_fldcat type LVC_S_FCAT.

DATA: gp_table TYPE REF TO data.

DATA: v_char TYPE numc3.

DATA : DREF TYPE REF TO DATA.

data:dyn_wa type char2000 .

DO 65 TIMES.

v_char = sy-index.

if sy-index le 62.

read table descr_ref->components ASSIGNING <comp_wa> index v_char.

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = <comp_wa>-name.

wa_it_fldcat-datatype = 'CHAR'.

wa_it_fldcat-outputlen = <comp_wa>-length.

wa_it_fldcat-intlen = <comp_wa>-length.

APPEND wa_it_fldcat TO it_fldcat .

else.

Do 34 times.

v_char = sy-index.

read table descr_ref1->components ASSIGNING comp_wa> index v_char.

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = <comp_wa>-name.

wa_it_fldcat-datatype = 'CHAR'.

wa_it_fldcat-outputlen = <comp_wa>-length.

wa_it_fldcat-intlen = <comp_wa>-length.

APPEND wa_it_fldcat TO it_fldcat .

enddo.

endif.

ENDDO.

*Internal table creation..

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING it_fieldcatalog = it_fldcat

IMPORTING ep_table = gp_table.

ASSIGN gp_table->* TO <tb_file_data>.

ENDFORM. " get_dynamic_table

Could you please help on this.

regards,

Sankar

3 REPLIES 3
Read only

Former Member
0 Likes
415

Hi

Try to transfer the WA_IT_FLDCAT-INTTYPE too

Max

Edited by: max bianchi on Apr 30, 2008 10:05 AM

Read only

Former Member
0 Likes
415

I have tried to pass it_fldcat-inttype, but still getting the same dump.

Read only

Former Member
0 Likes
415

Hi,

try this..

=====================================

REPORT zmaschl_create_data_dynamic .

TYPE-POOLS: slis.

DATA: it_fcat TYPE slis_t_fieldcat_alv,

is_fcat LIKE LINE OF it_fcat.

DATA: it_fieldcat TYPE lvc_t_fcat,

is_fieldcat LIKE LINE OF it_fieldcat.

DATA: new_table TYPE REF TO data.

DATA: new_line TYPE REF TO data.

FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,

<l_line> TYPE ANY,

<l_field> TYPE ANY.

Build fieldcat

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SYST'

CHANGING

ct_fieldcat = it_fcat[].

LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.

MOVE-CORRESPONDING is_fcat TO is_fieldcat.

is_fieldcat-fieldname = is_fcat-fieldname.

is_fieldcat-ref_field = is_fcat-fieldname.

is_fieldcat-ref_table = is_fcat-ref_tabname.

APPEND is_fieldcat TO it_fieldcat.

ENDLOOP.

Create a new Table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fieldcat

IMPORTING

ep_table = new_table.

Create a new Line with the same structure of the table.

ASSIGN new_table->* TO <l_table>.

CREATE DATA new_line LIKE LINE OF <l_table>.

ASSIGN new_line->* TO <l_line>.

Test it...

DO 30 TIMES.

ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.

<l_field> = sy-index.

INSERT <l_line> INTO TABLE <l_table>.

ENDDO.

LOOP AT <l_table> ASSIGNING <l_line>.

ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.

WRITE <l_field>.

ENDLOOP.

Regards,

Raj.