01-22-2019 7:15 AM
Dear Expert,
I want to achieve the below in the CDS view.
AS ABAP
ls_condtab-field = 'CARRID'.
ls_condtab-opera = 'EQ'.
ls_condtab-low = 'AZ'.
append ls_condtab into t_condtab.
clear : ls_condtab.
ls_condtab-field = 'CONNID'.
ls_condtab-opera = 'EQ'.
ls_condtab-low = '0017'.
append ls_condtab into t_condtab.
APPEND lx_condtab TO t_condtab.
CALL FUNCTION ‘RH_DYNAMIC_WHERE_BUILD’
EXPORTING
dbtable = ‘SFLIGHT’
TABLES
condtab = t_condtab
where_clause = t_where_clause
EXCEPTIONS
empty_condtab = 1
no_db_field = 2
unknown_db = 3
wrong_condition = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
****Dynamic Where Select Query
SELECT * FROM sflight INTO TABLE t_sflight WHERE (t_where_clause).
CDS VIew
@AbapCatalog.sqlViewName: 'ZDDL_TEST_DYN'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Dynamic Where Condition CDS View'
define view ZCDS_TEST_DYNWHERE as select from sflight
{ sflight.mandt,
sflight.carrid,
sflight.connid,
sflight.fldate,
sflight.price,
sflight.currency,
sflight.planetype,
sflight.seatsmax,
sflight.seatsocc,
sflight.paymentsum,
sflight.seatsmax_b,
sflight.seatsocc_b,
sflight.seatsmax_f,
sflight.seatsocc_f }
Kindly help.
01-23-2019 12:29 AM
I guest you cant do it within CDS view but I think you could handle it using CDS table function (if you have ABAP 7.5 ). Read more here:
https://blogs.sap.com/2015/10/21/abap-news-for-release-750-cds-table-functions-implemented-by-amdp/
https://blogs.sap.com/2018/03/21/select-options-in-cds-using-table-function/
01-22-2019 8:13 PM
Hi,
Please, check this post
https://answers.sap.com/questions/103987/dynamic-where-clause-in-sap-hana-calculated-view.html
Regards
Enric
01-23-2019 10:29 AM
01-23-2019 12:29 AM
I guest you cant do it within CDS view but I think you could handle it using CDS table function (if you have ABAP 7.5 ). Read more here:
https://blogs.sap.com/2015/10/21/abap-news-for-release-750-cds-table-functions-implemented-by-amdp/
https://blogs.sap.com/2018/03/21/select-options-in-cds-using-table-function/
01-23-2019 10:29 AM