‎2009 Oct 20 7:44 AM
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 ?
‎2009 Oct 20 8:08 AM
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
‎2009 Oct 20 7:52 AM
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.
‎2009 Oct 20 7:57 AM
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.
‎2009 Oct 20 8:08 AM
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