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: 

Default value setting while creating a ztable

Former Member
0 Kudos

Hi all,

I want to know the possibility to set a default value for a field while modifying a transparent table. Since my requirement forces me to have a default value for a field. This table has been used in several programs where data is fed ignoring this filed. So whenever anyprogram populating data into this table without providing value to my field ,it should be populated with a default value.

Can anyone help me in this problem? I dont want to change the codes..

1 ACCEPTED SOLUTION

alejandro_bindi
Active Contributor
0 Kudos

AFAIK it can't be done. Default values exist at Database level but not in ABAP dictionary (you can see them in SE11 under Utilities -> Database object -> Display in the maintenance screen of the corresponding table). Maybe you could use Native SQL and ALTER TABLE statement to set the field default value at DB level, but A) i'm not sure it would work either and B) it's extremely dangerous because for example if table gets regenerated those DB level changes would be lost.

I'd say find another way to accomplish requirement.

Provide points if this helps.

Regards

ps: thread title should be "Default value setting while creating <b>a new field in</b> ztable"

7 REPLIES 7

Former Member
0 Kudos

hi Asshok,

Assuming that you are populating data programatically with insert statement ... in that case if insert statement fails then update the field with a default value..

Regards,

Santosh

0 Kudos

Hi santosh

In the insert statment there will no value for my field, still i want to get a defalult value in my field for this record. Since insert statement are in different progs i cant change all of the progs. Those progs dont about my newly added field in the table.

Former Member
0 Kudos

Hi Ashok,

You can write the code under the Events in table maintainanec generator. so whenever a new entry created the default value can be populated using your code.

Regards,

Atish

alejandro_bindi
Active Contributor
0 Kudos

AFAIK it can't be done. Default values exist at Database level but not in ABAP dictionary (you can see them in SE11 under Utilities -> Database object -> Display in the maintenance screen of the corresponding table). Maybe you could use Native SQL and ALTER TABLE statement to set the field default value at DB level, but A) i'm not sure it would work either and B) it's extremely dangerous because for example if table gets regenerated those DB level changes would be lost.

I'd say find another way to accomplish requirement.

Provide points if this helps.

Regards

ps: thread title should be "Default value setting while creating <b>a new field in</b> ztable"

0 Kudos

Helleo:

I meet the same problem. are there any good solution without modify programss.!

Thanks

0 Kudos

Hi

Best way is to use use conversion exit in domain. Which is a user defined function module.

Reward points plz.

Former Member
0 Kudos

Hi,

Are you talking about the database table or an internal table? In case of database table if the data is bein populated from SM30(table maintainance) then if you write code at table maintainance generator. But what I could understand out of your mail custom programs are populating the table in that case this won't help. And you have to explicitly populate the field.