Application Development 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: 

COALESCE doesn't work in SQ02

0 Kudos
324

Hello,

I'd like to use this function in infoset (SQ02) but I donesn't worke here is the code :

DATA:

BEGIN OF ls_test,

vbeln TYPE vbap-vbeln ,

posnr TYPE vbap-posnr ,

parvw_EN TYPE vbpa-parvw,

parvw_ZF TYPE vbpa-parvw,

END OF ls_test.

SELECT vbap~*,

COALESCE(( SELECT SINGLE posnr

FROM vbpa AS v

WHERE v~posnr = vbap~posnr

AND v~posnr <> '' ),

( SELECT SINGLE posnr

FROM vbpa AS v

WHERE v~posnr = '' )

) AS tag

INTO TABLE lt_result

FROM vbap.

Error:

This Open SQL statement uses additions that can only be used when the

fixed point arithmetic flag is activated (such as CASE expressions or host variables in

thank you in advance

1 REPLY 1

BiberM
Active Participant
0 Kudos
207

I can only answer from a pure technical view:

COALESCE Returns the first not null value. Please keep. In Kind the difference between null and initial in ABAP (or the absence of null). So I assume that the subqueries are evaluated, Transporte back to the ABAP layer where they become initial values. Therefor it is always the first value that is returned.

Better:

Don't use subqueries but left outer joins. If you give them an alias you can join the same table multiple times. With a left outer join the whole query is executed as one and null values are possible. Then you can use COALESCE as intendend.

Best regards

Michael