Skip to Content
0
Oct 30, 2019 at 05:18 AM

Finding out the value of a field of internal table incase it can contain blank or null

473 Views

Hi Experts,

I am having a table in DDIC with columns containing blank and null values both. Using SAP Logon we cannot differentiate between both of them. So I write a following prorgam where I am able to get entries if i am using null in where condition(Please refer to the program) and otherwise 0 entries( in case of blank).

I am trying to check the value of the field which contains null by using "IS NOT INTIAL". But it never enters the if block, it means test2 is not null.

So I am having following questions :

1.) When we transfer data from SAP database in an internal table, what happens to the null values(which were present in sap database). Does internal table fields also contains null values or they gets intialized.

2.) I am using "IS NOT INTIAL" to check if a field is having null value. Is there any other way also to check the same?

In UI it is shown as:

Table : ZTEST_NEERAJ

|ID |NAME |AGE|TEST|TEST2 |

| 1 |NEERAJ|45 | 0 | |

| 2 | |45 | 0 | |

In Actual it is as below:

Table : ZTEST_NEERAJ

|ID |NAME |AGE|TEST|TEST2 |

| 1 |NEERAJ|45 | 0 | NULL |

| 2 | |45 | 0 | NULL |

FUNCTION ZSQL_QUERY2.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" REFERENCE(DBCNT) TYPE SY-DBCNT
*"----------------------------------------------------------------------


DATA : TABLE1 LIKE TABLE OF ZTEST_NEERAJ INITIAL SIZE 10 WITH HEADER LINE.

Select * from ZTEST_NEERAJ INTO TABLE TABLE1 where test2 IS NULL.

DBCNT = SY-DBCNT.

READ TABLE TABLE1 INDEX 1.

DATA: X TYPE I VALUE 0.
IF TABLE1-test2 IS NOT INITIAL.
X = 1.
ENDIF.

ENDFUNCTION.

Thanks,

Partish