Thursday, February 6, 2020

How to call an OData service of a CDS view and also pass parameters and also including a date field?


Questions about SAP CDS Views.

How to call an OData service of a CDS view and also pass parameters and also including a date field?

ABAP CDS ODATA View with parameters bp_idp_date ,p_language:

























@AbapCatalog.sqlViewName: 'ZSD_CDSView'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'My Consumption CDS View'
@OData.publish: true
define view ZSD_CDS_View
    with parameters bp_id: bu_partner,
        @Environment.systemField: #SYSTEM_DATE
        p_date: dats,
        @Environment.systemField: #SYSTEM_LANGUAGE
        p_langu: spras
as select from ZI_CDS_View_Composite {   
     
    key partner1,
    partner2,
    date_to,
    reltyp,
    date_from,
    spras,
    bez50,
    bez50_2
     
} where partner1 = :bp_id
    and date_to >= :p_date
    and date_from <= :p_date
    and spras = :p_langu



ANOTATION: -@OData. Publish: true


You can call ODATA service this link
Link ODADA Service: /sap/opu/odata/sap/ZCDS_VIEW_SRV/ZC_CDS_View(bp_id='0123456789',p_date=datetime'2019-04-01T12:00',p_langu='E')/Set


No comments:

Post a Comment