<?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 Dynamic Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table/m-p/3533601#M850115</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 got error when it comes to the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error " CREATE DATA: The specified type " " is no valid data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;dynamically create appropriate internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data dref type table of (tabname).&lt;/P&gt;&lt;P&gt;  assign dref-&amp;gt;* to &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone identify the error? Please help. Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; Report  Z_ZRVSL0013&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; This program is used to remove logs created in z-tables.&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  Z_ZRVSL0013.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of it_tbl occurs 0.&lt;/P&gt;&lt;P&gt;          include structure ztabl_log.&lt;/P&gt;&lt;P&gt;data : end of it_tbl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : num_days type sy-datum,&lt;/P&gt;&lt;P&gt;       num_days1 type string,&lt;/P&gt;&lt;P&gt;       query type string,&lt;/P&gt;&lt;P&gt;       status(80) type c.&lt;/P&gt;&lt;P&gt;data : tabname type tabname,&lt;/P&gt;&lt;P&gt;       fieldname type fieldname.&lt;/P&gt;&lt;P&gt;data : xref type ref to cx_dynamic_check,&lt;/P&gt;&lt;P&gt;       message_txt type string,&lt;/P&gt;&lt;P&gt;       dref type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters : chckbox as checkbox default 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;tab&amp;gt; type standard table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;dynamically create appropriate internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data dref type table of (tabname).&lt;/P&gt;&lt;P&gt;  assign dref-&amp;gt;* to &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if chckbox is not initial.&lt;/P&gt;&lt;P&gt;  select * from ztabl_log into table it_tbl.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;  exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at it_tbl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    tabname = it_tbl-tabname.&lt;/P&gt;&lt;P&gt;    fieldname = it_tbl-fname.&lt;/P&gt;&lt;P&gt;    num_days = sy-datum - it_tbl-zdays.&lt;/P&gt;&lt;P&gt;    concatenate '''' num_days '''' into num_days1.&lt;/P&gt;&lt;P&gt;    concatenate fieldname '&amp;lt;' num_days1 into query separated by space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    select *&lt;/P&gt;&lt;P&gt;        from (tabname)&lt;/P&gt;&lt;P&gt;          into table &amp;lt;tab&amp;gt;&lt;/P&gt;&lt;P&gt;         where (query).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;    delete (tabname) from table &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;    concatenate 'Last update is on' sy-datum into status separated by space.&lt;/P&gt;&lt;P&gt;    it_tbl-status = status.&lt;/P&gt;&lt;P&gt;    modify (tabname) from it_tbl.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;catch cx_sy_dynamic_osql_error&lt;/P&gt;&lt;P&gt;cx_sy_create_data_error into xref.&lt;/P&gt;&lt;P&gt;message_txt = xref-&amp;gt;get_text( ).&lt;/P&gt;&lt;P&gt;message message_txt type 'E'.&lt;/P&gt;&lt;P&gt;endtry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Hui Leng Yeoh on Feb 29, 2008 4:18 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Feb 2008 03:13:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-29T03:13:30Z</dc:date>
    <item>
      <title>Dynamic Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table/m-p/3533601#M850115</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 got error when it comes to the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error " CREATE DATA: The specified type " " is no valid data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;dynamically create appropriate internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data dref type table of (tabname).&lt;/P&gt;&lt;P&gt;  assign dref-&amp;gt;* to &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone identify the error? Please help. Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; Report  Z_ZRVSL0013&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; This program is used to remove logs created in z-tables.&lt;/P&gt;&lt;P&gt;*&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  Z_ZRVSL0013.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of it_tbl occurs 0.&lt;/P&gt;&lt;P&gt;          include structure ztabl_log.&lt;/P&gt;&lt;P&gt;data : end of it_tbl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : num_days type sy-datum,&lt;/P&gt;&lt;P&gt;       num_days1 type string,&lt;/P&gt;&lt;P&gt;       query type string,&lt;/P&gt;&lt;P&gt;       status(80) type c.&lt;/P&gt;&lt;P&gt;data : tabname type tabname,&lt;/P&gt;&lt;P&gt;       fieldname type fieldname.&lt;/P&gt;&lt;P&gt;data : xref type ref to cx_dynamic_check,&lt;/P&gt;&lt;P&gt;       message_txt type string,&lt;/P&gt;&lt;P&gt;       dref type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters : chckbox as checkbox default 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;tab&amp;gt; type standard table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;dynamically create appropriate internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data dref type table of (tabname).&lt;/P&gt;&lt;P&gt;  assign dref-&amp;gt;* to &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if chckbox is not initial.&lt;/P&gt;&lt;P&gt;  select * from ztabl_log into table it_tbl.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;  exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at it_tbl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    tabname = it_tbl-tabname.&lt;/P&gt;&lt;P&gt;    fieldname = it_tbl-fname.&lt;/P&gt;&lt;P&gt;    num_days = sy-datum - it_tbl-zdays.&lt;/P&gt;&lt;P&gt;    concatenate '''' num_days '''' into num_days1.&lt;/P&gt;&lt;P&gt;    concatenate fieldname '&amp;lt;' num_days1 into query separated by space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    select *&lt;/P&gt;&lt;P&gt;        from (tabname)&lt;/P&gt;&lt;P&gt;          into table &amp;lt;tab&amp;gt;&lt;/P&gt;&lt;P&gt;         where (query).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;    delete (tabname) from table &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;    concatenate 'Last update is on' sy-datum into status separated by space.&lt;/P&gt;&lt;P&gt;    it_tbl-status = status.&lt;/P&gt;&lt;P&gt;    modify (tabname) from it_tbl.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;catch cx_sy_dynamic_osql_error&lt;/P&gt;&lt;P&gt;cx_sy_create_data_error into xref.&lt;/P&gt;&lt;P&gt;message_txt = xref-&amp;gt;get_text( ).&lt;/P&gt;&lt;P&gt;message message_txt type 'E'.&lt;/P&gt;&lt;P&gt;endtry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Hui Leng Yeoh on Feb 29, 2008 4:18 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Feb 2008 03:13:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table/m-p/3533601#M850115</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-29T03:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table/m-p/3533602#M850116</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 thing wrong with syntax...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Correct One:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create data dref type (tabname).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data dref type table of (tabname).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the docu..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creating Data Objects Dynamically &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CREATE DATA statement prior to Release 6.10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA allows you to create fields in a pre-defined or user-defined data type. The statement has the following variants:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA dref TYPE  typ.&lt;/P&gt;&lt;P&gt;CREATE DATA dref TYPE (typname).&lt;/P&gt;&lt;P&gt;CREATE DATA dref LIKE  feld.&lt;/P&gt;&lt;P&gt;CREATE DATA dref TYPE LINE OF itab.&lt;/P&gt;&lt;P&gt;CREATE DATA dref LIKE LINE OF itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the following example, a specific field is read from database table X031L. Note that neither the field name nor the table name is known until runtime: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Read a field from the table X031L&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS:&lt;/P&gt;&lt;P&gt;  TAB_NAME    LIKE SY-TNAME,           "Table name&lt;/P&gt;&lt;P&gt;  TAB_COMP    LIKE X031L-FIELDNAME,   "Field name&lt;/P&gt;&lt;P&gt;  ANZAHL      TYPE I DEFAULT 10.       Number of lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;WA&amp;gt;   TYPE ANY,&lt;/P&gt;&lt;P&gt;               &amp;lt;COMP&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: WA_REF TYPE REF TO DATA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CREATE DATA WA_REF TYPE (TAB_NAME). "Suitable work area&lt;/P&gt;&lt;P&gt;  ASSIGN WA_REF-&amp;gt;* TO &amp;lt;WA&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM (TAB_NAME) INTO &amp;lt;WA&amp;gt; &lt;/P&gt;&lt;P&gt;  UP TO anzahl ROWS.&lt;/P&gt;&lt;P&gt;  WRITE: / TAB_COMP, &amp;lt;COMP&amp;gt;.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CREATE DATA statement for internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another variant of CREATE DATA allows you to create table objects at runtime. The line type and table key can be entered statically or dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA dref (TYPE [STANDARD|SORTED|HASHED] TABLE&lt;/P&gt;&lt;P&gt;     OF (LineType | (Name) |REF TO DATA | REF TO Obj))&lt;/P&gt;&lt;P&gt;     | (LIKE [STANDARD|SORTED|HASHED] TABLE OF LineObj &lt;/P&gt;&lt;P&gt;       [ WITH (UNIQUE|NON-UNIQUE) &lt;/P&gt;&lt;P&gt;        (KEY (k1 ... kn | (keytab) | TABLE_LINE )| DEFAULT KEY )  ]&lt;/P&gt;&lt;P&gt;       [ INITIAL SIZE m ]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following constraints apply to this variant: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;m is a variable or a constant without a sign, whose content at runtime must be of the type NUMLIKE. &lt;/P&gt;&lt;P&gt;keytab is a table of the type CHARLIKE, which must not be empty, and whose components must not contain any offset, length, or overlapping key entries. You can use the TABLE_LINE addition, if the table contains only one line. &lt;/P&gt;&lt;P&gt;The system returns a syntax error if either the type, or line declaration and the key declaration are static. &lt;/P&gt;&lt;P&gt;If you do not define a key, the system uses the DEFAULT-KEY. &lt;/P&gt;&lt;P&gt;The CREATE DATA statement with built-in generic types&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use the basic generic types, C, N, X, and P with the CREATE DATA statement. You can specify the length and number of decimal places (for type P) using additions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA dref TYPE (t | (typeName))&lt;/P&gt;&lt;P&gt;[ LENGTH len ]&lt;/P&gt;&lt;P&gt;[ DECIMALS dec ].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can only use the LENGTH addition for types C, N, X, and P and you must always include it after the TYPE keyword. A catchable runtime error occurs if you do not comply with syntax conventions when entering LENGTH or DECIMALS values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Reward if useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Feb 2008 03:22:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table/m-p/3533602#M850116</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-29T03:22:44Z</dc:date>
    </item>
  </channel>
</rss>

