<?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 Changed Date - Changed By in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367337#M1039255</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;&lt;/P&gt;&lt;P&gt;I have created a custom table. In addition to custom fields, we need "changed Date(AEDTM)" and "changed by" fields in this table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;User is not going to fill these fields, system should fill this automatically. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example: whenever a new record is created(using sm31), changed date = today's date, and changed by = user name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to achieve this? &lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Aug 2008 09:48:42 GMT</pubDate>
    <dc:creator>kammaje_cis</dc:creator>
    <dc:date>2008-08-28T09:48:42Z</dc:date>
    <item>
      <title>Changed Date - Changed By</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367337#M1039255</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;&lt;/P&gt;&lt;P&gt;I have created a custom table. In addition to custom fields, we need "changed Date(AEDTM)" and "changed by" fields in this table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;User is not going to fill these fields, system should fill this automatically. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example: whenever a new record is created(using sm31), changed date = today's date, and changed by = user name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to achieve this? &lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2008 09:48:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367337#M1039255</guid>
      <dc:creator>kammaje_cis</dc:creator>
      <dc:date>2008-08-28T09:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Changed Date - Changed By</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367338#M1039256</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;In my opinion, you can do that with events :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using SE11 then Utility -&amp;gt; maintenance screen generator &lt;/P&gt;&lt;P&gt;Then via the menu -&amp;gt; environment -&amp;gt; modifications -&amp;gt; events&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There you have to choose the appropriate event and define a FORM routine. This FORM routine is created within a form-include of the function group containing the maintenance dialogs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to set the default value at the start of the dialog and when the user creates new entries you will need events '21' (fill hidden fields) and '05' (creating a new entry).&lt;/P&gt;&lt;P&gt;For the events define a form routine within an include in your function group. There you have access to the structure of the view (e.g. z_tabl_view). There you fill z_tabl_view-column = &amp;lt;fixed value&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For checking data before saving you will need event 01 (before saving the data in the database).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For detailed information please refer to the SAP online documentation:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_erp2005vp/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erwan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2008 09:52:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367338#M1039256</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-28T09:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Changed Date - Changed By</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367339#M1039257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Table maintenance screen generator&lt;/P&gt;&lt;P&gt;environment -&amp;gt; modifications -&amp;gt; events&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write your code here&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2008 10:20:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367339#M1039257</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-28T10:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Changed Date - Changed By</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367340#M1039258</link>
      <description>&lt;P&gt;Using the Table Maintenance event you can populate those fields.&lt;/P&gt;&lt;P&gt;You need to use the event 01&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FORM f_actions_event_01.
IF vim_abort_saving IS INITIAL.
  * Update Change history fields
  INCLUDE ZZFSAI086_UPD_CHG_HSTY .
ENDIF.
ENDFORM. " f_actions_event_01
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; include code&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; DATA:
  lv_index1 TYPE sy-tabix, "Index for Table 'TOTAL'
  lv_index2 TYPE sy-tabix, "Index for Table 'EXTRACT'
  lr_data   TYPE REF TO data, "Reference Data object
  lv_action TYPE char1, "Variable for View action
  lv_mark   TYPE char1. "Variable for View mark


FIELD-SYMBOLS:
  &amp;lt;lf_fval&amp;gt;  TYPE any, "For field value
  &amp;lt;ls_str&amp;gt;   TYPE any, "For data string
  &amp;lt;ls_xfrom&amp;gt; TYPE x, "Hexadecimal value of from value
  &amp;lt;ls_xto&amp;gt;   TYPE x. "Hexadecimal value of to value


* Dynamic creation of data object using the table name
CREATE DATA lr_data TYPE (x_header-viewname).
ASSIGN lr_data-&amp;gt;* TO &amp;lt;ls_str&amp;gt;.


