‎2006 May 30 5:33 AM
hi there,
i have great confusion about the use of INIT. check box in ABAP dictionary beside KEY field check box.
some say this is to ensure not null is forced for the field.
i created a table with 2 fields one key field(NUMC4) another non-key(char4). for the second one i checked the INIT check box.
now i make table entries where i leave the second field. that means initial value(space for characters). it takes this initial value also.
then what is the use of this checkbox. please explain. i m so confused.
also tell me how we can make a table field mandatory while creating a table?
‎2006 May 30 5:39 AM
Hi Surendra,
Its the indicator that NOT NULL is forced for this field
Use
Select this flag if a field to be inserted in the database is to be filled with initial values. The initial value used depends on the data type of the field.
Please note that fields in the database for which the this flag is not set can also be filled with initial values.
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. An exception is key fields. These are always filled automatically with initial values.
Restrictions and notes:
The initial value cannot be set for fields of data types LCHR, LRAW, and RAW. If the field length is greater than 32, the initial flag cannot be set for fields of data type NUMC.
If a new field is inserted in the table and the initial flag is set, the complete table is scanned on activation and an UPDATE is made to the new field. This can be very time-consuming.
If the initial flag is set for an included structure, this means that the attributes from the structure are transferred. That is, exactly those fields which are marked as initial in the definition have this attribute in the table as well
Regards,
Susmitha
Dont forget to reward for useful answers
‎2006 May 30 5:39 AM
Hi Surendra,
Its the indicator that NOT NULL is forced for this field
Use
Select this flag if a field to be inserted in the database is to be filled with initial values. The initial value used depends on the data type of the field.
Please note that fields in the database for which the this flag is not set can also be filled with initial values.
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. An exception is key fields. These are always filled automatically with initial values.
Restrictions and notes:
The initial value cannot be set for fields of data types LCHR, LRAW, and RAW. If the field length is greater than 32, the initial flag cannot be set for fields of data type NUMC.
If a new field is inserted in the table and the initial flag is set, the complete table is scanned on activation and an UPDATE is made to the new field. This can be very time-consuming.
If the initial flag is set for an included structure, this means that the attributes from the structure are transferred. That is, exactly those fields which are marked as initial in the definition have this attribute in the table as well
Regards,
Susmitha
Dont forget to reward for useful answers
‎2006 May 30 5:46 AM
Hi Surendra,
u cannot make a field mandatory in a table even if it is among the primary keys.. for that u need to write additional piece of code while maintaining data via SM30.
The INitial option just fills the field with its initial value automatically if nothing is being put.. if u do no chk this field, it will remain blank ( even if the initial value is 0, as in case of integers )
‎2006 May 30 6:02 AM
Hi surendrakumar,
1. This is the default and appropriate behaviour.
2. If we specify any field as primary key,
(it cannot be NULL in physical database table)
3. Hence, INITIAL means,
SPACES for charcter field
ZERO for numeric field.
4. So Its ok what is happening.
regards,
amit m.
‎2006 May 30 6:20 AM
let me know clearly the diff, b/n NULL and INITIAL.
what u mean by physical database? is it ORACLE etc.
‎2006 May 30 6:52 AM
Hi Surendra,
Null means nothing ( not even a blank space )
Initial :
for characters : space
for numbers : 0 ( with decimals depending on the data type )
‎2006 May 30 6:58 AM
You check the null value using INITIAL..
IF NOT w_matnr IS INITIAL.
or
IF w_matnr IS INITIAL.
NULL of oracle is reffered as INITIAL in ABAP. As such INITIAL and '' have same meaning. If you want to specifically check with space then you use SPACE reserved word.
A Database NULL value represents a field that has never been stored to database - this saving space, potentially.
Usually all SAP tables are stored with all fields, empty fields are stored with their initial value.
But: If a new table append is created and the newly-added fields do not have the 'initial value' marked in table definition, Oracle will just set NULL values for them.
as mentioned: There is no NULL value to be stored in an ABAP field. The IS NULL comparison is valid only for WHERE clause in SELECT statement. WHERE field = space is different from WHERE field IS NULL. That's why you should check for both specially for appended table fields.
If a record is selected (fulfilling another WHERE condition) into an internal table or work area, NULL values are convertted to their initial values anyway.
Hope that sheds some light on the subject!
‎2006 May 30 7:32 AM
Hi again,
1. what u mean by physical database? is it ORACLE etc
Yes, the oracle database for sap.
2. let me know clearly the diff, b/n NULL and INITIAL.
When we set a field(s) as primary key
in a oracle database,
we cannot insert NULL value in it.
(NULL = No value, not even spaces, It means totally EMPTY)
(INITIAL value =
Spaces for character type field
Zeroes for numeric/numc type of field)
3. So, in SAP, if we create a table,
and we set one field(s) as primary key,
then
by default,
it means that we cannot
insert NULL in the table record,
so ATLEAST,
SOME VALUE should go in the table,
and this SOME VALUE
can be
SPACES / ZEROES
(based upon the field type)
regards,
amit m.
‎2006 May 30 7:45 AM
Hi,
Go through the following link :
http://www.sappoint.com/abap/ab4dict.pdf
Thanks & Regards,
Ramya Reddy.