04-10-2006 2:03 PM
I am confused as to the purpose of the Initial Values flag when creating a table.
When you create a table, according to the documentation, all fields are set to be NOT NULL. It is only when fields are added are they NULLable.
Yet the Initial values flag is only checked for primary key fields, from the tables that I've looked at. And primary keys, by definition, are NOT NULL, anyway.
Therefore it leads me to wonder why have this flag at all? It doesn't tell you anything about the underlying fields in the database.
04-10-2006 2:12 PM
Hi Jerry,
"When you create a table, according to the documentation, all fields are set to be NOT NULL." Are you sure about it??
The actual purpose of that indicator is to set default values to that field so that even if you forget to update that particular field in your updating program, you can create a new entry in the database with a unique key.
Regards,
Ravi
04-10-2006 2:13 PM
Hi,
In ABAP
Intial Values are as follows
1) DATE 00000000
2) time 000000
3) Integer 0
4) Char space
When u specify initial flag
these values are updated in the table.
Compare to key they can occurs only once
This is what i know so far; Please correct me if am wrong.
Regards
Manoj
04-10-2006 2:16 PM
Hi Ravi. Here is the SAP Help page where I found this.
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ebf0446011d189700000e8322d00/frameset.htm
The statement in question is towards the bottom.
04-10-2006 4:55 PM
In native SQL, when fields are added to a table using the ALTER TABLE command the field is created with a NULL property unless a default value is specified.
A NULL database value != Initial ABAP value
Setting the initial values flag forces a default value to be used instead (a default value of the initial value of that ABAP datatype).
This is valuable as it ensures consistency when reading database tables through ABAP programs. Especially for date fields (stored as chars on database) since the code below works in all scenarios, irrespective of when the fields were added to the table.
constants c_zzrepdate type mara-zzrepdate value is initial
select matnr
into table l_it_matnr
from mara
where zzrepdate eq c_zzrepdate
04-10-2006 5:59 PM
Hi Chris. As an Oracle DBA in a past life, I completely understand that. What I still don't understand though, is that when I look at a table in SE11, the flag is pretty meaningless. It doesn't tell you anything about whether a column is NOT NULL or NULLable.
In order to really get the true story about a table, I have to do a describe, or use "Utilities->Database Utilities" in order to see a field's NULL status. The flag doesn't seem to correlate (except with the PK) to the underlying table.
05-05-2006 12:15 PM
Hi jerry,
1. Yes, you are absolutely right !
2. But if you notice,
that when we create a new z table,
and in primary keys
we check ONLY KEY (and not the initial values check box)
3. After that, when we activate the table,
these primary fields, will automatically
have the INITIAL VALUES CHECK BOX TICKED.
4. If we read the help, we can figure out
:
When you create a table, all fields of the table can be defined as NOT NULL and filled with an initial value. The same applies when converting the table.
Only when new fields are added or inserted, are these filled with initial values.
<b>An exception is key fields. These are always filled automatically with initial values.</b>
regards,
amit m.
05-04-2006 4:43 PM
Hi2all
I'm very iteresting in this question too. Is anybody knows the answer?