Skip to Content
Author's profile photo Surendra Garapati

Gate Way Service Creation Using The CDS Views With Parameters

In these blog I am going explain about:

How to create the Gate Way service using CDS Views with Parameters and Without Parameters:

Pre-requisite is to learn basics about the Core Data Services , Basic understanding about SADL Frame work.

Overview of CDS:


Setting Up ABAP On Eclipse:

Step 1: Create the CDS view in Eclipse or Hana Studio.

Here I am creating two CDS views in Hana Studio

Creating CDS View for the House Bank Details



@AbapCatalog.sqlViewName: 'zvtx_hbank'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'house bank data'
define view ztx_hbank 
    as select from t012
    left outer join t001 on t001.bukrs = t012.bukrs
    left outer join t012d on t012d.bukrs = t012.bukrs
                         and t012d.hbkid = t012.hbkid                          
key t012.bukrs as CompanyCode,
key t012.hbkid as HouseBankKey,
butxt as CompanyName,
banks as BankCountry,
bankl as BankInternalId,
t012d.dtbid as AlternativeBankId,
t012d.dtelz as BankNoReceiver,
dtkid as CustomerNumber,
dtfin as CompanyNumber,
edipn as PartnerNumber,
edisn as TypeOfSignature,
dtglz as BankNumber,
dtgbk as AccountNumber,
dtgko as ControlKey,
dtgis as IsoCurrencyCode,
dtaws as InstructionKey,
dtvta as LeadDays,
telf1 as Telephone,
stcd1 as TaxNumber,
name1 as NameOfContactPerson   

On Activation of CDS view got created in the BACK END. Please find the below screen shot

Step 2: Creating the another CDS view with bank master details

Creating the CDS view ZTX_BANK in association with the ZTX_HBANK with Parameter.




@AbapCatalog.sqlViewName: 'zvtx_bank'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'bank master'
define view ztx_bank 
    with parameters
        p_spras: sylangu
    as select from bnka 
    association[0..*] to ztx_hbank as _hbank on $projection.BankCountry    = _hbank.BankCountry
                                            and $projection.BankInternalId = _hbank.BankInternalId
key banks as BankCountry,
key bankl as BankInternalId,
    erdat                          as CreateOn,
    ernam                          as CreateBy,
    bnka.banka                     as BankName,
    provz                          as Region,
    stras                          as StreetName,
    ort01                          as BankCity,
    bnka.swift                     as Swift,
    bgrup                          as BankGroup,
    xpgro                          as PostOfficeAccount,
    bnklz                          as BankNumber,
    @EndUserText.label: 'Homeland or not'
    case when banks = 'CN' then  
//     'Homeland'      
     cast( 'Homeland' as abap.char( 20 ))
    else cast ('Foreign Country' as abap.char( 20 ))
    end as Country,


On activation View got generated in the back end please find the attached screen shot:


Step 3:Two CDS views created, now we are going to create the GATE WAY SERVICE using the                     CDS VIEWS.

In SAP GUI , Open the T-code SEGW

Create the project

Click on create button below POP-UP will open:

Step 4:  In Data Model right click on Entity type and Click on Create button, below POPUP will open                give the entity name and create the Entity Set and click on enter.

Step 5: Give the ABAP Structure name as ZVTX_BANK as shown below which is created on                          activation of CDS View

Step 6:  Right Click on Entity and Import Properties as shown below

Select the parameters which are required and click on next

Select the key and click on finish

Follow the same steps for the Hbank Entity as well it looks like as below shown fig:

  Creation of Properties for the Bank Master and house bank data is done

Step 7: Creating Association BankToHbank i.e optional if you need any associations between two                    entities we can create as shown below:

Right Click on the association node and Click on Create below screen appears:

click on next

Click on Next

Click on Finish


Step 8: In Service implementation:

Right Click on Service Implementation node & click on Map to Data Source

We have different types of business Entities as shown below:

In our case we are using the CDS view as a business entity:

ZTX_BANK is the CDS View Name


Step 9: Click on continue below mapping screen will appear

Click on generate Mapping or drag and drop the properties , below screen appears after                     mapping

Follow same steps for the Hbank Entity as well below screen appears after Mapping


Step 10: Save the Project and click on the generate run-time objects

Create of the model and service definitions , Click on okay and save the objects

Model Provider class and the Data provider classes generated success fully

Step 11:  Register the service i.e. Service registration in the Sap Gateway Hub System

Click on Register button, Select the system alias

Select the SYSTEM and add the service in the package and click on continue, Service                       gets added


Step 12:Test the service

Click on the SAP Gateway Client, below screen will appear

Select GET radio button and click on Execute button

HTTP Response with two entity sets get Displayed as shown below i.e BANKSet and                          HbankSet

For the bank set we used the CDS view with parameter i.e. Language, So add the                              parameter open ZCL_ZTX_BANK_DEMO1_DPC_EXT (Data Provider Extension class),                      Redefine the method.

Note: If you don’t  need any parameter kindly remove the parameter in the CDS view                            and activate it.


Add the below code for adding the parameters to the query.


