<?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: SUBSTRING Operation not working for AMDP SQL INNER JOIN Condition. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/substring-operation-not-working-for-amdp-sql-inner-join-condition/m-p/762716#M37130</link>
    <description>&lt;P&gt;My desperation to find the answer or my luck I don't know.&lt;/P&gt;&lt;P&gt;I just now found the Solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For INNER JOIN always use SUBSTR function instead of SUBSTRING.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;   METHOD get_changed_kunwe BY DATABASE PROCEDURE
                            FOR HDB
                            LANGUAGE SQLSCRIPT
                            OPTIONS READ-ONLY
                            USING cdhdr cdpos.
    ex_t_changd_kunwe = SELECT DISTINCT kunwe
                          FROM :im_t_zsd_catalog_pric AS zsd_catalog_pric
                         INNER JOIN cdhdr AS cdhdr
                            ON zsd_catalog_pric.kunwe = substr(cdhdr.objectid,1,10)
                         INNER JOIN cdpos AS cdpos
                            ON cdhdr.objectclas = cdpos.objectclas
                           AND cdhdr.objectid   = cdpos.objectid
                           AND cdhdr.changenr   = cdpos.changenr
                         WHERE cdhdr.mandant    = session_context('CLIENT')
                           AND cdhdr.objectclas = 'DEBI'
*                           AND (cdhdr.udate &amp;lt;= :im_from_date   --From Date
*                            AND cdhdr.utime &amp;lt;= :im_from_time   --From Time
*                            AND cdhdr.udate &amp;gt;= :im_to_date     --To Date
*                            AND cdhdr.utime &amp;gt;= :im_to_time)    --To Time
                            AND cdhdr.change_ind = 'U'
                            AND cdpos.tabname = 'KNA1'
                            AND cdpos.fname   = 'ZZ_CATALOG';
   ENDMETHOD."get_changed_kunwe&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Really strange, I was not even getting any Exceptions raised also for this, so it was difficult to find out that this was the actual error.&lt;/P&gt;&lt;P&gt;Hope it would be helpful for others.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sijin&lt;/P&gt;</description>
    <pubDate>Wed, 13 Feb 2019 15:09:39 GMT</pubDate>
    <dc:creator>Sijin_Chandran</dc:creator>
    <dc:date>2019-02-13T15:09:39Z</dc:date>
    <item>
      <title>SUBSTRING Operation not working for AMDP SQL INNER JOIN Condition.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/substring-operation-not-working-for-amdp-sql-inner-join-condition/m-p/762715#M37129</link>
      <description>&lt;P&gt;Hello ABAP Gurus,&lt;/P&gt;
  &lt;P&gt;I am not able to use SUBTRING SQL operation in WHERE Clause.&lt;/P&gt;
  &lt;P&gt;Attaching the screenshot of codes and Data,&lt;/P&gt;
  &lt;P&gt;Code snippet:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;   METHOD get_changed_kunwe BY DATABASE PROCEDURE
                            FOR HDB
                            LANGUAGE SQLSCRIPT
                            OPTIONS READ-ONLY
                            USING cdhdr cdpos.
    ex_t_changd_kunwe = SELECT DISTINCT kunwe
                          FROM :im_t_zsd_catalog_pric AS zsd_catalog_pric
                         INNER JOIN cdhdr AS cdhdr
                            ON zsd_catalog_pric.kunwe = substring(cdhdr.objectid,1,10)
                         INNER JOIN cdpos AS cdpos
                            ON cdhdr.objectclas = cdpos.objectclas
                           AND cdhdr.objectid   = cdpos.objectid
                           AND cdhdr.changenr   = cdpos.changenr
                         WHERE cdhdr.mandant    = session_context('CLIENT')
                           AND cdhdr.objectclas = 'DEBI'
*                           AND (cdhdr.udate &amp;lt;= :im_from_date   --From Date
*                            AND cdhdr.utime &amp;lt;= :im_from_time   --From Time
*                            AND cdhdr.udate &amp;gt;= :im_to_date     --To Date
*                            AND cdhdr.utime &amp;gt;= :im_to_time)    --To Time
                            AND cdhdr.change_ind = 'U'
                            AND cdpos.tabname = 'KNA1'
                            AND cdpos.fname   = 'ZZ_CATALOG';
   ENDMETHOD."get_changed_kunwe&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/273818-cdpos.png" /&gt;&lt;/P&gt;
  &lt;P&gt;KUNWE is of size 10 ( CHAR10 ) and CDHDR~OBJECTID CHAR90.&lt;/P&gt;
  &lt;P&gt;I have checked data is there for the remaining WHERE Clause.&lt;/P&gt;
  &lt;P&gt;Its the JOIN where its failing&lt;/P&gt;
  &lt;P&gt;Can anyone please suggest where I am missing.&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Sijin&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 14:58:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/substring-operation-not-working-for-amdp-sql-inner-join-condition/m-p/762715#M37129</guid>
      <dc:creator>Sijin_Chandran</dc:creator>
      <dc:date>2019-02-13T14:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTRING Operation not working for AMDP SQL INNER JOIN Condition.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/substring-operation-not-working-for-amdp-sql-inner-join-condition/m-p/762716#M37130</link>
      <description>&lt;P&gt;My desperation to find the answer or my luck I don't know.&lt;/P&gt;&lt;P&gt;I just now found the Solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For INNER JOIN always use SUBSTR function instead of SUBSTRING.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;   METHOD get_changed_kunwe BY DATABASE PROCEDURE
                            FOR HDB
                            LANGUAGE SQLSCRIPT
                            OPTIONS READ-ONLY
                            USING cdhdr cdpos.
    ex_t_changd_kunwe = SELECT DISTINCT kunwe
                          FROM :im_t_zsd_catalog_pric AS zsd_catalog_pric
                         INNER JOIN cdhdr AS cdhdr
                            ON zsd_catalog_pric.kunwe = substr(cdhdr.objectid,1,10)
                         INNER JOIN cdpos AS cdpos
                            ON cdhdr.objectclas = cdpos.objectclas
                           AND cdhdr.objectid   = cdpos.objectid
                           AND cdhdr.changenr   = cdpos.changenr
                         WHERE cdhdr.mandant    = session_context('CLIENT')
                           AND cdhdr.objectclas = 'DEBI'
*                           AND (cdhdr.udate &amp;lt;= :im_from_date   --From Date
*                            AND cdhdr.utime &amp;lt;= :im_from_time   --From Time
*                            AND cdhdr.udate &amp;gt;= :im_to_date     --To Date
*                            AND cdhdr.utime &amp;gt;= :im_to_time)    --To Time
                            AND cdhdr.change_ind = 'U'
                            AND cdpos.tabname = 'KNA1'
                            AND cdpos.fname   = 'ZZ_CATALOG';
   ENDMETHOD."get_changed_kunwe&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Really strange, I was not even getting any Exceptions raised also for this, so it was difficult to find out that this was the actual error.&lt;/P&gt;&lt;P&gt;Hope it would be helpful for others.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sijin&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 15:09:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/substring-operation-not-working-for-amdp-sql-inner-join-condition/m-p/762716#M37130</guid>
      <dc:creator>Sijin_Chandran</dc:creator>
      <dc:date>2019-02-13T15:09:39Z</dc:date>
    </item>
  </channel>
</rss>

