<?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 Open SQL statment for Update flag based on Date in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-statment-for-update-flag-based-on-date/m-p/5370843#M1235556</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;&lt;/P&gt;&lt;P&gt;I am trying to write an Open SQL statement to update a flag in a table. Table Ztable1 with fields Sr.No, Flag, Datefrom, DateTo. i would like to update Flag entry in the table only if today falls in between Datefrom &amp;amp; Dateto. I can satisfy the above requirement using the following ABAP code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lv_timestamp TYPE timestamp,
      lv_today LIKE adr2-valid_from,
      tz TYPE timezone.

CONVERT DATE sy-datlo TIME sy-timlo INTO TIME STAMP lv_timestamp
  TIME ZONE tz.
lv_today = lv_timestamp.

update ztable1 set flag = 'X' where lv_today BETWEEN datefrom and dateto.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the issue is that, DateFrom &amp;amp; DateTo contains space aswell Dates. Datefrom can be space if it is start of Time (01010001) and also DateTo can be space if it is End of time (31129999). Which means that if DateFrom is space, then it should treated as 01010001, simlarly DateTo is space, then it should be 31129999. How can i write the if else cases within where clauses. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know Decode statement in Native sql programming, but that won't fit for Opensql in ABAP. Also, because of huge entries in database, i cannot read entries, manupulate &amp;amp; then update.&lt;/P&gt;&lt;P&gt;How can i enhance the same above Update statement to cater this need. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please advise. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance. &lt;/P&gt;&lt;P&gt;Greetings, Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Apr 2009 06:22:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-07T06:22:47Z</dc:date>
    <item>
      <title>Open SQL statment for Update flag based on Date</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-statment-for-update-flag-based-on-date/m-p/5370843#M1235556</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;&lt;/P&gt;&lt;P&gt;I am trying to write an Open SQL statement to update a flag in a table. Table Ztable1 with fields Sr.No, Flag, Datefrom, DateTo. i would like to update Flag entry in the table only if today falls in between Datefrom &amp;amp; Dateto. I can satisfy the above requirement using the following ABAP code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lv_timestamp TYPE timestamp,
      lv_today LIKE adr2-valid_from,
      tz TYPE timezone.

CONVERT DATE sy-datlo TIME sy-timlo INTO TIME STAMP lv_timestamp
  TIME ZONE tz.
lv_today = lv_timestamp.

update ztable1 set flag = 'X' where lv_today BETWEEN datefrom and dateto.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the issue is that, DateFrom &amp;amp; DateTo contains space aswell Dates. Datefrom can be space if it is start of Time (01010001) and also DateTo can be space if it is End of time (31129999). Which means that if DateFrom is space, then it should treated as 01010001, simlarly DateTo is space, then it should be 31129999. How can i write the if else cases within where clauses. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know Decode statement in Native sql programming, but that won't fit for Opensql in ABAP. Also, because of huge entries in database, i cannot read entries, manupulate &amp;amp; then update.&lt;/P&gt;&lt;P&gt;How can i enhance the same above Update statement to cater this need. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please advise. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance. &lt;/P&gt;&lt;P&gt;Greetings, Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 06:22:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-statment-for-update-flag-based-on-date/m-p/5370843#M1235556</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T06:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: Open SQL statment for Update flag based on Date</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-statment-for-update-flag-based-on-date/m-p/5370844#M1235557</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;first fetch records in to internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ranges: r_range for sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into wa.&lt;/P&gt;&lt;P&gt;if wa-validfrom is initial.&lt;/P&gt;&lt;P&gt;wa-validfrom =  (here u pass valid from date).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;elseif wa-validto is initial&lt;/P&gt;&lt;P&gt;wa-validto = 99991231.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;r_range-low = wa-validfrom&lt;/P&gt;&lt;P&gt;r_range-high = wa-validto&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*check here current date is falling in interval. if its fall between ranges update flas in work area and *modify you internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-datum in r_range.&lt;/P&gt;&lt;P&gt;wa-flag = 'x'.&lt;/P&gt;&lt;P&gt;modify itab from wa.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh r_range.&lt;/P&gt;&lt;P&gt;clear wa-flag.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Finally update your ztable&lt;/P&gt;&lt;P&gt;modify ztable from table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Peranandam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 07:00:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-statment-for-update-flag-based-on-date/m-p/5370844#M1235557</guid>
      <dc:creator>Peranandam</dc:creator>
      <dc:date>2009-04-07T07:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Open SQL statment for Update flag based on Date</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-statment-for-update-flag-based-on-date/m-p/5370845#M1235558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;resolved myself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jul 2011 17:40:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-statment-for-update-flag-based-on-date/m-p/5370845#M1235558</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-13T17:40:12Z</dc:date>
    </item>
  </channel>
</rss>

