<?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: Select statement to get date ranges in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484264#M1556621</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 try to get the records of P9759 for Unpaid Leave  , you'll have the Begda and Endda dates.&lt;/P&gt;&lt;P&gt;     Now read the structure P9759 with Endda = Begda - 1. This should give record before the Unpaid Leave , and&lt;/P&gt;&lt;P&gt;     if you read the structure P9759 with begda = Endda + 1 , this will give record after the Unpaid Leave if it's present.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srini.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Dec 2010 04:41:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-12-09T04:41:17Z</dc:date>
    <item>
      <title>Select statement to get date ranges</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484263#M1556620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a specific HR programming which I use typical PNP selection need to grab all records of infotype 0 'unpaid leave'.&lt;/P&gt;&lt;P&gt;Below is my statement to grab all these:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET pernr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*-- Processing&lt;/P&gt;&lt;P&gt;  PROVIDE * FROM p0001 "ename pernr&lt;/P&gt;&lt;P&gt;          &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FROM p0000 "massn massg begda endda&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FROM p9759 "pernr begda endda compplan&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    BETWEEN pn-begda AND pn-endda.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    MOVE p0001-ename     TO ls_data-ename.&lt;/P&gt;&lt;P&gt;    MOVE p0001-pernr     TO ls_data-pernr.&lt;/P&gt;&lt;P&gt;    MOVE p0000-massn     TO ls_data-massn.&lt;/P&gt;&lt;P&gt;    MOVE p0000-massg     TO ls_data-massg.&lt;/P&gt;&lt;P&gt;    MOVE p0000-begda     TO ls_data-begda00.&lt;/P&gt;&lt;P&gt;    MOVE p0000-endda     TO ls_data-endda00.&lt;/P&gt;&lt;P&gt;    MOVE p9759-pernr     TO ls_data-pernr9759.&lt;/P&gt;&lt;P&gt;    MOVE p9759-begda     TO ls_data-begda9759.&lt;/P&gt;&lt;P&gt;    MOVE p9759-endda     TO ls_data-endda9759.&lt;/P&gt;&lt;P&gt;    MOVE p9759-compplan  TO ls_data-compplan.&lt;/P&gt;&lt;P&gt;    APPEND ls_data TO lt_data.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Find all infotypes 0000 records of type Unpaid Leave&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    DELETE lt_data WHERE massn &amp;lt;&amp;gt; 'ZA'.&lt;/P&gt;&lt;P&gt;    DELETE lt_data WHERE pernr9759 is INITIAL.&lt;/P&gt;&lt;P&gt;    CLEAR ls_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDPROVIDE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END-OF-SELECTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;1. How you use select/loop the table lt_data to find a 9759 record existed before the Unpaid Leave but does not exist after the Unpaid Leave?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 02:25:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484263#M1556620</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2010-12-09T02:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement to get date ranges</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484264#M1556621</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 try to get the records of P9759 for Unpaid Leave  , you'll have the Begda and Endda dates.&lt;/P&gt;&lt;P&gt;     Now read the structure P9759 with Endda = Begda - 1. This should give record before the Unpaid Leave , and&lt;/P&gt;&lt;P&gt;     if you read the structure P9759 with begda = Endda + 1 , this will give record after the Unpaid Leave if it's present.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srini.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 04:41:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484264#M1556621</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-09T04:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement to get date ranges</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484265#M1556622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srini Vas,&lt;/P&gt;&lt;P&gt;Thanks for reply. According to you:&lt;/P&gt;&lt;P&gt;First try to get the records of P9759 for Unpaid Leave , you'll have the Begda and Endda dates.&lt;/P&gt;&lt;P&gt;Now read the structure P9759 with Endda = Begda - 1. This should give record before the Unpaid Leave , and&lt;/P&gt;&lt;P&gt;if you read the structure P9759 with begda = Endda + 1 , this will give record after the Unpaid Leave if it's present.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Okie, the first part "get the records of P9759 for Unpaid Leave , you'll have the Begda and Endda dates" is done by my provide...endprovide statement shown in my first post, am i right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your info, my lt_data is type table of the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF data_struct,&lt;/P&gt;&lt;P&gt;         ename     TYPE p0001-ename,&lt;/P&gt;&lt;P&gt;         pernr     TYPE p0001-pernr,&lt;/P&gt;&lt;P&gt;         massn     TYPE p0000-massn,     " action&lt;/P&gt;&lt;P&gt;         massg     TYPE p0000-massg,     " reason&lt;/P&gt;&lt;P&gt;         begda00   TYPE p0000-begda,&lt;/P&gt;&lt;P&gt;         endda00   TYPE p0000-endda,&lt;/P&gt;&lt;P&gt;         exception TYPE string,          " exception type&lt;/P&gt;&lt;P&gt;         pernr9759 TYPE p9759-pernr,&lt;/P&gt;&lt;P&gt;         begda9759 TYPE p9759-begda,     " begda&lt;/P&gt;&lt;P&gt;         endda9759 TYPE p9759-endda,     " endda&lt;/P&gt;&lt;P&gt;         compplan  TYPE p9759-compplan,  " compensation plan&lt;/P&gt;&lt;P&gt;       END OF data_struct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the 2nd part, "read the structure P9759 with Endda = Begda - 1.", do you mean as below:&lt;/P&gt;&lt;P&gt;LOOP AT lt_data INTO ls_data.&lt;/P&gt;&lt;P&gt;    IF ls_data-endda9759 &amp;lt; ls_data-begda00.&lt;/P&gt;&lt;P&gt;      APPEND ls_data to lt_before.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    CLEAR ls_data.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the 3rd part, "read the structure P9759 with begda = Endda + 1" do you mean as below:&lt;/P&gt;&lt;P&gt;LOOP AT lt_before INTO ls_data.&lt;/P&gt;&lt;P&gt;    IF ls_data-begda9759 &amp;gt; ls_data-endda00.&lt;/P&gt;&lt;P&gt;       APPEND ls_data to lt_after.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    CLEAR ls_data.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Siong Chao on Dec 9, 2010 7:23 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 06:06:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484265#M1556622</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2010-12-09T06:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement to get date ranges</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484266#M1556623</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;    Your initial provide .. endprovide might not get all the records as the records are filtered on begda , endda.&lt;/P&gt;&lt;P&gt;    Its better to get the records from the structure P9759   ..  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    loop at P9759 where endda &amp;lt; Unpaid_record-begda.&lt;/P&gt;&lt;P&gt;*get these records.&lt;/P&gt;&lt;P&gt;   endloop.&lt;/P&gt;&lt;P&gt;similarly get the other records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srini.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 08:04:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484266#M1556623</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-09T08:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement to get date ranges</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484267#M1556624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srini Vas,&lt;/P&gt;&lt;P&gt;loop at P9759 where endda &amp;lt; Unpaid_record-begda.&lt;/P&gt;&lt;P&gt;*get these records.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let say I do not want to use provide...endprovide. I use the PNP as my LDB for my report which will have a selection screen which user can enter the pernr and dates like begda and endda. So based on this, how do you first get to the Unpaid_record-begda?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: the unpaid_record came from p0000 with a certain action, let assume = 'ZZ'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 14:38:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484267#M1556624</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2010-12-09T14:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement to get date ranges</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484268#M1556625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not entirely sure if this is what you need, but I would do the following (getting rid of the PROVIDE statements):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Loop through the table for infotype 0000 and selecting only the records that define "unpaid leaves".&lt;/P&gt;&lt;P&gt;2. Calculate the date before the beggining of the unpaid leave as p0000-begda - 1.&lt;/P&gt;&lt;P&gt;3. Look for a record of the infotype 9759 in that date.&lt;/P&gt;&lt;P&gt;4. Calculate the date after the end of the unpaid leave as p0000-endda + 1.&lt;/P&gt;&lt;P&gt;5. Look for a record of the infotipe 9759 in that date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code would be as following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT zsdn.

