<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: TSV_ILLEGAL_REFERENCE while trying to append to dynamic structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/tsv-illegal-reference-while-trying-to-append-to-dynamic-structure/m-p/8058390#M1612470</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Rajesh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspected that problem was somewhere in my understanding of principles. Thank you for your answer, problem is solved now.&lt;/P&gt;&lt;P&gt;Here is the solution code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; data: lr_strucdesc TYPE REF TO CL_ABAP_STRUCTDESCR,
        lr_tableref TYPE REF TO CL_ABAP_TABLEDESCR,
        dref TYPE REF TO DATA,
        linetype TYPE REF TO CL_ABAP_STRUCTDESCR,
        comp_tab     TYPE cl_abap_structdescr=&amp;gt;component_table.

FIELD-SYMBOLS: &amp;lt;fs_table&amp;gt; TYPE INDEX TABLE.
  
  lr_strucdesc ?= cl_abap_typedescr=&amp;gt;describe_by_name( 'ZAK_STAT_DEF' ).

  comp_tab = lr_strucdesc-&amp;gt;get_components( ).
  
  linetype = cl_abap_structdescr=&amp;gt;create( comp_tab ).
  
  lr_tableref = cl_abap_tabledescr=&amp;gt;create(
   p_line_type = linetype
   p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_std 
  ).
 
 CREATE DATA dref TYPE HANDLE lr_tableref.
 ASSIGN dref-&amp;gt;* TO &amp;lt;fs_table&amp;gt;.
 
 APPEND INITIAL LINE TO &amp;lt;fs_table&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Jul 2011 08:02:20 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-07-08T08:02:20Z</dc:date>
    <item>
      <title>TSV_ILLEGAL_REFERENCE while trying to append to dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/tsv-illegal-reference-while-trying-to-append-to-dynamic-structure/m-p/8058388#M1612468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create structure dynamically, but when I try to make an append (even the initial line), I get &lt;STRONG&gt;TSV_ILLEGAL_REFERENCE&lt;/STRONG&gt; dump.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  data: lr_strucdesc TYPE REF TO CL_ABAP_STRUCTDESCR,
        dref TYPE REF TO DATA,
  lr_strucdesc ?= cl_abap_typedescr=&amp;gt;describe_by_name( 'ZAK_STAT_DEF' ).
  CREATE DATA dref TYPE HANDLE lr_strucdesc.
  FIELD-SYMBOLS: &amp;lt;fs_table&amp;gt; TYPE INDEX TABLE.
  ASSIGN dref-&amp;gt;* TO &amp;lt;fs_table&amp;gt; CASTING TYPE HANDLE lr_strucdesc.

  APPEND INITIAL LINE TO &amp;lt;fs_table&amp;gt;. " &amp;lt;&amp;lt; dump is here
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Anton.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 14:44:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/tsv-illegal-reference-while-trying-to-append-to-dynamic-structure/m-p/8058388#M1612468</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T14:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: TSV_ILLEGAL_REFERENCE while trying to append to dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/tsv-illegal-reference-while-trying-to-append-to-dynamic-structure/m-p/8058389#M1612469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; I create structure dynamically, but when I try to make an append (even the initial line), I get &lt;STRONG&gt;TSV_ILLEGAL_REFERENCE&lt;/STRONG&gt; dump.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here lies the issue, you are trying to append a record(initial) to a structure!  the 'CASTING' addition doesn't help you to create a table out of a structure, extract from F1 help of 'CASTING' addition of 'ASSIGN' statement says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"&lt;STRONG&gt;The specified data type must match the generic typing of the field symbol, which means that the casting may specialize the generic typing, but not generalize it&lt;/STRONG&gt;&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution :&lt;/STRONG&gt; create a dynamic table from the dynamic structure and append(initial) record to the dynamic table instead... how to create dynamic table? check the documentation of the method 'CREATE' of the class 'CL_ABAP_TABLEDESCR'  or search the forum with the keyword "CL_ABAP_TABLEDESCR=&amp;gt;CREATE"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rajesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 16:35:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/tsv-illegal-reference-while-trying-to-append-to-dynamic-structure/m-p/8058389#M1612469</guid>
      <dc:creator>rajesh_paruchuru</dc:creator>
      <dc:date>2011-07-07T16:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: TSV_ILLEGAL_REFERENCE while trying to append to dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/tsv-illegal-reference-while-trying-to-append-to-dynamic-structure/m-p/8058390#M1612470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Rajesh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspected that problem was somewhere in my understanding of principles. Thank you for your answer, problem is solved now.&lt;/P&gt;&lt;P&gt;Here is the solution code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; data: lr_strucdesc TYPE REF TO CL_ABAP_STRUCTDESCR,
        lr_tableref TYPE REF TO CL_ABAP_TABLEDESCR,
        dref TYPE REF TO DATA,
        linetype TYPE REF TO CL_ABAP_STRUCTDESCR,
        comp_tab     TYPE cl_abap_structdescr=&amp;gt;component_table.

FIELD-SYMBOLS: &amp;lt;fs_table&amp;gt; TYPE INDEX TABLE.
  
  lr_strucdesc ?= cl_abap_typedescr=&amp;gt;describe_by_name( 'ZAK_STAT_DEF' ).

  comp_tab = lr_strucdesc-&amp;gt;get_components( ).
  
  linetype = cl_abap_structdescr=&amp;gt;create( comp_tab ).
  
  lr_tableref = cl_abap_tabledescr=&amp;gt;create(
   p_line_type = linetype
   p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_std 
  ).
 
 CREATE DATA dref TYPE HANDLE lr_tableref.
 ASSIGN dref-&amp;gt;* TO &amp;lt;fs_table&amp;gt;.
 
 APPEND INITIAL LINE TO &amp;lt;fs_table&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2011 08:02:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/tsv-illegal-reference-while-trying-to-append-to-dynamic-structure/m-p/8058390#M1612470</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-08T08:02:20Z</dc:date>
    </item>
  </channel>
</rss>

