<?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: Dynamic SQL in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813120#M348416</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rebeka,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the below mentioned code is the same requirement you are looking for. If not the Explain your requirement in details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using parameters statements instead of select-options then you need to use Where condition like this in select statement(WHERE kunnr = s_kunnr).&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;DATA: Begin of itab occurs10,&lt;/P&gt;&lt;P&gt;             kunnr type kunnr,&lt;/P&gt;&lt;P&gt;             land1 type land1_gp,&lt;/P&gt;&lt;P&gt;             ort01 type ort01_gp,&lt;/P&gt;&lt;P&gt;             pstlz type pstlz,&lt;/P&gt;&lt;P&gt;           end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options: s_kunnr for kna1-kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;SELECT       kunnr land1 ort01 pstlz &lt;/P&gt;&lt;P&gt;FROM          kna1&lt;/P&gt;&lt;P&gt;INTO TABLE itab&lt;/P&gt;&lt;P&gt;WHERE       kunnr in s_kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ashven&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 21 Jan 2007 12:02:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-01-21T12:02:26Z</dc:date>
    <item>
      <title>Dynamic SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813117#M348413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to define a dynamic select statment: Only the selection fields are suppose to be dynamic, meaning "select var_dynfld1 var_dynfld2 from kna1 where kunnr = 222".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone can send me the exact syntax ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Rebeka&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jan 2007 11:38:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813117#M348413</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-21T11:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813118#M348414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;code sample&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT YDYNSEL
       NO STANDARD PAGE HEADING.


data: itab type standard table of sflight .
TYPE-POOLS RSFS.

DATA SELECT_FIELDS TYPE RSFS_FIELDS.


data: FIELDLISTS TYPE RSFS_TAB_FIELDS,
           FLAG_READ.

  IF FLAG_READ = SPACE.
    FIELDLISTS-TABLENAME = 'SFLIGHT'.
    READ TABLE SELECT_FIELDS WITH KEY FIELDLISTS-TABLENAME
                             INTO FIELDLISTS.
    append 'CARRID' to FIELDLISTS-fields .
    append 'CONNID' to FIELDLISTS-fields .
    FLAG_READ = 'X'.
  ENDIF.




SELECT (FIELDLISTS-FIELDS)
up to 10 rows from sflight into corresponding fields of table itab .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jan 2007 11:54:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813118#M348414</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2007-01-21T11:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813119#M348415</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;How to write dynamic where condition you can find in documentation:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3990358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3990358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;in section "Specifying Columns Dynamically"&lt;/P&gt;&lt;P&gt;There is also small example there...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Krzys&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jan 2007 11:57:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813119#M348415</guid>
      <dc:creator>krzysztof_konitz4</dc:creator>
      <dc:date>2007-01-21T11:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813120#M348416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rebeka,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the below mentioned code is the same requirement you are looking for. If not the Explain your requirement in details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using parameters statements instead of select-options then you need to use Where condition like this in select statement(WHERE kunnr = s_kunnr).&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;DATA: Begin of itab occurs10,&lt;/P&gt;&lt;P&gt;             kunnr type kunnr,&lt;/P&gt;&lt;P&gt;             land1 type land1_gp,&lt;/P&gt;&lt;P&gt;             ort01 type ort01_gp,&lt;/P&gt;&lt;P&gt;             pstlz type pstlz,&lt;/P&gt;&lt;P&gt;           end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options: s_kunnr for kna1-kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;SELECT       kunnr land1 ort01 pstlz &lt;/P&gt;&lt;P&gt;FROM          kna1&lt;/P&gt;&lt;P&gt;INTO TABLE itab&lt;/P&gt;&lt;P&gt;WHERE       kunnr in s_kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ashven&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jan 2007 12:02:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813120#M348416</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-21T12:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813121#M348417</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;If the question is answered, can you mark the thread as answered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jan 2007 12:09:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813121#M348417</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2007-01-21T12:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813122#M348418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me be more exact &amp;amp; specific:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an internal table which I want to read from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that I want to set my key fields according to some dynamic conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;BEGIN OF ITAB OCCURS 0,&lt;/P&gt;&lt;P&gt;  KUNNR LIKE KNA1-KUNNR,&lt;/P&gt;&lt;P&gt;  MATNR LIKE MARA-MATNR,&lt;/P&gt;&lt;P&gt;  SUM     LIKE BSEG-WRBTR,&lt;/P&gt;&lt;P&gt;END OF ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At first time I want to write READ TABLE ITAB WITH KEY KUNNR = 2&lt;/P&gt;&lt;P&gt;and after that: READ TABLE ITAB WITH KEY MATNR = 2.&lt;/P&gt;&lt;P&gt;I want the KUNNR and MATNR to be defined as variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jan 2007 12:24:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813122#M348418</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-21T12:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813123#M348419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data: fnam(40) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move: 'KUNNR' to fnam .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab with key (fnam) = 2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear fnam .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move: 'MATNR' to fnam .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab with key (fnam) = 2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jan 2007 12:27:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/1813123#M348419</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2007-01-21T12:27:57Z</dc:date>
    </item>
  </channel>
</rss>

