on 2025 Mar 19 7:34 AM - last edited 3 weeks ago
Hello,
I've got this ABAP syntax check warning for all key fields of ZTABLE (WAERS, etc.) of below ABAP code:
The expression that contains "WAERS" can get null values since it contains fields that were not created with "Initial Values" in the dictionary. |
Syntax check internal message code: INSERT 211.
ABAP code (there's a list of columns and a WHERE clause with IN and = followed by ABAP variables, no SQL expression):
INSERT ztable FROM ( SELECT waers, ... FROM zcview ).
WAERS is the first key field of ZTABLE. ZTABLE has a client key field in the very first position.
ZCVIEW is a CDS entity view with this code (only inner join, no left outer join):
define view entity ZCVIEW
as select from bkpf
inner join ...
{
key bkpf.waers,
...
sum( ... ) as sum_...,
...
cast(' ' as belnr_d) as extbelnr,
...
}
where ... // conditions against constants
group by ... // all fields before the sum fields
The description says to use ##NULL_VALUES to remove the warning. This works fine.
I'd like to know the reason why there is this warning.
I see in the ABAP documentation INSERT dbtab, source - Alternative 3 ( SELECT subquery_clauses ... ):
Null values to be inserted can be produced in the following cases:
A catchable exception of exception class CX_SY_OPEN_SQL_DB is raised in the case of columns that are key fields of the DDIC database table or DDIC view to be filled. If it is known statically that null values can be inserted into key fields, a syntax check warning that can be hidden by the pragma null_values is produced. |
Is there a way to avoid the warning without using ##NULL_VALUES?
Why exactly is the warning sent with INSERT ztable FROM ( SELECT ... )?
Thank you.
Sandra
ABAP release: 7.58.
EDIT April 9th, 2025: I have updated a little bit the question because it didn't make sense as I had used the example of BKPF-BUKRS which is NOT NULL in BKPF, so I replaced with WAERS,
Request clarification before answering.
The warning is because of:
Hence, COALESCE is a good solution to avoid the exception to define a value instead of the NULL value:
INSERT ztable FROM ( SELECT coalesce( bkpf~waers , ' ' ), ... FROM zcview ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's possible to use the SQL function COALESCE to convert NULL into a value, and the warning doesn't show up anymore, e.g.
INSERT ztable FROM ( SELECT coalesce( bkpf~waers , ' ' ), ... FROM zcview ).
But is it good to use COALESCE for just a warning...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's probably a generic warning requiring a pragma is all. No way around probably.
As a test I would remove "BUKRS" to see if you get a warning about the next field after "BUKRS"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
12 | |
9 | |
8 | |
7 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.