在SE11表中检查初始值initial value,ABAP中的初始值和空值

来源:互联网 发布:淘宝店铺图片 编辑:程序博客网 时间:2024/05/16 10:40

1、在开发中遇到这样的情况:一个表使用了一段时间之后需要增加一些字段,而表中已经存在数据了。
2、SE16(N)查看数据时,SAP把具有初始值和空值的字段都显示为初始值,但是在查询语句中,它们在数据库中的行为是不一样的。

3、While designing new table, we often enable the initial value check to set the initial value for the field based on the datatype.

 

test.JPG

 

A field can also be created in the database as NOT NULL if the initial flag isnot set in the ABAP Dictionary.

 

To see  the default value of each field check

 

Utilities -> Database object ->Display in the maintenance screen of the corresponding table.

 

test.JPG

 

But in select query there are some impact

 

NULL means that physically nothing is stored in the database. If a database field is defined as CHAR with, say, 80 characters, the NULL value will not waste that space.

 

When NULL values are transfered from the database, they are converted to the ABAP initial value. But if existing database tables are extended appending new field(s), those fields get stored as NULL values for the existing database records. A WHERE <field> = SPACE will not retrieve the recors with NULL values for the field.

 

If such a null field is used in WHERE clause, no problem if specifying any values except initial.
If selection of records with initial fields is required  and  you do not know if NULL values exist, select

 

WHERE ( <field> = space or <field> is NULL ).

 

So we have to check this aspect of table while doing programming.

4、There is an option to convert all the null values to their respective initial values in transaction SE14. The 'Force Conversion' option available in Menu option 'Extras' will adjust the table replacing NULL will the initial values. Just thought of sharing it here。

0 0
原创粉丝点击