Hello everyone, in this ABAP on HANA tutorial, we will learn how to consume Attribute Views in ABAP on HANA. Lets get started.
Prerequisites
- You should have Attribute View created in HANA Repository.Please read our previous tutorial on how to create Attribute View.
- You should have created ABAP project in Eclipse IDE.
Step-By-Step Procedure
1. Right Click on your package and choose New → Other ABAP Repository Object.
2. In the New ABAP Repository Object window, search by “dictionary” and choose Dictionary View under Dictionary folder and hit OK.
3. In the New Dictionary View window, enter Name, Description and choose External View radio button and enter our attribute view name we created in our previous tutorial.
♦ Tip : To search for attribute view name you can use Browse button or press Cntrl+space (Content Assist Available).
4. In Selection of Transport Request window, choose the transport request in which you want to save the program and hit Finish button.Here we are saving the program in $TMP package so transport request not required.
5. External View will be created successfully.Click on activate button to activate the external view created.
6. Congrats, you have successfully created a Dictionary View(External View) for a HANA Attribute View.
Now we need to call this dictionary view ZEV_EMP_INFO in our ABAP program using Open SQL statement.
7. Before calling the view in an ABAP program, we do a quick and easy test to access the data.
Go to SE16N(Data Browser) enter ZEV_EMP_INFO and Execute.
8. Create a sample ABAP Program ZDEMO_HANA_VIEW in your package. To know how to create an ABAP program click here. Copy and paste the below code into the abap program.
REPORT zdemo_hana_view. *-- Internal declaration for Dictionary View DATA: lt_emp_info TYPE TABLE OF zev_emp_info, lo_salv TYPE REF TO cl_salv_table. *-- Open SQL statement to access Dictionary View SELECT * FROM zev_emp_info INTO TABLE lt_emp_info. *.. ALV Display cl_salv_table=>factory( IMPORTING r_salv_table = lo_salv CHANGING t_table = lt_emp_info ). lo_salv->display( ).
9. Save and activate the program and execute the report.
Output
Congrats, you have successfully know how to consume Attribute Views in ABAP on HANA.
Please stay tuned to us for more ABAP on HANA Eclipse tutorials.Please feel free to comment and let us know your feedback. You feedback will keep us alive.
Thank you. 🙂