DATA: lt_parameters TYPE if_sadl_public_types=>tt_entity_parameters,
          ls_parameter  LIKE LINE OF lt_parameters,
          lt_para       LIKE ls_parameter-parameters,
          ls_para       LIKE LINE OF lt_para.

    DATA(lo_auth_provider) = cl_sadl_cond_prov_factory_pub=>create_for_authorization(  ).
    DATA(lv_target_set_name) = me->mr_request_details->*-target_entity_set.
    IF me->mr_request_details->technical_request-navigation_path IS INITIAL.
      CLEAR lv_target_set_name.

    CASE iv_entity_set.
      WHEN 'BANKSet'.
            iv_authorization_object    = 'F_BNKA_MAO'
            it_activities              = VALUE #( ( auth_field = 'ACTVT' value = '03' ) )
            it_field_mapping           = VALUE #( ( auth_field = 'BBANKS' view_field = 'BANKCOUNTRY' ) ) ).
        ls_para-name = 'P_SPRAS'.
        ls_para-value = sy-langu.
        APPEND ls_para TO  lt_para.

        ls_parameter-entity_alias = iv_entity_set.
        ls_parameter-parameters = lt_para.
        APPEND ls_parameter TO lt_parameters.
        io_query_options->set_entity_parameters( lt_parameters ).

    io_query_options->set_authority_provider( io_authority_provider = lo_auth_provider ).


If we are not adding the above code, then it will throw the below error i.e. Missing Parameter:

If you add the above code, we will get the http response with the data as shown below

Same way select the Hbank Entity set i.e Hbank cds view without Parameter so no need to redefine the set query options


Hope the Document is useful….

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Very much confused by this blog...

      First of all, it's "Gateway", and "framework", just one word. Second - what is a "gateway service"? Google -> "gateway service" top links only show references to OData services with SAP NW Gateway.

      If you Google "create gateway service using CDS" you'll find several blogs on OData services already. The top link seems to be sufficiently detailed and in the comments you'll find that in ABAP 7.51 the process is much simpler and SEGW is no longer needed. Yet there is SEGW mentioned here. What gives?

      I might be simply misinformed but, unfortunately, this blog is not giving me any information to understand this either, sorry.

      Author's profile photo Surendra Garapati
      Surendra Garapati
      Blog Post Author

      Hello Jelena,


      In these i am going explain how to consume the the CDS Views with Parameters and without Parameters & how to consume the associated associations from CDS views into Gate Way.




      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      "Consume CDS Views" and "associated associations"? Sorry, this makes even less sense now. And does not really answer any of my questions...

      Author's profile photo lokesh B
      lokesh B

      Hello Surendra,

      Good stuff..,

      As @Jelena mentioned, Gate Way is single word.

      But It will be good if u mention from which version of SAP Gateway component  Creating service with CDS supported ?.

      –> there are 3 ways of Creating Gateway service with CDS view( As far as I know).

      1. Import CDS view via SEGW–>DATA MODEL–>IMPORT–>DDIC Structure

      2. While creating CDS View add annotation @Odata.Publish: true and from                                              /IWFND/MAINT_SERVICE –> select and activate the service.

      3. Map CDS View via Business enrity as you mentioned in this blog.

      If possible please add there ponits also and along wth that it will be helpful for others.



      Author's profile photo Naga Prakash
      Naga Prakash

      Hi all,

      Please find the below link for different approaches and their use cases related to CDS views consumption.




      Author's profile photo Dominik Steinrücken
      Dominik Steinrücken

      Good stuff!

      I needed to use a parameterized CDS-View in my OData-Service ( with sy-langu as a parameter on SAP NW 7.40 ) and your blog post saved my evening.


      Best regards

      Author's profile photo jagadeesh kenguva
      jagadeesh kenguva

      Hello Surendra,

      Good Blog.

      I have a small question. In your example,you have used p_spras as input parameter for cds view and passing sy-langu to it in the method IF_SADL_GW_QUERY_CONTROL~SET_QUERY_OPTIONS.

      But, in my case of example I need to pass an input parameter of cds view through the oData request URI. So, Could you please suggest me that how could I achieve this...


      Thanks in advance,


      Author's profile photo Surendra Garapati
      Surendra Garapati
      Blog Post Author

      Hello Jagadeesh,


      Please use the below Code Snippet.

      DATA: lt_parameters TYPE if_sadl_public_types=>tt_entity_parameters.

      APPEND VALUE #( entity_alias = iv_entity_set

      parameters = VALUE #( ( name = 'P_LANGU' value = sy-langu ) )

      TO lt_parameters.

      io_query_options->set_entity_parameters( lt_parameters ).




      Author's profile photo Shani Niza
      Shani Niza

      Here again, you are passing Sy-langu as parameter value. rather How can I pass value that I get from the odata uri?

      Author's profile photo Shani Niza
      Shani Niza

      Hi Jagadeesh, did you find any solution for doing this?

      Author's profile photo jagadeesh kenguva
      jagadeesh kenguva

      Hello Shani, No, i did not find any solution. Please let me know if you found anything.

      Author's profile photo Saswata Chandra
      Saswata Chandra

      Hi Surendra,

      Could you please explain how you mapped your GW associations with the CDS associations that you have? I'm running into an issue in mapping an association which is present in CDS. I tried creating a new association and and mapped the CDS association which appeared in the SADL model but that's throwing error in generating the service.
      Any help will be highly appreciated!

      Author's profile photo Rahul Lohia
      Rahul Lohia

      Thank you  Surendra ,


      This saved me from re-creating a CDS view ! Absolutely wonderful.