<?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: date operations in internal table. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-operations-in-internal-table/m-p/1429647#M205556</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;There are (at least) two options to extend your version:&lt;/P&gt;&lt;P&gt;a) you need to display separately: add two new fields for sorting-date and sorting-time. Fill these fields from chdate / crdat, chtime / crtime, depending which is filled. Then sort and delete the sorting fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;b) you just need to display one date / time. Add before SORT&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab_new.
if itab_new-chdate is initial.
  itab_new-chdate = itab_new-crdat.
  itab_new-chtime = itab_new-crtime.
  modify itab_new.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Jun 2006 14:06:55 GMT</pubDate>
    <dc:creator>christian_wohlfahrt</dc:creator>
    <dc:date>2006-06-26T14:06:55Z</dc:date>
    <item>
      <title>date operations in internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-operations-in-internal-table/m-p/1429646#M205555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear firends....&lt;/P&gt;&lt;P&gt;         first I need to tell thank you srinivas for your presious help to solve my most currently changed record finding problem..  now i am aske to add two more fields crdat and crtim if the chdat and chtim is not there with the idnumbers then crdat and crtim should be considered as crdat and crtim is creation date creation time.. so it is alway there... i have tryied with the srinivas's given code but i am faild to get the proper values....(after adding two more fields)... i am giving you all the details for the refrence and i am changing the scenario according to my new problem. please help me&lt;/P&gt;&lt;P&gt;regards naim&lt;/P&gt;&lt;P&gt;the new scenario:&lt;/P&gt;&lt;P&gt;id idnumber chdate chtime crdat     crtim &lt;/P&gt;&lt;P&gt;1 123456 20060606 135312  00000000  00000&lt;/P&gt;&lt;P&gt;2 123456 20060606 135900  00000000  00000&lt;/P&gt;&lt;P&gt;3 123456 00000000 000000  20060607  13000&lt;/P&gt;&lt;P&gt;4 123457 00000000 000000  20060605  12000    &lt;/P&gt;&lt;P&gt;5 123457 20060606 142500  00000000  00000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the above scenario i must keep in my mind that the most recently changed record is identical to its idnumber i can say that:&lt;/P&gt;&lt;P&gt;the record should be fetched this way&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id idnumber chdate chtime crdat      crtim&lt;/P&gt;&lt;P&gt;3 123456 00000000 000000  20060607  13000&lt;/P&gt;&lt;P&gt;5 123457 20060606 142500  00000000  00000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because here the id 3 is the most recently changed in the idnumber 123456&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where id 5 is the most recently changed in the idnumber 123457&lt;/P&gt;&lt;P&gt;__code given by srinivas_________________________________&lt;/P&gt;&lt;P&gt;it works perfect in chdat and chtim but i am failed to modify it according to new scenario....&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF itab_type,&lt;/P&gt;&lt;P&gt;       id TYPE i,&lt;/P&gt;&lt;P&gt;       idnumber TYPE i,&lt;/P&gt;&lt;P&gt;       chdate   LIKE sy-datum,&lt;/P&gt;&lt;P&gt;       chtime   LIKE sy-uzeit.&lt;/P&gt;&lt;P&gt;tyPES: END OF itab_type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE TABLE OF itab_type WITH HEADER LINE,      &lt;/P&gt;&lt;P&gt;itab_new TYPE TABLE OF itab_type WITH HEADER LINE,      prev_rec TYPE itab_type.&lt;/P&gt;&lt;P&gt;DATA: v_id TYPE i.&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.  &lt;/P&gt;&lt;P&gt;itab-id       = 1.  &lt;/P&gt;&lt;P&gt;itab-idnumber = 123456.  &lt;/P&gt;&lt;P&gt;itab-chdate   = '20060606'.  &lt;/P&gt;&lt;P&gt;itab-chtime   = '135312'.  &lt;/P&gt;&lt;P&gt;APPEND itab. CLEAR itab.  &lt;/P&gt;&lt;P&gt;itab-id       = 2.  &lt;/P&gt;&lt;P&gt;itab-idnumber = 123456.  &lt;/P&gt;&lt;P&gt;itab-chdate   = '20060606'.  &lt;/P&gt;&lt;P&gt;itab-chtime   = '135900'.  &lt;/P&gt;&lt;P&gt;APPEND itab. CLEAR itab.  &lt;/P&gt;&lt;P&gt;itab-id       = 3.  &lt;/P&gt;&lt;P&gt;itab-idnumber = 123456.  &lt;/P&gt;&lt;P&gt;itab-chdate   = '20060606'.  &lt;/P&gt;&lt;P&gt;itab-chtime   = '132300'.  &lt;/P&gt;&lt;P&gt;APPEND itab. CLEAR itab.  &lt;/P&gt;&lt;P&gt;itab-id       = 4.  &lt;/P&gt;&lt;P&gt;itab-idnumber = 123457.  &lt;/P&gt;&lt;P&gt;itab-chdate   = '20060606'.  &lt;/P&gt;&lt;P&gt;itab-chtime   = '140000'.  &lt;/P&gt;&lt;P&gt;APPEND itab. CLEAR itab.  &lt;/P&gt;&lt;P&gt;itab-id       = 5.  &lt;/P&gt;&lt;P&gt;itab-idnumber = 123457.  &lt;/P&gt;&lt;P&gt;itab-chdate   = '20060606'.  &lt;/P&gt;&lt;P&gt;itab-chtime   = '142500'.  &lt;/P&gt;&lt;P&gt;APPEND itab. CLEAR itab.  &lt;/P&gt;&lt;P&gt;itab_new[] = itab[].  &lt;/P&gt;&lt;P&gt;SORT itab_new BY idnumber ASCENDING                   chdate DESCENDING                  &lt;/P&gt;&lt;P&gt; chtime DESCENDING.  &lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber.  &lt;/P&gt;&lt;P&gt;LOOP AT itab_new.   &lt;/P&gt;&lt;P&gt; WRITE:/ itab_new-id,  &lt;/P&gt;&lt;P&gt;          itab_new-idnumber, &lt;/P&gt;&lt;P&gt;           itab_new-chdate, &lt;/P&gt;&lt;P&gt;           itab_new-chtime.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jun 2006 22:20:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-operations-in-internal-table/m-p/1429646#M205555</guid>
      <dc:creator>naimkhans_babi</dc:creator>
      <dc:date>2006-06-22T22:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: date operations in internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-operations-in-internal-table/m-p/1429647#M205556</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;There are (at least) two options to extend your version:&lt;/P&gt;&lt;P&gt;a) you need to display separately: add two new fields for sorting-date and sorting-time. Fill these fields from chdate / crdat, chtime / crtime, depending which is filled. Then sort and delete the sorting fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;b) you just need to display one date / time. Add before SORT&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab_new.
