Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate date & time when user enter data for custom table in sm30

Former Member
0 Kudos

Can anyone tell me How to populate system date & time when user enter data for custom table in sm30..

Req is

i have custom table and using sm30 user can enter data.

after saving date i want to update date & time in table

Pls let me know where to write the code?

Thanks in Advance

1 ACCEPTED SOLUTION

Former Member

Did the code help? If so can you please close the issue?

Thanks,

Srinivas

12 REPLIES 12

Former Member
0 Kudos

You can activate the events in the TABLE MAINTENANCE (SE11), Miantenance --> Events. For this you can use event 002, before saving to the database.

In this event you can update the extra fields that you are talking about.

Regards

Ravi

Former Member
0 Kudos

Hii Suresh ,

check this

->Execute <b>SE54</b>

-> Enter your ZTABLE name.

-> Choose Change button.

-> In the next screen press F7.

-> In the popup that comes up choose the 1st option which suits best to ur case and then press enter.

-> Save the changes and the regenartion is complete.

Regards

Naresh

0 Kudos

You have to write the code in EVENT 01 in SE54 transaction. Go to SE54, enter your Ztable name and in the menu 'Environment-->Events'. Press 'ENTER' to go past the popup message. In the next screen, click on 'New Entries'. In the first column, enter 01 and in the next column give some name for your routine(say UPDATE_USER_DATE_TIME). Then click on the souce code icon that appears in blue at the end of the row. In the code, you need logic like below.


FORM update_user_date_time.

  DATA: f_index LIKE sy-tabix. 
  DATA: BEGIN OF l_total.
          INCLUDE STRUCTURE zztable.
  INCLUDE  STRUCTURE vimtbflags.
  DATA  END OF l_total.
  DATA: s_record TYPE zztable.

  LOOP AT total INTO l_total.
    IF l_total-vim_action = aendern OR
       l_total-vim_action = neuer_eintrag.
      MOVE-CORRESPONDING l_total TO s_record.
      s_record-zz_user = sy-uname.
      s_record-zz_date = sy-datum.
      s_record-zz_time = sy-uzeit.
      READ TABLE extract WITH KEY l_total.
      IF sy-subrc EQ 0.
        f_index = sy-tabix.
      ELSE.
        CLEAR f_index.
      ENDIF.
      MOVE-CORRESPONDING s_record TO l_total.
      MODIFY total FROM l_total.
      CHECK f_index GT 0.
      MODIFY extract INDEX f_index FROM l_total.
    ENDIF.
  ENDLOOP.

ENDFORM.                    " UPDATE_USER_DATE_TIME

Here ZZTABLE is the Z table and ZZ_USER, ZZ_DATE, and ZZ_TIME are the fields that are updated.

0 Kudos

thanks for everyone.given pts.

0 Kudos

Hello,

Sorry for bugging you, I saw in your posts that you have experience with Table maintenance events. I have problems understanding how to write the code for validation with event 01. The problem is that my system is Unicode, and if I try the example you posted here, I have the following short dump:

Runtime Error UC_OBJECTS_NOT_CONVERTIBLE

Date and Time 27.11.2006 15:13:08

ShrtText

Data objects in a Unicode program are not convertible.

Error analysis

The statement

"MOVE src TO dst"

requires the operands "dst" and "src" to be comvertible.

Since this statement occurs in a Unicode program, the special

convertibility rules for Unicode programs apply. In this case, the

following rules have been broken:

Thank you a lot, I am stuck with this problem for a few days!

0 Kudos

Hi Srinivas Adavi ,

I was facing the same problem for updating the date and time in table maintenance generator .I followed the steps of your coding and could get the desired results ..

Thanks ..

Former Member

Did the code help? If so can you please close the issue?

Thanks,

Srinivas

0 Kudos

hi sorry for late.i was away from office for couple of days.

Still unable to solve the issue.once completed i will close the issue.

Thanks

0 Kudos

Hi Srinivas,

i followed the steps what u mentioned.

i have created a subrotuine get_date_time in event01.

it showed a new include when i clik editor and wrote the code. i mentioned the form name and then code.

here why not i'm not getting subrouine name by default.

but while entering data thr sm30 its dumping as

call perform to a non-existent routine.its not able to recongise the form name.

Even its simple steps, i think somewhere i'm doing wrong.

Thanks

0 Kudos

Is the include inserted into your table maintenance function group main program? Just go and activate your table maintenance function group and see if that is what the issue is.

Subroutine names are defined by you, they are not defaulted.

0 Kudos

Thanks lot srinivas..it s working..sorry for late reply