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

Popular posts from this blog

AMDP ( ABAP Managed Database Procedure ) Part - 1

Backup all ADT Objects & Other queries RAP Part 10.1

SAP CDS Introduction Part 2 - ABAP on HANA Course