if itab_new-chdate is initial.
  itab_new-chdate = itab_new-crdat.
  itab_new-chtime = itab_new-crtime.
  modify itab_new.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 14:06:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-operations-in-internal-table/m-p/1429647#M205556</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2006-06-26T14:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: date operations in internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-operations-in-internal-table/m-p/1429648#M205557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Niam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think u should add 2 addtional field in the Internal table.&lt;/P&gt;&lt;P&gt;Check the initial value for the code and sort as per the new field added.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id idnumber chdate chtime crdat crtim -&lt;/P&gt;&lt;HR originaltext="---" /&gt;&lt;P&gt;date ---time&lt;/P&gt;&lt;P&gt;1 123456 20060606 135312 00000000 00000&lt;/P&gt;&lt;P&gt;2 123456 20060606 135900 00000000 00000&lt;/P&gt;&lt;P&gt;3 123456 00000000 000000 20060607 13000&lt;/P&gt;&lt;P&gt;4 123457 00000000 000000 20060605 12000 &lt;/P&gt;&lt;P&gt;5 123457 20060606 142500 00000000 00000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) check initial and modify table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab.

  if itab-chdate is not initial.
     itab-date = itab-chdate.
     itab-time = itab-chtime.
  else.
     itab-date = itab-crdat.
     itab-time = itab-crtim.   
  endif.

  Modify itab.

Endloop.

SORT itab BY idnumber ASCENDING date DESCENDING time DESCENDING. 
DELETE ADJACENT DUPLICATES FROM itab COMPARING idnumber.[
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is ur previous problem solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 14:20:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-operations-in-internal-table/m-p/1429648#M205557</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T14:20:19Z</dc:date>
    </item>
  </channel>
</rss>

