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 Auto populate username in 'z' table field

Former Member
0 Kudos

Folks,

How to populate username, date, time automatically in 'z' table.

Thanks,

Younus

3 REPLIES 3

Former Member

Go to Se11...

utilities ---table maintance generator..

environmentmodification-events...

give t=01

ur form routine name.and create an include insidet the routine

write ur code inside the include

  • Local Declarations

DATA: lv_index TYPE sy-tabix, "Sy-index

lvo_ref TYPE REF TO data. "Data type

FIELD-SYMBOLS : <fs> TYPE ANY, "To access work areas

<fv> TYPE ANY. "To access total fields.

  • If saving is to be done and save is not aborted.

IF vim_abort_saving IS INITIAL.

  • Check if the Values are updated using SM30 transaction.

IF sy-tcode = 'SM30'.

  • Total table contains the list of all entries in the table

LOOP AT total.

  • Check if there is any action that is associated with the entry

CASE <action>.

  • If it is a newly created entry Update the created date and created

  • User name to the entry.

WHEN neuer_eintrag.

  • Created by

ASSIGN COMPONENT 'ERNAM'

OF STRUCTURE <vim_total_struc> TO <fv>.

<fv> = sy-uname.

  • Creation date

ASSIGN COMPONENT 'ERDAT'

OF STRUCTURE <vim_total_struc> TO <fv>.

<fv> = sy-datum.

  • Changed by

ASSIGN COMPONENT 'AENAM'

OF STRUCTURE <vim_total_struc> TO <fv>.

CLEAR <fv>.

  • Changed on

ASSIGN COMPONENT 'AEDAT'

OF STRUCTURE <vim_total_struc> TO <fv>.

CLEAR <fv>.

READ TABLE extract WITH KEY <vim_total_key>.

IF sy-subrc EQ 0.

lv_index = sy-tabix.

ENDIF.

  • Modify the total table.

MODIFY total.

  • Modify the extract table which contains the list of entries to be

  • modified with the updated total entry.

CHECK lv_index GT 0.

<vim_extract_struc> = <vim_total_struc>.

MODIFY extract INDEX lv_index.

  • If the entry is having some change update the modified date and

  • modified user name in the corresponding record.

WHEN aendern.

  • Changed by

ASSIGN COMPONENT 'AENAM'

OF STRUCTURE <vim_total_struc> TO <fv>.

<fv> = sy-uname.

  • Changed on

ASSIGN COMPONENT 'AEDAT'

OF STRUCTURE <vim_total_struc> TO <fv>.

<fv> = sy-datum.

READ TABLE extract WITH KEY <vim_total_key>.

IF sy-subrc EQ 0.

lv_index = sy-tabix.

ENDIF.

  • Modify total table

MODIFY total.

CHECK lv_index GT 0.

<vim_extract_struc> = <vim_total_struc>.

MODIFY extract INDEX lv_index.

WHEN OTHERS.

ENDCASE.

ENDLOOP.

sy-subrc = 0.

ENDIF.

ENDIF.

Regards

Ansari

Former Member
0 Kudos

Hi,

As mentioned above by Mohammad, create a form routine for 01 & 05 events.

write code like below, inside the form that will do

Ztablename-username = sy-uname.

Ztablename-date = sy-date

Thanks,

Muthu

former_member188685
Active Contributor
0 Kudos

check this thread