<?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 query not working in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876430#M1324205</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, i don;t know: haven't used it like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, my advice stands: print out the content of gv_query and you'll find a few more errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jul 2009 12:24:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-07-20T12:24:16Z</dc:date>
    <item>
      <title>dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876427#M1324202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;im using a dynamic query to put in an internal table but its not working&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you see whats wrong in that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gv_query = ' au~uname AS OTCTUSERNM,'.&lt;/P&gt;&lt;P&gt;CONCATENATE gv_query  'a1&lt;SUB&gt;object' '.' 'a1&lt;/SUB&gt;field'  ' AS  0TCTAUTH'  INTO gv_query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONCATENATE gv_query  'au~to_dat AS OTCTADTO, OTCTOBJNM, ' INTO gv_query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (gv_query)&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE gi_ds1&lt;/P&gt;&lt;P&gt;  FROM agr_users AS au INNER JOIN&lt;/P&gt;&lt;P&gt;  agr_1251 AS a1&lt;/P&gt;&lt;P&gt;  ON au&lt;SUB&gt;agr_name = a1&lt;/SUB&gt;agr_name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:11:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876427#M1324202</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876428#M1324203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;'.'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's it doing there? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You better print out the value in gv_query to see how it actually looks like. That might give you some hints as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:18:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876428#M1324203</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876429#M1324204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the '.' is the concatenation of 2 fields. Is it the correct way of merging 2 fields in a dynamic query?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:22:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876429#M1324204</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876430#M1324205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, i don;t know: haven't used it like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, my advice stands: print out the content of gv_query and you'll find a few more errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:24:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876430#M1324205</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876431#M1324206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I am not wrong then '.' is not required I hope so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;gv_query = 'au~uname AS OTCTUSERNM'.
CONCATENATE gv_query 'a1~object a1~field AS 0TCTAUTH' INTO gv_query SEPARATED BY space.

CONCATENATE gv_query 'au~to_dat AS OTCTADTO' INTO gv_query SEPARATED BY space.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shiba Prasad Dutta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:29:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876431#M1324206</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876432#M1324207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following are the observations:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. gv_query = ' au~uname AS OTCTUSERNM,'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; In above string i think you want to use uname column as OTCTUSERNM and it is correct&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. CONCATENATE gv_query 'a1&lt;SUB&gt;object' '.' 'a1&lt;/SUB&gt;field' ' AS 0TCTAUTH' INTO&lt;/P&gt;&lt;P&gt;    gv_query.&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; In statement 2 above I am not able to understand whey 'a1&lt;SUB&gt;object' '.' 'a1&lt;/SUB&gt;field'  this is incorrect.&lt;/P&gt;&lt;P&gt;     Also '.' (dot) in not required in query it will be either '~' or 'AS' as valid chars.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. CONCATENATE gv_query 'au~to_dat AS OTCTADTO, OTCTOBJNM, ' INTO gv_query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; In statement 3 above whey OTCTOBJNM is used there is no such column exit in AGR_USERS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. SELECT DISTINCT (gv_query)&lt;/P&gt;&lt;P&gt;    INTO CORRESPONDING FIELDS OF TABLE gi_ds1&lt;/P&gt;&lt;P&gt;    FROM agr_users AS au INNER JOIN&lt;/P&gt;&lt;P&gt;    agr_1251 AS a1&lt;/P&gt;&lt;P&gt;    ON au&lt;SUB&gt;agr_name = a1&lt;/SUB&gt;agr_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; In above statement a1 is used as alias for AGR_USERS then why it it not there in statement 3 where instead au is used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Normarlly query is like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'&amp;lt;alias1&amp;gt;&lt;SUB&gt;&amp;lt;col_name1&amp;gt; as &amp;lt;col_desc1&amp;gt;, &amp;lt;alias2&amp;gt;&lt;/SUB&gt;&amp;lt;col_name2&amp;gt; as &amp;lt;col_desc2&amp;gt;......up to n cols&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case it is possible that alias1 and alias2 are used for different table in case of joins and for same table in case of self joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, You can only define colums in dynamic query those are available in the table from which we have to select the data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Augustin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:29:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876432#M1324207</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876433#M1324208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Augustarian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need the concatenation of the two fields as OCTCTAUTH  i.e a1&lt;SUB&gt;object.a1&lt;/SUB&gt;field&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:40:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876433#M1324208</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876434#M1324209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Anjali,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two things:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. you want to contcatenate two columns and give them in query for fetching result which is impossible as &lt;/P&gt;&lt;P&gt;    ABAP sql require well formed SQL and concatenation is not allowed in query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. you want to concatenate output of two columsn so in that case first get values of both the fields in internal table and then &lt;/P&gt;&lt;P&gt;    either in SELECT..ENDSELECt or in internal table LOOP you can go on concatenating values for required column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, concatenating using "." is not allowed in ABAP query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It has nothing to do with dynamic query. if you try same thing using static query that will give you same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Augustin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:47:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876434#M1324209</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876435#M1324210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oh i see&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i didnt know concatenation is not allowed during dynamic query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in fact its because of the concatenation that i did a dynamic query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there other alternative or i should do a loop to concatenate the fields?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz advise&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 12:58:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876435#M1324210</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T12:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876436#M1324211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Anjali,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best practice in ABAP is to query the data into internal table and then process it in internal table loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you can do concatenation in loop it will be much faster than SELECT..ENDSELECT loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Augustin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2009 05:32:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876436#M1324211</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-21T05:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876437#M1324212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks a lot Augustin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 10:16:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-query-not-working/m-p/5876437#M1324212</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-23T10:16:39Z</dc:date>
    </item>
  </channel>
</rss>