CLEAR: lv_index1, lv_index2, lr_data.
* Looping through all the records in the M.View
LOOP AT total.
  CLEAR lv_index1.
  lv_index1 = sy-tabix.
  READ TABLE extract WITH KEY total.
  IF sy-subrc EQ 0.
    lv_index2 = sy-tabix.
  ELSE.
    CLEAR lv_index2.
  ENDIF.
  ASSIGN total TO &amp;lt;ls_xfrom&amp;gt; CASTING.
  ASSIGN &amp;lt;ls_str&amp;gt; TO &amp;lt;ls_xto&amp;gt; CASTING.
  &amp;lt;ls_xto&amp;gt; = &amp;lt;ls_xfrom&amp;gt;.
  MOVE:
  &amp;lt;action&amp;gt; TO lv_action,
  &amp;lt;mark&amp;gt; TO lv_mark.
  CASE &amp;lt;action&amp;gt;.
    WHEN neuer_eintrag. " New entry
* If there is a new entry fill created by / date
      ASSIGN COMPONENT 'CRNAM' OF STRUCTURE &amp;lt;ls_str&amp;gt; TO &amp;lt;lf_fval&amp;gt;.
      IF sy-subrc = 0.
        &amp;lt;lf_fval&amp;gt; = sy-uname.
      ENDIF.
      ASSIGN COMPONENT 'CRDAT' OF STRUCTURE &amp;lt;ls_str&amp;gt; TO &amp;lt;lf_fval&amp;gt;.
      IF sy-subrc = 0.
        &amp;lt;lf_fval&amp;gt; = sy-datum.
      ENDIF.
* If Changed by / date have to be blanked out if e.g. an entry is
      copied
     assign component 'AENAM' of structure &amp;lt;ls_str&amp;gt; to &amp;lt;lf_fval&amp;gt;.
      IF sy-subrc = 0.
        CLEAR &amp;lt;lf_fval&amp;gt;.
      ENDIF.


      ASSIGN COMPONENT 'AEDAT' OF STRUCTURE &amp;lt;ls_str&amp;gt; TO &amp;lt;lf_fval&amp;gt;.
      IF sy-subrc = 0.
        CLEAR &amp;lt;lf_fval&amp;gt;.
      ENDIF.


    WHEN aendern. "Updated entry
* Update to an existing entry fill in changed by / date
      ASSIGN COMPONENT 'AENAM' OF STRUCTURE &amp;lt;ls_str&amp;gt; TO &amp;lt;lf_fval&amp;gt;.
      IF sy-subrc = 0.
        &amp;lt;lf_fval&amp;gt; = sy-uname.
      ENDIF.


      ASSIGN COMPONENT 'AEDAT' OF STRUCTURE &amp;lt;ls_str&amp;gt; TO &amp;lt;lf_fval&amp;gt;.
      IF sy-subrc = 0.
        &amp;lt;lf_fval&amp;gt; = sy-datum.
      ENDIF.
  ENDCASE.


*(make desired changes to the line total)


* Changes to be incorporated only when update or new entry.
  CHECK &amp;lt;action&amp;gt; EQ aendern OR &amp;lt;action&amp;gt; EQ neuer_eintrag.
  CLEAR: total,extract.
  ASSIGN &amp;lt;ls_str&amp;gt; TO &amp;lt;ls_xfrom&amp;gt; CASTING.
  ASSIGN total TO &amp;lt;ls_xto&amp;gt; CASTING.
  &amp;lt;ls_xto&amp;gt; = &amp;lt;ls_xfrom&amp;gt;.
  MOVE :
  lv_action TO &amp;lt;action&amp;gt;,
  lv_mark TO &amp;lt;mark&amp;gt;.
  CONCATENATE total lv_action lv_mark INTO total.
  MODIFY total FROM total INDEX lv_index1.
* modify extract if this is necessary
  CHECK lv_index2 GT 0.
  extract = total.
  MODIFY extract FROM extract INDEX lv_index2.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Aug 2008 10:39:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367340#M1039258</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-28T10:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Changed Date - Changed By</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367341#M1039259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijaya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for the solution. It is working well &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Dec 2010 14:23:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367341#M1039259</guid>
      <dc:creator>former_member206485</dc:creator>
      <dc:date>2010-12-23T14:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Changed Date - Changed By</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367342#M1039260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijaya,&lt;/P&gt;&lt;P&gt;just like to thank you for the codes. It works perfectly for me. keep up the good work. Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Edwin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 May 2011 09:19:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/changed-date-changed-by/m-p/4367342#M1039260</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-06T09:19:21Z</dc:date>
    </item>
  </channel>
</rss>

