Case statement in Select - Open SQL Enhancement ABAP on HANA - Part 6

 *&---------------------------------------------------------------------*

*& Report zr_opensql_10_case_t

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT zr_opensql_10_case_t.


SELECT

 FROM vbak

 FIELDS vbeln AS sales_order,

        CASE vbtyp

           WHEN 'C' THEN 'Order'

           WHEN 'B' THEN 'Quotation'

           WHEN 'H' THEN 'Returns'

           ELSE 'Other Docs'

           END AS document_category,

           netwr AS net_amount,

        CASE

         WHEN netwr > 1000 THEN 'Higher amount document'

         WHEN ( netwr > 500 AND netwr < 1000 ) THEN 'Medium amount'

         ELSE  'Lower amount'

         END AS amount_category

 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