COALESCE function in Select - Open SQL Enhancement ABAP on HANA - Part 7
REPORT zr_opensql_11_coalesce_t.
SELECT
FROM vbak AS so
LEFT OUTER JOIN vbfa AS flow
ON flow~vbelv = so~vbeln
AND flow~vbtyp_v = 'C'
AND flow~vbtyp_n = 'M'
LEFT OUTER JOIN vbrk AS inv
ON inv~vbeln = flow~vbeln
FIELDS so~vbeln AS sales_order,
so~netwr AS so_amount,
inv~netwr AS inv_amount,
CASE WHEN inv~netwr IS NOT NULL THEN inv~netwr
ELSE so~netwr
END AS amount_net,
COALESCE( inv~netwr , so~netwr ) as amount_co
INTO TABLE @DATA(it_result).
IF sy-subrc IS INITIAL.
cl_demo_output=>display( it_result ).
ENDIF.
Comments
Post a Comment