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

Database fields with no values

Former Member
0 Likes
739

Dear Gurus ,

I have a strange problem . I insert in a Z database table(that already exist) a new field that is char 10.This field isn't key .

The problem is the following .

Assume that the total records are 2000 .

The records that have value in the new field are 20 .

When i go in a program with select i don't get the right results !!!!!

Also in se16 i don't take the right results !!!!

Look

REPORT AAAA.

TABLES : ZAAHEADMET.
DATA: AA TYPE I.
DATA : BB(10) TYPE C.
DATA : CCC TYPE I.

CLEAR ZAAHEADMET.
SELECT * FROM ZAAHEADMET WHERE YREFERENCE <> ' ' .
  MOVE ZAAHEADMET-YREFERENCE TO BB.
  AA = STRLEN( BB ).
  IF AA > 1.
    WRITE:/ ZAAHEADMET-VBELN, AA .
    CCC = CCC + 1.
  ENDIF.
ENDSELECT.
WRITE :/ CCC.

Why this happen ?

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
659

Hi Dimath,

if you create a new field for an existing table, you must check the initial values flag for the new field. Then the new field gets its initial value for all existing records, otherwise you have NULL values. They are only selected if selected WHERE field IS NULL.

The reason is that the database does not use table space before the field is populated. This was very useful in the 50ies and sixties

Kind regards,

Clemens

3 REPLIES 3
Read only

Sm1tje
Active Contributor
0 Likes
659

After changing the table, did you activate it with database utility (transaction SE14)? Otherwise try this first and then have a look at SE16 again.

Read only

Former Member
0 Likes
659

Hi,

REPORT AAAA.

TABLES : ZAAHEADMET.

DATA: AA TYPE I.

DATA : BB(10) TYPE C.

DATA : CCC TYPE I.

CLEAR ZAAHEADMET.

SELECT * FROM ZAAHEADMET WHERE YREFERENCE ' ' .

MOVE ZAAHEADMET-YREFERENCE TO BB.

AA = STRLEN( BB ).

IF AA > 1.

WRITE:/ ZAAHEADMET-VBELN, AA .

CCC = CCC + 1.

ENDIF.

ENDSELECT.

WRITE 😕 CCC.

1.SELECT * FROM ZAAHEADMET WHERE YREFERENCE ' ' .

According to me the above select query should be SELECT * FROM ZAAHEADMET INTO ITAB WHERE YREFERENCE = ' ' .

The internal table ITAB is of type ZAAHEADMET .

2. MOVE ZAAHEADMET-YREFERENCE TO BB.

In this the query will select the field YREFERENCE is NIL; so what is the point in moving it to BB field.

Thanks.

Read only

Clemenss
Active Contributor
0 Likes
660

Hi Dimath,

if you create a new field for an existing table, you must check the initial values flag for the new field. Then the new field gets its initial value for all existing records, otherwise you have NULL values. They are only selected if selected WHERE field IS NULL.

The reason is that the database does not use table space before the field is populated. This was very useful in the 50ies and sixties

Kind regards,

Clemens