Saturday, 3 January 2009

Check and Review

Checking and reviewing should now be my best new friends.

I had an assignment for 3 days and the last two of them were used to find and fix an stupid problem that ended in dumps all the time. The program was really simple: create a backup of the table T059Z with the added field TEXT from its text table T059ZT, in a Z-table with the corresponding fields. The code is simple, by definition:

Create an internal table with the Z-table structure.
Select from T059Z with inner join to T059ZT the fields to backup.
Delete the old DB info.
Insert the new DB info.

The problem was when inserting the new info: a runtime error occurred at the very first record to insert:

ABAP runtime errors DBIF_RSQL_SQL_ERROR
Occurred on 03.01.2009 at 10:36:21

SQL error 1438 occurred when accessing table "ZTFI026 ".

What happened?

When writing a data record to the database (i.e. when
updating the database), only part of the data field was
written (updated). The rest was truncated.

What can you do?

If the error occurred in Open SQL, there is probably an inconsistency
between the NAMETAB and the ABAP/4 Dictionary.
Compare the length specifications of the fields in the NAMETAB with
those in the ABAP/4 Dictionary and contact someone who is able to
perform a consistency check and eliminate the problem.
In most cases, this person will be your SAP consultant.
Please make a note of the actions and input which caused the error.

*


(...)

Error Analysis

The problem has arisen because, within the database interface,
one of the data buffers made available for the INSERT (UPDATE)
is longer than the maximum defined in the database.
On the other hand, it may be that the length in the NAMETAB
does not match the maximum length defined in the database.
(In this case, the length in the NAMETAB is longer.)


I do not know why but my workmate, who was in charge of creating this table in particular, never checked or reviewed his work, then giving me 2 days of more work looking for the solution, which was really simple and it became pretty clear by reading OSS note 591600. The table definition was wrong: one of the fields had the wrong data element:


MANDT MANDT CLNT 3
LAND1 LAND1 CHAR 3
WITHT WITHT CHAR 2
WT_WITHCD WT_WITHCD CHAR 2
QPROZ QPROZ DEC 5
QSATZ QSATZ DEC 4
TEXT40 TEXT40 CHAR 40


compared to:


MANDT MANDT CLNT 3
LAND1 LAND1 CHAR 3
WITHT WITHT CHAR 2
WT_WITHCD WT_WITHCD CHAR 2
QPROZ QPROZ DEC 5
QSATZ WT_QSATZ DEC 7
TEXT40 TEXT40 CHAR 40


This is a reminder of why do I check and review my work once or twice... sometimes even more.

No comments: