‎2007 May 15 2:34 PM
Hi All,
A simple question.
I am creating one table with table maintenance generator and also T code for it.
I need to apply logic that when i am enterting some data into table using that T code,
3 fields System date, Sytem time and user name should populate automatically.
please guide and tell the procedure.
Regards,
Rishi
‎2007 May 16 7:58 AM
Table of Contents
Let us consider a scenario, where a custom table has to be updated with the created/modified date and time.
The steps for implementing the same are given below:
Step1: Create a table ZTAB with the following fields:
field key key key key Dec text
MANDT X MANDT CLNT 3 0 Client
ZCTRY X LAND1 Char 3 Country Key
ZDATE X CDATE Dats 8 Creation/Change Date
Step 2: Create a TABLE MAINTENANCE GENERATOR FOR THE TABLE
Utilities-> Table Maintenance Generator.
Authorization Group: &NC&
Function group: Any suitable FC Eg: ZBC420XX
Maintenance type: Two Step
Maint. screen no: Overview screen 8005
Single screen 8006
Create.
Step 3: Create table Maintenance Events
Table Maintenance Environment->Modification->Events-> New Entries
You can see list of events.
Select 05 for an event for Creating a new entry.
This event will be triggered while creating a new entry in SM30 or using the TCODE.
Form Name: AT_NEWENTRY (Enter key)
Double Click on the editor.
form at_newentry.
Ztab-ZCTRY = India.
Ztab-ZCDATE = sy-datum.
endform.
Create another event: 02 for After Save
FORM after_save.
Ztab-mandt = extract+0(3).
Ztab-ZCTRY = extract+3(3)..
Ztab-ZCDATE = sy-datum.
MODIFY ztab.
ENDFORM. "after_save
Step 4: Create Transaction Code.
Go to SE93.
Transcation code: ZTAB
Transaction text Test Table Maintenance Events
Transaction: SM30, Skip first Screen
Default Values:
VIEWNAME ZTAB
UPDATE X
After this when you execute the tcode ZTAB, and create a new entry, it will update the system date and time in the tabel ZTAB.
Moreover if any of the data entries are changed, it will update with the new entries.
All sorts of validations of the entries is also possible through this event creation.
Reward points if useful.
Regards,
SaiRam
‎2007 May 15 2:38 PM
‎2007 May 15 2:38 PM
Create table Maintenance Events
Table Maintenance Environment->Modification->Events-> New Entries
This event will be triggered while creating a new entry in SM30 or using the TCODE.
Form Name: AT_NEWENTRY (Enter key)
Double Click on the editor.
form at_newentry.
Ztab-ZCOUNTRY = India.
Ztab-ZCREATEDATE = sy-datum.
Ztab-ZCREATETIME = sy-uzeit.
endform.
Create another event: 02 for After Save
FORM after_save.
Ztab-mandt = extract+0(3).
Ztab-ZCOUNTRY = extract+3(3)..
Ztab-ZCREATEDATE = sy-datum.
Ztab-ZCREATETIME = sy-uzeit.
MODIFY ztab.
ENDFORM. "after_save
Reward Points if it is useful
Thanks
Seshu
‎2011 Jul 20 5:42 PM
Create another event: 02 for After Save
FORM after_save.
Ztab-mandt = extract+0(3).
Ztab-ZCOUNTRY = extract+3(3)..
Ztab-ZCREATEDATE = sy-datum.
Ztab-ZCREATETIME = sy-uzeit.
MODIFY ztab.
ENDFORM. "after_save
What is the purpose of this Ztab-mandt = extract+0(3) statement ??
‎2011 Jul 20 6:39 PM
it is to assign the value of the mandt field to the correct field from the extract. ie.. the extract will have all the data together as a string. so you have to manually assign the first 3 characters to the mandt field and so on.
‎2007 May 15 2:48 PM
Hi Rishi,
go to se54..give table/view name... environment->events..
click new entries..select '01' ..before saving to database...
give a form name ...and then click on 'SAVE'...
then click on the editor...
and write this logic there..TOTAL will be the table with the whole contents.. EXTRACT will have the newly added entries after clicking on the new entries...
LOOP AT TOTAL.
LS_VIEW = TOTAL.
CASE <ACTION>.
WHEN NEUER_EINTRAG.
LS_VIEW-CREATED_BY = SY-UNAME.
LS_VIEW-CREATED_ON = SY-DATUM.
LS_VIEW-CREATED_TIME = SY-UZEIT.
LS_VIEW-UPDATED_BY = SY-UNAME.
LS_VIEW-UPDATED_DATE = SY-DATUM.
LS_VIEW-UPDATED_TIME = SY-UZEIT.
READ TABLE EXTRACT WITH KEY <VIM_XTOTAL_KEY>.
IF SY-SUBRC EQ 0.
L_INDEX = SY-TABIX.
ELSE.
CLEAR L_INDEX.
ENDIF.
*-- make desired changes to the line total
TOTAL = LS_VIEW.
MODIFY TOTAL.
CHECK L_INDEX GT 0.
EXTRACT = TOTAL.
MODIFY EXTRACT INDEX L_INDEX.
ENDCASE.
ENDLOOP.
Regards,
Vidya.
‎2007 May 16 7:58 AM
Table of Contents
Let us consider a scenario, where a custom table has to be updated with the created/modified date and time.
The steps for implementing the same are given below:
Step1: Create a table ZTAB with the following fields:
field key key key key Dec text
MANDT X MANDT CLNT 3 0 Client
ZCTRY X LAND1 Char 3 Country Key
ZDATE X CDATE Dats 8 Creation/Change Date
Step 2: Create a TABLE MAINTENANCE GENERATOR FOR THE TABLE
Utilities-> Table Maintenance Generator.
Authorization Group: &NC&
Function group: Any suitable FC Eg: ZBC420XX
Maintenance type: Two Step
Maint. screen no: Overview screen 8005
Single screen 8006
Create.
Step 3: Create table Maintenance Events
Table Maintenance Environment->Modification->Events-> New Entries
You can see list of events.
Select 05 for an event for Creating a new entry.
This event will be triggered while creating a new entry in SM30 or using the TCODE.
Form Name: AT_NEWENTRY (Enter key)
Double Click on the editor.
form at_newentry.
Ztab-ZCTRY = India.
Ztab-ZCDATE = sy-datum.
endform.
Create another event: 02 for After Save
FORM after_save.
Ztab-mandt = extract+0(3).
Ztab-ZCTRY = extract+3(3)..
Ztab-ZCDATE = sy-datum.
MODIFY ztab.
ENDFORM. "after_save
Step 4: Create Transaction Code.
Go to SE93.
Transcation code: ZTAB
Transaction text Test Table Maintenance Events
Transaction: SM30, Skip first Screen
Default Values:
VIEWNAME ZTAB
UPDATE X
After this when you execute the tcode ZTAB, and create a new entry, it will update the system date and time in the tabel ZTAB.
Moreover if any of the data entries are changed, it will update with the new entries.
All sorts of validations of the entries is also possible through this event creation.
Reward points if useful.
Regards,
SaiRam
‎2007 May 16 8:56 AM
Dear Rishi,
Goto table --> Utlities --> Table maintanence generator --> Environment --> Modification --> Events.
Select the event 01 (Before saving the data in the database)--> Enter some name example USER_NAME_TIME. There is one more column Editor near to that click that.
Write the code inside that.
Example:
ztest-user_name = sy-uname.
ztest-time = sy-uzeit.
Thanks & Regards
Sastry
‎2011 Jul 20 6:49 PM
Please note the date of the original post before posting your question.