Application Development and Automation 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: 
Read only

differentiate between INITIAL value and NULL values( Not in where level)

Former Member
0 Likes
2,925

Dear All,

Is there any method to differentiate between INITIAL value and NULL value at abap level. I have one internal table in which there are some Initial values as well as some Null values and also others are present. so i want to recognize these values at abap level .please suggest me some method.

REgards,

Anuj jain

12 REPLIES 12
Read only

ThomasZloch
Active Contributor
0 Likes
1,806

Since IS NULL is only available for SQL-conditions, and I assume that NULL means hex '00' values, you can maybe use the BYTE-CO operator in conjunction with a type X field with value '00'.

Thomas

Read only

Former Member
0 Likes
1,806

You might find answer (or at least some hints) in one of the following two dicussions:

[;

[;

Read only

P1029777
Explorer
0 Likes
1,806

hi Anuj Jain ,

Initial value means '0' (zero)

null value means 'garbage value'

garbage value ( it could be anything which is not useful)

Hope this will work.

Read only

Former Member
0 Likes
1,806

I tried thomas method but it's not giving required result

Any other suggestions?

Regards,

Anuj

Read only

0 Likes
1,806

Please precisely explain what you consider a NULL value in this specific case. The more details you disclose, the more likely you will receive helpful replies.

Thomas

Read only

Clemenss
Active Contributor
0 Likes
1,806

Hi Anuj,

you can not detect NULL values in ABAP. In the database, if you append new fields to a table, the database will not automaticalls create values for all records (except you crossed INITIAL flag in DDIC). Those values are NULL values because they simply do not exist. You can check for them in the WHERE clause of a select statement. You will not find a record with NULL value if you specify WHERE ... = space.

If you select records into a structure or table, all NULL values will be converted automatically to INITIAL value. When updating a database table from structure or table, all previously NULL values get overwritten with initial (or existing) value.

This is about NULL in context of field values.

In context of references, we can talk of NULL as a missing reference. A class or data object is NULL (in ABAP; IS BOUND) as long as no instance or data refernced by this object has been created.

Hope this sheds lights on any doubts.

Regards,

Clemens

Read only

Former Member
0 Likes
1,806

Dear Thomas ,

As per your suggestion i tried like this

" table zmara field zaennr has NULL values
SELECT * FROM    zmara  INTO table it_zmara.
DATA: hex1 TYPE xstring ,
           hex2 TYPE xstring value IS INITIAL.
loop at it_zmara.
hex1 = it_zmara-zaennr." This contain NULL values
IF hex1 BYTE-CO hex2.
write: 'Found Initial values'.
ENDIF.
endloop.

and in this case for all null values showing sy-subrc = 0 for if conditions and write: 'Found Initial values'.

Regards,

Anuj jain

<Added code tags>

Edited by: Suhas Saha on Jul 13, 2011 10:58 AM

Read only

Former Member
0 Likes
1,806

Hi All,

Can we found out that any table is having Any NULL values or not?

Like Any table maintain all tables entries for null values or Any FM.

NOTE: Not usefull (sql with where field is null)

Read only

0 Likes
1,806

the only way to find records with NULL values is WHERE ... IS NULL. There is no other solution. Even WHERE ... = hex 00 won't work, neither WHERE ... NE any value.

Sandra

Read only

Former Member
0 Likes
1,806

any suggestion....

Read only

0 Likes
1,806

Hi,

if sql with where field is null is not applicable, then please close the thread, change the subject and describe what you really want (Not: field is null)

And plese explain where your own definition of initial is different to common IT definition. Thank you.

Regards

Clemens

Read only

Former Member
0 Likes
1,806

thanks all