<?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: Duration Overlap Calculation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450926#M1741413</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jog, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this logic. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a function module C14B_DATE_TIME_COMPARE , which outputs value X if datetime1 &amp;lt; datetime2.&amp;nbsp; In the code below, COMPARE refers to this FM. Duration refers to your&amp;nbsp; FM to calculate duration&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Also another FM is there SD_CAL_DURATION_FROM_DATETIME which outputs X if datetime 2 &amp;lt; datetime 1. The following logic is based on the first FM, if you want to use the second FM, change logic accordingly.&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose your internal table is itab. &lt;/P&gt;&lt;P&gt;ws1 like line of itab,&lt;/P&gt;&lt;P&gt;ws2 like line of itab.&lt;/P&gt;&lt;P&gt;res1 type c, res2 type c, res3 type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read itab index 1 into ws1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into ws2. &lt;/P&gt;&lt;P&gt;* When the start date of current record is between start and end date of first record&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare (ws2-stdt, ws2-sttm, ws1-endt, ws1-entm) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res1 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-stdt,ws1-sttm, ws2-std, ws2-sttm)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res2 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res1&amp;nbsp; = 'X' and res2 = 'X'.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " Start date of current record is between the start and end date of first record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-enddt,ws1-enddtm, ws2-enddt,ws2-endtm)&amp;nbsp;&amp;nbsp;&amp;nbsp; " get end date of overlap. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res3 = 'X &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws2-stdt,ws2sttm, ws1-enddt,ws1-endtm.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws2-stdt, ws2-sttm, ws2-enddt, ws2-endt.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modify itab index sy-tabix from ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear : res1, res2, res3, ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* When enddate of current record is betwen start and end date of first record. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare (ws2-enddt, ws2-endtm, ws1-endt, ws1-entm) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res1 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-stdt,ws1-sttm, ws2-enddt, ws2-endtm)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res2 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res1&amp;nbsp; = 'X' and res2 = 'X'.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " End date of current record is between the start and end date of first record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-stdt,ws1-sttm, ws2-stdt,ws2-sttm)&amp;nbsp;&amp;nbsp;&amp;nbsp; " get start date of overlap. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res3 = 'X &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws1-stdt,ws1sttm, ws2-enddt,ws2-endtm.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws2-stdt, ws2-sttm, ws2-enddt, ws2-endtm.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modify itab index sy-tabix from ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear : res1, res2, res3, ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dont forget to clear the flags and ws2 after each loop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Susmitha Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 May 2013 09:23:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-05-23T09:23:10Z</dc:date>
    <item>
      <title>Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450918#M1741405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 6 fields in an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. STDT - Start Date&lt;/P&gt;&lt;P&gt; 2. STTM - Start Time&lt;/P&gt;&lt;P&gt; 3. ENDT - End Date&lt;/P&gt;&lt;P&gt; 4. ENTM - End Time&lt;/P&gt;&lt;P&gt;5. DURN - Duration &lt;/P&gt;&lt;P&gt;6. OVRLP -Overlap &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have calculated DURN through FM 'SWI_DURATION_DETERMINE' (using fields 1 to 4).&lt;/P&gt;&lt;P&gt;Then I have sorted the table in descending order of DURN.&lt;/P&gt;&lt;P&gt;Now the highest duration record is in the 1st line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;The requirement now is&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000; font-size: 12pt;"&gt;I need to calculate the duration-overlap of each line item &lt;SPAN style="text-decoration: underline;"&gt;with reference to the 1st record,&lt;/SPAN&gt; into field OVRLP&amp;nbsp; (in hours or minutes or seconds).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Your help is requested.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;kind regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Jogeswara Rao&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 06:43:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450918#M1741405</guid>
      <dc:creator>jogeswararao_kavala</dc:creator>
      <dc:date>2013-05-23T06:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450919#M1741406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you mean by duration overlap? &lt;/P&gt;&lt;P&gt;Does the timing and date also have coincide with the first record or you look only at the duration?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 07:06:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450919#M1741406</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-23T07:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450920#M1741407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is no role of DURN field, further after sorting.&lt;/P&gt;&lt;P&gt;I need the timing overlap of each line item with reference to the first one.&lt;/P&gt;&lt;P&gt;Perhaps I should have used the title as ' &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Timing Overlap&lt;/STRONG&gt;&lt;/SPAN&gt;'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you Susmitha for response.&lt;/P&gt;&lt;P&gt;-Jogeswara Rao&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 07:23:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450920#M1741407</guid>
      <dc:creator>jogeswararao_kavala</dc:creator>
      <dc:date>2013-05-23T07:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450921#M1741408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think by Overlap you mean how much time is shared by interval of first record and interval of n'th record.&lt;/P&gt;&lt;P&gt;Assuming LT_REC is internal table, LS_REC is structure/workarea, LS_FIRST is another structure meant to store first record data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SWI_DURATION_CALCULATE gives 0 if end date/time is less than start date/time.&lt;/P&gt;&lt;P&gt;Think of first interval as (2....7) and second interval as (4....12).&lt;/P&gt;&lt;P&gt;Durations between start of one interval and end of other interval would be 10 and 3.&lt;/P&gt;&lt;P&gt;I believe you are considering 3 to be the overlap value in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a pseudocode.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Read table LT_REC into LS_FIRST index 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Loop at LT_REC into LS_REC.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Calculate duration between (LS_REC-STDT, LS_REC-STTM, LS_FIRST-ENDT, LS_FIRST-ENTM).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Calculate duration between (LS_FIRST-STDT, LS_FIRST-STTM, LS_REC-ENDT, LS_REC-ENTM).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Out of 2 calculated durations, whichever is lower should be the overlap. Store in it LS_REC-OVRLP.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;If the invervals don't overlap, lower calculated duration would be 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Modify LT_REC using LS_REC.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Endloop.&lt;/SPAN&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the pseudocode is incorrect or does not make sense, let us know by example data what overlap value are you expecting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 07:54:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450921#M1741408</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-23T07:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450922#M1741409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about (in pseudo-code):&lt;/P&gt;&lt;P&gt;OVRLP(I1, I2) = DURATION( MAX(START_I1, START_I2) ... MIN(END_I1, END_I2) )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 08:01:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450922#M1741409</guid>
      <dc:creator>former_member184455</dc:creator>
      <dc:date>2013-05-23T08:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450923#M1741410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i dont know if this is your query , but from what i understand...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;overlap line n --&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check start date + start time of line n if greater than end date + end time of line1 , overlap = 0&lt;BR /&gt;if not then overlap = end date + end time of line 1 - start date + start time of line n...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use F.M. SD_CALC_DURATION_FROM_DATETIME to calculate the difference in hours , it also sets a flag to X if the hours are negative , so you can put your first condition of overlap being 0 if the flag is set(i.e. start date and time is after end date and time of the first line)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 08:21:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450923#M1741410</guid>
      <dc:creator>former_member193464</dc:creator>
      <dc:date>2013-05-23T08:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450924#M1741411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 9pt;"&gt;Thank you Manish,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN lang="EN" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: #333333;"&gt;I feel you've understood the issue. We are studying the code. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN lang="EN" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: #333333;"&gt;But the example you've give above the code ( 2..7 &amp;amp; 4....12), I could not follow.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN lang="EN" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: #333333;"&gt;So to clear any understanding-gap, I am attaching the graphical representation of my requirement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN lang="EN" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: #333333;"&gt;Hope this helps you to understand the requirement fully.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN lang="EN" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: #333333;"&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/221144" width="450" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 08:53:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450924#M1741411</guid>
      <dc:creator>jogeswararao_kavala</dc:creator>
      <dc:date>2013-05-23T08:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450925#M1741412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok so you can have overlap at the starting also , sorry skipped my mind...&lt;BR /&gt;so based on the&lt;STRONG&gt; start date + time &lt;/STRONG&gt;, you need to find where does it lie&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)less than &lt;STRONG&gt;start date +time of 1st item&lt;/STRONG&gt;,then &lt;STRONG&gt;check end date +time should lie in between &lt;/STRONG&gt;, else over lap 0.&lt;BR /&gt;2)in between start date + time and end date + time of&amp;nbsp; 1st&amp;nbsp; item&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;3)greater than end date + time of 1st item ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for the third case its 0,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for the second case, and first case, &lt;BR /&gt;when passing date to FM sd_calc_duration_from_datetime&lt;BR /&gt;keep variable lv_to_date, lv_from_date , same for time&lt;/P&gt;&lt;P&gt;if its in the first case -&amp;nbsp; if it satisfies the above condition&lt;/P&gt;&lt;P&gt;lv_from_date = start date of 1st item &lt;/P&gt;&lt;P&gt;IF end date + time of nth line item is GT end date + time of 1st.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_to_date =&amp;nbsp; end date of 1st item (same for time).&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;lv_to_date = end date of nth item.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;Now pass this to the FM&lt;/P&gt;&lt;P&gt;Similar condition check you need to do for second case... I hope it make sense...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 09:18:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450925#M1741412</guid>
      <dc:creator>former_member193464</dc:creator>
      <dc:date>2013-05-23T09:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450926#M1741413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jog, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this logic. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a function module C14B_DATE_TIME_COMPARE , which outputs value X if datetime1 &amp;lt; datetime2.&amp;nbsp; In the code below, COMPARE refers to this FM. Duration refers to your&amp;nbsp; FM to calculate duration&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Also another FM is there SD_CAL_DURATION_FROM_DATETIME which outputs X if datetime 2 &amp;lt; datetime 1. The following logic is based on the first FM, if you want to use the second FM, change logic accordingly.&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose your internal table is itab. &lt;/P&gt;&lt;P&gt;ws1 like line of itab,&lt;/P&gt;&lt;P&gt;ws2 like line of itab.&lt;/P&gt;&lt;P&gt;res1 type c, res2 type c, res3 type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read itab index 1 into ws1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into ws2. &lt;/P&gt;&lt;P&gt;* When the start date of current record is between start and end date of first record&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare (ws2-stdt, ws2-sttm, ws1-endt, ws1-entm) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res1 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-stdt,ws1-sttm, ws2-std, ws2-sttm)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res2 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res1&amp;nbsp; = 'X' and res2 = 'X'.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " Start date of current record is between the start and end date of first record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-enddt,ws1-enddtm, ws2-enddt,ws2-endtm)&amp;nbsp;&amp;nbsp;&amp;nbsp; " get end date of overlap. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res3 = 'X &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws2-stdt,ws2sttm, ws1-enddt,ws1-endtm.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws2-stdt, ws2-sttm, ws2-enddt, ws2-endt.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modify itab index sy-tabix from ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear : res1, res2, res3, ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* When enddate of current record is betwen start and end date of first record. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare (ws2-enddt, ws2-endtm, ws1-endt, ws1-entm) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res1 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-stdt,ws1-sttm, ws2-enddt, ws2-endtm)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res2 = result. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res1&amp;nbsp; = 'X' and res2 = 'X'.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " End date of current record is between the start and end date of first record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare(ws1-stdt,ws1-sttm, ws2-stdt,ws2-sttm)&amp;nbsp;&amp;nbsp;&amp;nbsp; " get start date of overlap. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if res3 = 'X &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws1-stdt,ws1sttm, ws2-enddt,ws2-endtm.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws2-overlap = duration(ws2-stdt, ws2-sttm, ws2-enddt, ws2-endtm.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modify itab index sy-tabix from ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear : res1, res2, res3, ws2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dont forget to clear the flags and ws2 after each loop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Susmitha Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 09:23:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450926#M1741413</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-23T09:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450927#M1741414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have edited the code a little. Let me know if its giving the right output. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 10:06:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450927#M1741414</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-23T10:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450928#M1741415</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;check FM TTE_CHK_DTRNG_DATETAB_2(checl Funtion Group for more FMs) along with FM's mentioned by Susmitha.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prabhu &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 10:24:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450928#M1741415</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-23T10:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Duration Overlap Calculation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450929#M1741416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Susmitha, You're Great !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 May 2013 10:59:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/duration-overlap-calculation/m-p/9450929#M1741416</guid>
      <dc:creator>jogeswararao_kavala</dc:creator>
      <dc:date>2013-05-23T10:59:51Z</dc:date>
    </item>
  </channel>
</rss>

