<?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 select sql statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235084#M771895</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi currently i have a problem with the sql statement.&lt;/P&gt;&lt;P&gt;The field name and the table name of the sql statement will depend on what the user input. We need to find out what records is in tableA columnA and not in tableB columnB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is my sql statement: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM (TABLEA) INTO TABLE ITABA&lt;/P&gt;&lt;P&gt;WHERE (COLUMNA) &lt;/P&gt;&lt;P&gt;NOT IN ( SELECT (COLUMNB) FROM (TABLEB) ).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;=============================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ColumnA = "the user input the field name"&lt;/P&gt;&lt;P&gt;TableA = " the user input the table name"&lt;/P&gt;&lt;P&gt;TableB = " the user input the table name"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem lies at the WHERE clause. The system generate a sql error which says "unable to find the field name".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Jan 2008 02:25:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-03T02:25:52Z</dc:date>
    <item>
      <title>Dynamic select sql statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235084#M771895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi currently i have a problem with the sql statement.&lt;/P&gt;&lt;P&gt;The field name and the table name of the sql statement will depend on what the user input. We need to find out what records is in tableA columnA and not in tableB columnB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is my sql statement: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM (TABLEA) INTO TABLE ITABA&lt;/P&gt;&lt;P&gt;WHERE (COLUMNA) &lt;/P&gt;&lt;P&gt;NOT IN ( SELECT (COLUMNB) FROM (TABLEB) ).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;=============================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ColumnA = "the user input the field name"&lt;/P&gt;&lt;P&gt;TableA = " the user input the table name"&lt;/P&gt;&lt;P&gt;TableB = " the user input the table name"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem lies at the WHERE clause. The system generate a sql error which says "unable to find the field name".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2008 02:25:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235084#M771895</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-03T02:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select sql statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235085#M771896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Refer class CL_ABAP_TYPEDESCR.&lt;/P&gt;&lt;P&gt;It is used to create the dynamic SQL.&lt;/P&gt;&lt;P&gt;Also search the forums. There are already lots of thread on this topic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2008 02:30:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235085#M771896</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-03T02:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select sql statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235086#M771897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi thanks, but how do i use the class?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2008 02:44:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235086#M771897</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-03T02:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select sql statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235087#M771898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jocelyn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following is the code which i used for a dynamic SQL Query and it worked for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA where_tab(25) OCCURS 5 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA p_kunnar like vbak-kunnr.&lt;/P&gt;&lt;P&gt;CONDENSE p_kunnar NO-GAPS.&lt;/P&gt;&lt;P&gt;IF p_kunnar NE ''.&lt;/P&gt;&lt;P&gt;      APPEND 'vbak~kunnr = p_kunnar' TO where_tab.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;SELECT DISTINCT vbeln&lt;/P&gt;&lt;P&gt;FROM vbak&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE gi_vtab&lt;/P&gt;&lt;P&gt;WHERE vbak-vkorg = p_vkorg  AND&lt;/P&gt;&lt;P&gt;vbak-vtweg = p_vtweg  AND&lt;/P&gt;&lt;P&gt;vbak-auart = 'LP'     AND&lt;/P&gt;&lt;P&gt;(where_tab).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regds&lt;/P&gt;&lt;P&gt;Satya&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Provide points if the answer is helpful..*&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2008 11:47:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235087#M771898</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-03T11:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select sql statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235088#M771899</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;Check the following code:&lt;/P&gt;&lt;P&gt;For dynamic table name.... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_select_dynamic_database . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA wa TYPE scarr. &lt;/P&gt;&lt;P&gt;DATA name(10) TYPE c VALUE 'SCARR'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * &lt;/P&gt;&lt;P&gt;INTO wa &lt;/P&gt;&lt;P&gt;FROM (name) CLIENT SPECIFIED &lt;/P&gt;&lt;P&gt;WHERE mandt = '000'. &lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-carrname. &lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----- &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For dynamic field list &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_select_dynamic_columns . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE STANDARD TABLE OF spfli, &lt;/P&gt;&lt;P&gt;            wa LIKE LINE OF itab. &lt;/P&gt;&lt;P&gt;DATA: line(72) TYPE c, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;list LIKE TABLE OF line(72). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line = ' CITYFROM CITYTO '. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND line TO list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (list) &lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;FROM spfli. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa. &lt;/P&gt;&lt;P&gt;WRITE: / wa-cityfrom, wa-cityto. &lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2008 11:51:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-sql-statement/m-p/3235088#M771899</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-03T11:51:40Z</dc:date>
    </item>
  </channel>
</rss>

