Information Technology

Menu

ABAP for HANA Basic & Easy

To begin the onboarding to SAP ABAP for HANA, we will to implement some basic concepts and components that improve our ABAP solutions. These are:

Eclipse IDE as a developer environment.

CDS views as a source data connection and logic relationship.

OData service to expose data.

Program / ALV Reports with improved code to show the CDS data.

The SAP system in the virtual machine has a Procurement data model preloaded. In this basic tutorial we will use just the tables SNWD_AD (Business Partners Address) and SNWD_BPA (Business Partners complementary info).

Core Data Service View

Connect to ABAP project and create a new ABAP Repository Object in the ZTEST Package.

Select Data Definition from Core Data Services folder and press Next.

Set the name ZCDS_CLIENT, set a description and press Next.

Select the transport “Test Request”, and press Finish.

In the CDS created set this code.

@AbapCatalog.sqlViewName: 'ZV_CDS_CLI_INF'@AbapCatalog.compiler.compareFilter: true@AccessControl.authorizationCheck: #CHECK@EndUserText.label: 'CLIENT INFO'define view zcds_client as select from snwd_ad as adjoin snwd_bpa as bpaon ad.client = bpa.client and ad.node_key = bpa.address_guid{key ad.client as client_id,key ad.node_key as addres_key,ad.building as building,ad.city as city,ad.country as country,bpa.company_name as company_name,bpa.node_key as company_key,bpa.bp_role as company_role,bpa.currency_code as company_currency}

Save and activate your CDS view.

Right click on CDS view / Open With / Data Preview.

Check the result. It’s possible that eclipse won’t show the table with values but you can see the number of rows retrieved as test case.

OData Service

Now we will to create an OData service using our CDS view as data source.1. Click on Run ABAP Development Object …2. Set segw.3. Select SEGW transaction and press OK.If you have problems with this transaction in eclipse, you can use it with SAP GUI instead.

1. Press on Create Project.2. Set the values as the image shown.3. Press OK.

Open the created project and right click on Data Model and select Import / DDIC Structure.

Name: ClientInfo

Select Entity Type

ABAP Structure: ZV_CDS_CLI_INF

Check Create Default Entity Set

Press Next

From Data Source Parameter(s), select all the fields less CLIENT_ID and press Next

Select ADDRES_KEY and COMPANY_KEY as key values. Press Finish.

1. Select ClientInfoSet entity.
2. Press Generate Runtime Object
3. The system shows you the default names of some objects that will be created (don’t change).
4. Press OK.

Select ZTEST package and save.

Select the request “Test Request” and press OK.

You should to see several success messages.

In Service Implementation right click on ClientInfoSet and select Map to Data Source.