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).

procurement-data-model_short

Prerequisites:

Step-by-Step:

Core Data Service View

In eclipse IDE, open the ABAP perspective.

00

 

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

01

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

02

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

03

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

04

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 ad
join snwd_bpa as bpa
on 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.

05

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

06

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.

07


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.

08

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

09

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

10

  • Name: ClientInfo
  • Select Entity Type
  • ABAP Structure: ZV_CDS_CLI_INF
  • Check Create Default Entity Set
  • Press Next

11

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

12

Select ADDRES_KEY and COMPANY_KEY as key values. Press Finish.

13

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.

14

Select ZTEST package and save.

15

Select the request “Test Request” and press OK.

16

You should to see several success messages.

17

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

18

  • Target: Local
  • Type: Business Entity
  • Name: CDS~ZCDS_CLIENT
  • Press OK

19

1. Set the Element values as the image shown.
2. Press Save
3. Press Generate Runtime Object

20

1. Double click on Service Maintenance
2. Select GW_HUB
3. Press Register

21

To register your project as service, your info should look like the image shown and the package related is ZTEST. Press OK.

22

1. Check the registration status as green.
2. Press Maintain

23

1. Select the service.
2. Press on SAP Gateway Client

24

1. Press Execute.
2. Check the result.

25
Your OData service is working fine.


ABAP Program : ALV Report

You can use your CDS view in yours ABAP programs too. In eclipse IDE create a new ABAP Program in ZTEST package.

26

Set the name ZR_CLIENT_ALV and add a description. Press Next

27

Select the “Test Request” and press Finish.

28

  • Set the code:

cl_salv_gui_table_ida=>create_for_cds_view( iv_cds_view_name = ‘zcds_client’ )->fullscreen( )->display( ).

  • Save it and activate it.
  • Press F8 to run the program.

29

The program / report is working fine.30

spanish-version

Advertisements

One thought on “ABAP for HANA Basic & Easy

  1. Pingback: ABAP Repository & Fiori Application | Innovators at Heart

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s