2007 Jul 14 9:16 AM
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..
2007 Jul 15 9:03 AM
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"
2007 Jul 14 9:39 AM
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
2007 Jul 14 9:47 AM
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.
2007 Jul 14 9:48 AM
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
2007 Jul 15 9:03 AM
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"
2008 Jun 17 8:18 AM
Helleo:
I meet the same problem. are there any good solution without modify programss.!
Thanks
2008 Jun 17 9:20 AM
Hi
Best way is to use use conversion exit in domain. Which is a user defined function module.
Reward points plz.
2007 Jul 16 7:17 AM
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.