Skip to Content
author's profile photo Former Member
Former Member

problem in creating dynamic internal table

Hi Experts,

I am trying creating a dynamic internal table.

But I am getting the error 'The field string "LT_GENTAB" contains no fields. 4 LT_GENTAB".

Can anybody tell me what is the error and how to solve it.

Thanks,

Sudheer

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Apr 16, 2010 at 04:08 AM

    We dont have telepathic powers. Please post the code you are using

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 16, 2010 at 05:15 AM

    TYPE-POOLS: abap.

    DATA:

    lr_structdescr TYPE REF TO cl_abap_structdescr,

    lr_tabledescr TYPE REF TO cl_abap_tabledescr,

    lr_datadescr TYPE REF TO cl_abap_datadescr,

    lt_components TYPE abap_component_tab,

    ls_component TYPE LINE OF abap_component_tab,

    lr_wa TYPE REF TO data,

    lr_tab TYPE REF TO data.

    DATA: lv_index_num(3) TYPE n.

    DATA: lv_index_char(3) TYPE c.

    FIELD-SYMBOLS: <fs_wa> TYPE ANY.

    FIELD-SYMBOLS: <fs_tab> TYPE table.

    START-OF-SELECTION.

    DO 20 TIMES.

    lv_index_num = sy-index.

    lv_index_char = lv_index_num.

    CONCATENATE 'value' lv_index_char INTO ls_component-name.

    ls_component-type ?= cl_abap_elemdescr=>get_c( p_length = 10 ).

    INSERT ls_component INTO TABLE lt_components.

    ENDDO.

    • get structure descriptor -> lr_STRUCTDESCR

    lr_structdescr ?= cl_abap_structdescr=>create( lt_components ).

    • create work area of structure lr_STRUCTDESCR -> lr_WA

    CREATE DATA lr_wa TYPE HANDLE lr_structdescr.

    ASSIGN lr_wa->* TO <fs_wa>.

    lr_datadescr ?= lr_structdescr.

    lr_tabledescr ?= cl_abap_tabledescr=>create( lr_datadescr ).

    • Create dynmaic internal table, <FS_TAB> will be your dynamic internal table

    CREATE DATA lr_tab TYPE HANDLE lr_tabledescr.

    ASSIGN lr_tab->* TO <fs_tab>.

    create a deep structure for dynamic internal table

    data: begin of itab occurs 0,

    material(10),

    unit(5),

    size(2) type n,

    quant type i,

    end of itab,

    begin of wa_out,

    material(10),

    unit(4),

    size1(2) type n,

    size2(2) type n,

    size3(2) type n,

    size4(2) type n,

    size5(2) type n,

    size6(2) type n,

    size7(2) type n,

    size8(2) type n,

    size9(2) type n,

    sizea(2) type n,

    sizeb(2) type n,

    sizec(2) type n,

    sized(2) type n,

    sizee(2) type n,

    sizef(2) type n,

    end of wa_out,

    wa_head like wa_out,

    tab_out like table of wa_out.

    data: begin of ftab occurs 0,

    s_val(2) type n,

    s_idx type i,

    end of ftab.

    field-symbols: <col>.

    wa_head-material = 'Material'.

    wa_head-unit = 'uom'.

    SORT itab by size.

    ftab-s_idx = 2.

    LOOP AT itab.

    on change of itab-size.

    add 1 to ftab-idx.

    ftab-s_val = itab-size.

    append ftab.

    assign COMPONENT ftab-s_idx OF STRUCTURE wa_head to <col>.

    <col> = itab-size.

    endon.

    ENDLOOP.

    sort itab by material.

    LOOP AT itab.

    on CHANGE OF itab-material.

    IF wa_out is not initial.

    append wa_out to tab_out.

    ENDIF.

    clear wa_out.

    wa_out-material = itab-material.

    endon.

    wa_out-unit = itab-unit.

    READ TABLE ftab WITH KEY s_val = itab-size.

    if sy-subrc ne 0.

    • do something awfully impressive

    endif.

    ASSIGN COMPONENT ftab-s_idx OF STRUCTURE wa_out to <col>.

    <col> = itab-quant.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.