<?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: Select query for picking data in a dynamic internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508288#M567123</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works only with C or N type fields... it doesnt work even with type STRING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Prax&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jul 2007 13:40:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-07-16T13:40:52Z</dc:date>
    <item>
      <title>Select query for picking data in a dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508286#M567121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;The code is :&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;p_table1 = itab_final-tabname1. 
        p_field1 = itab_final-fieldname1.          

        SELECT (p_field1) FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE &amp;lt;dyntable1&amp;gt;.       
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is working fine when the domain is of CHAR&lt;/P&gt;&lt;P&gt;The piece of code is not working where domain is DATS, CURR, DEC, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What shall I do so that it works for other domains also. Please its urgent......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;ERROR that came:&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An exception occurred. This exception will be dealt with in more detail &lt;/P&gt;&lt;P&gt;below. The exception, assigned to the class 'CX_SY_OPEN_SQL_DB', was not&lt;/P&gt;&lt;P&gt; caught, which                                                          &lt;/P&gt;&lt;P&gt; led to a runtime error. The reason for this exception is:              &lt;/P&gt;&lt;P&gt;The data read during a SELECT access could not be inserted into the     &lt;/P&gt;&lt;P&gt;target field.                                                           &lt;/P&gt;&lt;P&gt;Either conversion is not supported for the target field's type or the   &lt;/P&gt;&lt;P&gt;target field is too short to accept the value or the data are not in a  &lt;/P&gt;&lt;P&gt;form that the target field can accept&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2007 13:20:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508286#M567121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-16T13:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select query for picking data in a dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508287#M567122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Amit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I presume that you are using a field symbol to fetch that data.&lt;/P&gt;&lt;P&gt;You will have to use a conversion exit to convert to the correct data format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer to the code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;To find the correct Conversion exit for your field name :&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select statement to get the domain name of the field for identifying&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;the conversion exit&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT domname&lt;/P&gt;&lt;P&gt;     INTO&lt;/P&gt;&lt;P&gt;     v_domname FROM&lt;/P&gt;&lt;P&gt;     dd03l&lt;/P&gt;&lt;P&gt;     WHERE tabname = p_table AND fieldname = p_field .&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select statement to get the conversion exit name for the field&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT convexit&lt;/P&gt;&lt;P&gt;    INTO v_convexit&lt;/P&gt;&lt;P&gt;    FROM  dd01l&lt;/P&gt;&lt;P&gt;    WHERE domname = v_domname.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;To generate the correct Conversion exit name:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;CONCATENATE 'CONVERSION_EXIT_'&lt;/P&gt;&lt;P&gt;                   v_convexit&lt;/P&gt;&lt;P&gt;                   '_INPUT'&lt;/P&gt;&lt;P&gt;                   INTO&lt;/P&gt;&lt;P&gt;                   v_convexit.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;To call the conversion exit:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;PERFORM f_conversion_exit&lt;/P&gt;&lt;P&gt;                            USING p_table&lt;/P&gt;&lt;P&gt;                                  p_field&lt;/P&gt;&lt;P&gt;                                  v_convexit :&lt;/P&gt;&lt;P&gt;                           CHANGING Parameter1,&lt;/P&gt;&lt;P&gt;                                    parameter2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravish Garg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2007 13:32:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508287#M567122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-16T13:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Select query for picking data in a dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508288#M567123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works only with C or N type fields... it doesnt work even with type STRING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Prax&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2007 13:40:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508288#M567123</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-16T13:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Select query for picking data in a dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508289#M567124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

REPORT zpwtest .

*** Tables
DATA: lt_data TYPE REF TO data.
DATA: lt_fieldcatalog TYPE lvc_t_fcat.

data : p_field type string ,
       p_table type string .

*** Structure
DATA: ls_fieldcatalog TYPE lvc_s_fcat.

*** Data References
DATA: new_line TYPE REF TO data.

*** Field Symbols
FIELD-SYMBOLS: &amp;lt;fs_data&amp;gt; TYPE REF TO data,
               &amp;lt;fs_1&amp;gt; TYPE ANY TABLE,
               &amp;lt;fs_2&amp;gt;,
               &amp;lt;fs_3&amp;gt;.



ls_fieldcatalog-fieldname = 'MANDT'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.

ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
ls_fieldcatalog-inttype = 'C'. "Internal Type C-&amp;gt; Character
APPEND ls_fieldcatalog TO lt_fieldcatalog.

ls_fieldcatalog-fieldname = 'CONNID'.
ls_fieldcatalog-inttype = 'N'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.

ls_fieldcatalog-fieldname = 'FLDATE'.
ls_fieldcatalog-inttype = 'D'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.

ls_fieldcatalog-fieldname = 'PRICE'.
ls_fieldcatalog-inttype = 'P'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.

ls_fieldcatalog-fieldname = 'CURRENCY'.
ls_fieldcatalog-inttype = 'C'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.


ASSIGN lt_data TO &amp;lt;fs_data&amp;gt;.


CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
     EXPORTING
       it_fieldcatalog = lt_fieldcatalog
     IMPORTING
       ep_table = &amp;lt;fs_data&amp;gt;
     EXCEPTIONS
       generate_subpool_dir_full = 1
       OTHERS = 2
		.
IF sy-subrc &amp;lt;&amp;gt; 0.
ENDIF.



*** So &amp;lt;FS_1&amp;gt; now points to our dynamic internal table.
ASSIGN &amp;lt;fs_data&amp;gt;-&amp;gt;* TO &amp;lt;fs_1&amp;gt;.

*** Next step is to create a work area for our dynamic internal table.

CREATE DATA new_line LIKE LINE OF &amp;lt;fs_1&amp;gt;.

*** A field-symbol to access that work area
ASSIGN new_line-&amp;gt;*  TO &amp;lt;fs_2&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
p_field = 'mandt carrid connid fldate price currency' .
p_table = 'sflight' .

*** And to put the data in the internal table

SELECT (p_field)
  FROM (p_table)
  INTO CORRESPONDING FIELDS OF TABLE &amp;lt;fs_1&amp;gt;.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*** Access contents of internal table
LOOP AT &amp;lt;fs_1&amp;gt; ASSIGNING &amp;lt;fs_2&amp;gt;.

  ASSIGN COMPONENT 5 OF STRUCTURE &amp;lt;fs_2&amp;gt; TO &amp;lt;fs_3&amp;gt;.
  WRITE: / &amp;lt;fs_3&amp;gt;.
ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2007 16:10:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-for-picking-data-in-a-dynamic-internal-table/m-p/2508289#M567124</guid>
      <dc:creator>Pawan_Kesari</dc:creator>
      <dc:date>2007-07-16T16:10:23Z</dc:date>
    </item>
  </channel>
</rss>

