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: 

Difference between NULL and INITIAL

pankajs_dwivedi
Participant
0 Kudos

Hi All,

I just wanted to know that if we have a statement such as 'IF VBAP-KWMENG IS INITIAL' or 'IF VBAP-KWMENG IS NULL' what is teh exact difference and where are they used. Is it that null is used for CHARACTER fields?

TIA

6 REPLIES 6

Former Member
0 Kudos

is INITIAL we use just to check that variable having its initial value or not.

for exmaple : integer wil have 0 & char variable is space.

NULL, we use for character variables, i guess.

further help(copied from SAP HELP)

about IS INITIAL:::

Checking for the Initial Value

Use the following logical expression to check whether the value of a field is initial:

.... <f> IS INITIAL .....

This expression is true if the field <f> contains the initial value for its type. To set the initial value of an elementary or aggregate field, use the statement CLEAR <f>.

NULL VALUES ::::

Checking for Null Values IN SELECT Stmts:To find out whether the value of a column is null, use:

SELECT ... WHERE <s> IS [NOT ] NULL ...

The condition is true if the value of <s> is [not] null.

regards

sriknath

Message was edited by: Srikanth Kidambi

0 Kudos

hi,

Null Statement is for validating character type of variable ... where as INITIAL statement is used to check whether the corresponding internal table is filled with data or not ...

Regards,

Santosh

0 Kudos

You check the null value using INITIAL..

IF NOT w_matnr IS INITIAL.

or

IF w_matnr IS INITIAL.

A NULL value on Oracle level is something completely different from the SPACE value on SAP side. In SAP environments NOT NULL constraints are often used, so NULL values should not appear so often. But under certain conditions (e.g. in order to avoid time-consuming conversions when adding a column to a table) the NOT NULL constraint is omitted by the SAP DDIC. In this case a column can contain both NULL and SPACE values. In order to capture both you have to select for both:

<column> = ' ' or <column> IS NULL

Former Member
0 Kudos

Hi,

An <b>Initial Value</b> is set for all the predefined data types

fo ex: type Initial value

b 0

c " "

i 0

so when an object is created,the start value explicitly given by you is taken by that else initial value is taken.

<b>NULL Value</b> is Initial value of an empty column in a row of a database table.Null values can be processing using Native SQL statements, but they have no equivalent as the content of data objects in ABAP. Only the WHERE addition enables a special condition IS NULL for null values. Changing Open SQLstatements (INSERT, UPDATE, MODIFY) generally do not create null values, provided that you are not processing a view that does not comprise all columns of a database table. However, depending on the database system, you can also display empty strings as null values. Null values can still arise in database tables if the new columns are appended to filled tables. When reading with the Open SQL statement SELECT , null values can be created by aggregate functions or an outer join, but they are converted to initial values of the correct type when passed to data objects.

Please reward points if you feel it helps you

Thanks,

Sowjanya

Clemenss
Active Contributor
0 Kudos

as already explained, NULL values appear only in the where condition selecting from database tables.

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 apending 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.

Abstract:

If respective fields are not required in the WHERE clause: Don't care because field contents get converted to initial values when read from database.

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

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

Regards,

Clemens

Former Member
0 Kudos

hi pankaj,

chck this thread