TABLES: pernr.

TYPE-POOLS: abap.

INFOTYPES: 0000,
           9759.

DATA: lv_date_before_unpaid_leave TYPE d,
      lv_record_before_unpaid_leave TYPE boolean,
      lv_date_after_unpaid_leave TYPE d,
      lv_record_after_unpaid_leave TYPE boolean.

START-OF-SELECTION.
  GET pernr.
    LOOP AT p0000 WHERE massn = 'ZA'. " Action for the unpaid leave
      lv_date_before_unpaid_leave = p0000-begda - 1.
      rp-provide-from-frst p9759 space lv_date_before_unpaid_leave lv_date_before_unpaid_leave.
      IF pnp-sw-found = 0.
        lv_record_before_unpaid_leave = abap_true.
      ELSE.
        lv_record_before_unpaid_leave = abap_false.
      ENDIF.
      lv_date_after_unpaid_leave = p0000-endda + 1.
      rp-provide-from-frst p9759 space lv_date_after_unpaid_leave lv_date_after_unpaid_leave.
      IF pnp-sw-found = 0.
        lv_record_after_unpaid_leave = abap_true.
      ELSE.
        lv_record_after_unpaid_leave = abap_false.
      ENDIF.
      IF lv_record_before_unpaid_leave = abap_true AND
         lv_record_after_unpaid_leave = abap_false.
        " Do whatever you want here
      ENDIF.
    ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 16:53:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-to-get-date-ranges/m-p/7484268#M1556625</guid>
      <dc:creator>jpoloteijeiro</dc:creator>
      <dc:date>2010-12-09T16:53:01Z</dc:date>
    </item>
  </channel>
</rss>

