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: 

Set default value in field of table

arpit_shah
Contributor
0 Kudos
8,037

Hi,

How to set system default value in field of table.

like zusnam - it will autimatically store current user id (sy-uname).

zdatum - it will store current date (sy-datum).

Regards,

Arpit

1 ACCEPTED SOLUTION

Former Member
0 Kudos
987

Hi,

You can add this logic for updation in the table maintenance events.

Table maintenance->Modifications->Events.

Add the logic for updation of system fields in Event 01-Before Save or 05-Create new entry based on your requirement.

Thanks

Shiva

11 REPLIES 11

Former Member
0 Kudos
988

Hi,

You can add this logic for updation in the table maintenance events.

Table maintenance->Modifications->Events.

Add the logic for updation of system fields in Event 01-Before Save or 05-Create new entry based on your requirement.

Thanks

Shiva

0 Kudos
987

Hi Shiva,

Thanks for reply,

but is it possible to set system variable in dictionary it self, instead of coding in events of table maintenance generator.

Regards,

Arpit

0 Kudos
987

Hi Arpit,

As far as i know, you cannot do that...

Regards

Shiva

0 Kudos
987

Hi Arpita,

I think when we click on the new entries, the date field should be fillied by current date.

If your requirement as the above, we can achieve the solution as below.

Goto the se80 -> enter the Function Group(Which is created through the Table Maintanence) -> Click on the Screens -> Select the Maintain View : Detail Screen (Your Table Name) -> Create a New Module in the PBO -> (Your Table Name) - date = Sy-datum. -> save and activate.

Let me know If you any queries.

--

Shyam.

0 Kudos
987

Hi Arpit,

You have to write code for that as mentioned earlier by Shiva.

There is no other way as far i know.

Regards

Sandipan

Former Member
0 Kudos
987

Hi , It all depend upon how r u planning to populate values in this tabvle.

If u will always do it through abap code then you can hard coed the logic to get the values form system variables and populate them in those fields.

If you are planning to enter the values using TMG then you can have a routine method writtenon Table maintainance SAVE event and write above logic there.

Hope this is helpful.

Regards,

Uma Dave

Former Member
0 Kudos
987

Hi Arpit,

This is possible only either through the PBO module of that screen or by using the Events in Table Maintenance.

you can use the event Create new entry-05.

Regards,

Rahul Girdhar

0 Kudos
987

Hi ,

Only way is to use database events - either 05 ( creating new entries ) or 12 ( fill hidden fields ) can be used.

Regards,

Deepthi

Former Member
0 Kudos
987

Suppose you have following fields to be filled automatically :

USER-NAME

SY-DATE

SY-TIME

Then go to UTILITIES> TMG>Environment>Modification>Event

Select Even 05 (Create new Entry)

And write code inside that, as below :

TABLE_NAME- USER_NAME = SY-UNAME

TABLE_NAME-SY_DATE = SY-DATUM

TABLE_NAME-SY_TIME = SY_UZEIT.

Former Member
0 Kudos
987

Hi Arpit,

To set default value to table fields like date , time or username , here are the steps given below :-

1. Create table (Eg. Ztable) having required fields (Eg. Mandt , kunnr , erdat ) . Give required Technical Settings and activate It .

2. Now Go to UTILITIES->TABLE MAINTENANCE GENERATOR . t

Former Member
987

Hi Arpit,

To set default values to table fields like date , time or username , here are the steps given below :-

1. Create table (Eg. Ztable) having required fields (Eg. Mandt , kunnr , erdat ) . Give required Technical Settings and activate It .

2. Now Go to UTILITIES->TABLE MAINTENANCE GENERATOR . This will take you to maintenance dialog screen.

Here pass this value to fields :-

Authorization Group = &NC&.

Function Group = Can give table name (i.e Ztable)

Maintenance type = ONE STEP

Main. Screen No . = any value .

After that Click on create button .

3. Go to ENVIRONMENT->MODIFICATION->EVENTS . Click on NEW ENTRIES. In table below type below values :

3.1 T = 21.

Form Routine = any subroutine name (Eg. SHOW ).

press ENTER .It will Show icon on Editor columne. Now Click on Editor button. Click on OK .

It will show ABAP Editor , here you can write your subroutine code as given bellow :

Form SHOW.

ztable-erdat = sy-datum.

Endform.

save and activate it .

3.2 T = 05.

Form Routine = any subroutine name (Eg. NEW).

press ENTER .It will Show icon on Editor columne. Now Click on Editor button. Click on OK .

It will show ABAP Editor , here you can write your subroutine code as given bellow :

Form NEW.

ztable-erdat = sy-datum.

Endform.

save and activate it .

4. This will create table with default fields. Now to see how this will work , Go to SM30 -> Click on MAINTAIN -> Click NEW ENTRIES. Type the value in the fields which is required and keep remaining fields as empty. Click on ENTER.

The values which we want (Eg. date , time or username) will be added automatically .

Regards ,

Ishant.