CD263 Exercise VHO
Short Description
Download CD263 Exercise VHO...
Description
ABAP ON SAP HANA - BUILDING AN END-TOEND APP FROM HANA VIA ABAP TO SAPUI5 CD263
Jens Weiler / SAP AG
Getting started with your session Login credentials and group numbers can be found in the ‘My Reservation’ tab on the SAP TechEd Virtual Hands-On Workshops website (https://saptechedhandson.sap.com/). Important: Some of the sessions use place holders for users (e.g. CD300_XX) or objects (e.g. ZCD400_Exercise_##). The place holders XX or ## must be replaced with your assigned group number, which you find in the ‘My Reservation’ tab on the above mentioned website.
2
TABLE of Contents A. Introduction ............................................................................................................................................ 3 B. ABAP List Viewer with integrated Data Access (ALV with IDA) ............................................................ 4 Introduction .............................................................................................................................................. 4 Exercise B1 – Simple ABAP List Viewer with Integrated Data Access ................................................... 4 Exercise B2 – ALV with Integrated Data Access leveraging SAP HANA Fuzzy Search Capabilities ..... 16 C. ABAP on HANA ..................................................................................................................................... 22 Introduction .............................................................................................................................................. 22 Exercise C1 – Expose a HANA view as an External View ...................................................................... 22 Exercise C2 – Enhance the view with additional fields ............................................................................ 28 Exercise C3 – Call a Database Procedure .............................................................................................. 33 D. OData & SAPUI5 ................................................................................................................................... 39 Introduction .............................................................................................................................................. 39 Exercise D1 – OData service ................................................................................................................... 39 Exercise D2 – SAPUI5 application .......................................................................................................... 53 Appendix .................................................................................................................................................... 64 Additional Material for Exercise D1.......................................................................................................... 64
3
A. INTRODUCTION Welcome to the exercises of TechEd Session CD263. In this document you will find exercises on: B. ABAP List Viewer with integrated Data Access C. ABAP on HANA D. ODATA and SAPUI5 Before you start, here is some technical information on the systems, usernames, passwords, etc. that you will need during the exercise: Session Name
CD263
Integrated Development Environment (IDE)
Accessible via the Windows Start Menu (“SAP HANA Studio – CD263”)
ABAP System
M33 (already configured in the SAP Logon)
ABAP Client
800
ABAP Username
CD263-## (where ## is your group name)
ABAP Password
Welcome1
HANA System
M33 (already configured in the “Modeler” perspective of your IDE
HANA Username
CD263_STUDENT
HANA Password
Welcome1
The screenshots for this exercise have been prepared using ABAP application user CD263_00. The explanation in this exercise will remind you to use your group number (indicated by ##), e.g. ABAP program ZCD263_##_SALV_IDA. Moreover, you’ll be creating ABAP artifacts in package ZCD263EX_##, while all screenshots show package ZCD263EX_DEMO for illustration purposes. In the “Modeler” perspective of the IDE, you will find packages teched.cd263.exercise.a as HANA Content packages.
Now, enjoy the exercises!
4
B. ABAP LIST VIEWER WITH INTEGRATED DATA ACCESS (ALV WITH IDA) Introduction Estimated total time: 40 minutes Objective This exercise introduces the ABAP for HANA Development Environment and familiarizes you with the new “ABAP List Viewer with Integrated Data Access” (a.k.a. “ALV with IDA”). The ALV with IDA introduces some major database feature improvements compared to the classical ALV like: Database paging: Result will be selected from the database in pages – there is no need to transfer the full result set to the application server any more Operations like aggregation, sorting, and filtering in the ALV grid will be pushed down to the database layer In exercises B1 and B2 you will learn how to build an ALV with IDA and get a first impression of the new paging, sorting, and aggregation possibilities / advantages. You will also learn how to use fault tolerant search, also known as “Fuzzy Search”, and how to consume it in a simple user interface based on the ALV with IDA.
Content Exercise B1 - ABAP List Viewer with Integrated Data Access Exercise B2 - ABAP List Viewer with Integrated Data Access leveraging SAP HANA Fuzzy Search Capabilities
Exercise B1 – Simple ABAP List Viewer with Integrated Data Access Transform an existing report following the traditional pattern: Data selection into an ABAP Internal Table (itab) Data output with a classical ALV into an ABAP List Viewer with Integrated Data Access Estimated time: 20 minutes
Explanation
1. Logon to the Frontend System 2. Start the Development Environment by selecting “Start” > “All Programs” > “SAP” > “SAP HANA” > “SAP HANA Studio – CD263”
Screenshot
5
Explanation 3. A “Welcome” screen is displayed. Click on the “Workbench” icon to launch your Integrated Development Environment (IDE) Hint: In the “Welcome” screen, you will find many useful links to either tutorials or further documentation about “SAP HANA Studio”, the “ABAP”, and “ABAP for HANA Development Tools”
For the virtual Hands-on workshops the user and password is unique and was changed before you get access to the system. Therefore the password of the secure store needs to be recovered/unlocked.
You need to recover the password first. Choose Window->Preferences
Screenshot
6
Explanation
Then open General -> Security -> Secure Storage
Click on Recover Password
Answer the questions Question 1: 1972 Question 2: Hoffenheim And click OK.
Screenshot
7
Explanation
And click OK.
And click OK.
Unlock the Secure Store by clicking on Unlock. Now you can continue with the exercises.
4. Make sure that the “ABAP” Development Perspective is selected
5. Create an ABAP Project. Navigate to the menu and select “File” > “New” > “ABAP Project” Hint: You can use the shortcut Ctrl+Alt+Shift+P
6. In the “System Connection” dialog window, use the “Browse” button and select the system M33 [PUBLIC]
Screenshot
8
Explanation
7. In the “New ABAP Project” dialog window, enter the logon credentials as indicated in the screenshot. The username and password information are given in the introduction of this document (chapter A). User: CD263-## (where ## is your group name) Password: Welcome1 Continue with “Next“
8. Press the “Add...” button to incorporate your working package ZCD263EX_## and the solution package ZCD263_SOLUTION to your “Favorite Packages” list and confirm with “OK”. Then press “Finish” to finalize the “New ABAP Project” wizard Note: Remember that ## denotes your group number
Screenshot
9
Explanation
Screenshot
9. Open the ABAP program ZCD263_##_SALV_IDA by using the “Open ABAP Development Object Dialog” by using the shortcut Ctrl+Shift+A and enter the program name in the input field. Continue with “OK” Or use Navigate->
Hint: You can also navigate through the “Project Explorer” to open the ABAP program
Code Snippet: ZCD263_##_SALV_IDA REPORT zcd263_00_salv_ida. * Dynpro Fields: Equal names used in Dynpro 555 and Program DATA: g_okcode TYPE sy-ucomm. DATA: gc_container_name TYPE string VALUE 'D0555_CONTAINER'. * Global program Fields/variables * A) Reference Variable of CL_SALV_TABLE DATA: go_alv_display TYPE REF TO cl_salv_table. DATA: go_container_d0555 TYPE REF TO cl_gui_custom_container. * B) gt_outtab global table to be filled by select statement DATA: gt_outtab TYPE TABLE OF zdv_bpa_open_inv. ... END-OF-SELECTION. * B) Note: Complete data must be loaded at the beginning -> poor performance, Limited ABAP memory. Restricted to 100.000 rows SELECT * FROM zdv_bpa_open_inv INTO CORRESPONDING FIELDS OF TABLE gt_outtab UP TO 100000 ROWS.
10
Explanation
Screenshot
What is the ABAP program about? You see a typical ABAP report including an ABAP List Viewer (ALV). The data is retrieved via the DDIC view ZDV_BPA_OPEN_INV which shows Business Partners and their Open Invoices. The report’s dynpro (555) has a GUI container which acts as a parent container for the ALV Grid Control. The dynpro typical PBO and PAI modules are already handling the basic logic. In the PBO module a classical ALV is created – in the PAI module a simple EXIT is implemented. In the END-OF-SELECTION event of the report – after the data is retreived from the database – a screen will be called to display the data. Note: This report will not handle any kind of authority checks and the data selection has been restricted to 100.000 rows due to retrieval time
10. Run the ABAP Program (press F8) to see a list of Business Partners and their open invoices (Total Gross Amount) Hint: Displaying the screen will take some seconds because of fetching the data from the database
Embedded SAP Gui You will see an embedded SAP Gui Window within the ABAP Development Tools at runtime to display the result
11. Switch back to your program by selecting the appropriate source code editor tab
11
Explanation
12. Analyze the Report
Screenshot a. Reference Variable of CL_SALV_TABLE b. gt_outtab: global table filled by select statement. Selection restricted to 100.000 rows for performance reasons c. Dynpro PBO/PAI/Fields/ContainerCreation d. Use cl_salv_table=>factory( ) to get a new instance for ALV Table Object e. Set GUID columns as technical to hide it from the ALV grid f. Enable the basic service functions of ALV (filtering, sorting, aggregation) g. Optimize the Column width h. Display configured ALV: Trigger the UI Rendering
From a classical ALV to an ALV with Integrated Data Access (ALV with IDA) Now let’s do a step-by-step transformation from the classical ALV to the new ALV with Integrated Data Access (IDA)
13. Change the reference of variable go_alv_display from cl_salv_table to if_salv_gui_table_ida Hint: See coding part A)
14. Comment or delete the variable definition gt_outtab and the OpenSQL statement for retrieving data from database view zdv_bpa_open_inv Hint: See coding part B)
12
Explanation
Screenshot
15. Navigate to the PBO form routine. Instantiate the ALV with IDA by calling the create method cl_salv_gui_table_ida=>cr eate(...)instead of the ALV table object and pass the existing database view name ZDV_BPA_OPEN_INV Hint: See coding part D)
Code: ZCD263_##_SALV_IDA FORM pbo. IF go_container_d0555 IS NOT BOUND. *
C) Dynpro PBO/PAI/Fields/ContainerCreation go_container_d0555 = NEW #( |{ gc_container_name }| ). TRY.
*
D) Instantiate the IDA ALV instead of the ALV table object go_alv_display = cl_salv_gui_table_ida=>create( iv_table_name = 'ZDV_BPA_OPEN_INV' io_gui_container = go_container_d0555 ).
16. Delete some technical columns containing GUIDs (Keys) from the available field list by using the getter and setter methods of the Field Catalog Interface Hint: See coding part E)
Code: ZCD263_##_SALV_IDA * E) Set technical columns containing GUIDs using the Field Catalog Interface go_alv_display->field_catalog( )->get_available_fields( IMPORTING ets_field_names = DATA(lts_available_fields) ). DELETE lts_available_fields WHERE table_line CP '*_GUID'. go_alv_display->field_catalog( )->set_available_fields( EXPORTING its_field_names = lts_available_fields ).
13
Explanation
Screenshot
17. Comment or delete the coding in section E), F), G), and H)
18. Catch exception cx_salv_ida_unknown_name instead of cx_salv_msg and cx_salv_not_found
Code: ZCD263_##_SALV_IDA .... CATCH cx_salv_ida_unknown_name INTO DATA(lr_ex). MESSAGE e202(salv_ida) WITH lr_ex->field_name. ENDTRY.
19. Navigate to the PAI module and add go_alv_display->free( ) within the CASE l_okcode section in order to release the resources Hint: See coding part I)
14
Explanation
Screenshot
Code: ZCD263_##_SALV_IDA ... CASE l_okcode. WHEN con_exit OR con_back OR con_canc. * I) Release the resources go_alv_display->free( ). SET SCREEN 0. LEAVE SCREEN. ENDCASE.
20. Save your ABAP program
21. Create a new transport request CD263:Transport Request of Group ## and press “OK”
22. Check and Activate your ABAP program
23. Run your ABAP program by pressing F8
15
Explanation
Screenshot
24. Do some analysis on the retrieved data: a) Create a list which shows the Total Gross Amount per Business Partner. In order to do so, select the column “Company Name” and click on the “Group” icon. Then select the “Total Gross Amount” column and click the “Aggregate” icon.
b) Apply a filter showing the Total Gross Amount per Business Partner in a given country. In order to do so, select the “Country” column, press the “Filter” icon and enter e.g. DE (Germany) in the filter dialog window.
Summary Exercise B1 Congratulation: You successfully transformed a classical ABAP List Viewer to an ABAP List Viewer with Integrated Data Access to leverage the full power of the SAP HANA Database. The ALV with IDA brings some major database feature improvements compared to the classical ALV like Database paging – the result will be selected from the database in pages. There is no need to transfer the full result to the application server any more. ALV services as database operations – Aggregations, Sorting and Filtering in the ALV grid will be pushed down to the database layer. You are now able to: Take advantage of the new integrated environment of ABAP for HANA Development Tools Transfer a classical ABAP List Viewer report to an ABAP List Viewer with Integrated Data Access
16
Exercise B2 – ALV with Integrated Data Access leveraging SAP HANA Fuzzy Search Capabilities Enhance an existing report containing an ABAP List Viewer with Integrated Database Access with SAP HANA Fuzzy Search capabilities. Estimated time: 20 minutes
Explanation
Screenshot
1. Open ABAP program ZCD263_##_SALV_IDA_FUZZY _SRCH via the “Open ABAP Development Object Dialog” (shortcut Ctrl+Shift+A) Or use Navigate->
2. Alternatively you can use the “Project Explorer” view to open the ABAP program
What is the ABAP program about? The report is based on the solution of Exercise B1 with two additional input fields g_search_text and g_similarity on the dynpro. The new input fields will handle the user input for leveraging the Fuzzy Search cababilities of the SAP HANA Database. Running the ABAP report you will see two new input fields on the screen, however, there is no logic implemented to handle any kind of user input. The goal of this exercise is to implement the logic for handling the user input and leveraging the fuzzy search on the SAP HANA database.
17
Explanation
3. Run the ABAP program by pressing F8 to see a list of business partners, their open invoices, and an input field to search for any kind of text. Enter any kind of search term e.g. SAP and press Enter. You will see that nothing will happen.
4. Navigate to the “PBO” form routine and implement the handling of the user input g_search_text and g_similarity Hint: See coding part J)
Screenshot
18
Explanation
Screenshot
5. First step is to handover the user input to the interface if_salv_ida_text_search by calling the text_search( ) method on the reference variable of go_alv_display using the appropriate setter methods set_field_similarity( ) and set_search_term( ). Save, Activate, and Run your program (shortcuts Ctrl+S, Ctrl+F3, F8). If you use remote Desktop connection, some of the shortcuts will not work!
Note: Use the transport request created in the previous exercise if applicable.
Code snippet: ZCD263_##_SALV_IDA_FUZZY_SRCH
* *
ELSE. J) Fuzzy Search: ....... go_alv_display->text_search( )->set_field_similarity( g_similarity ). go_alv_display->text_search( )->set_search_term( |{ g_search_text }| ).
6. Now you can explore the Fuzzy Search feature, e.g. enter SAP as search term and press Enter
19
Explanation
Screenshot
7. Enter e.g. Sola as search term and press Enter. Note: No data is returned from the database
8. Change the “Similarity” to e.g. 0,6, press Enter, and group the list by “Company Name”. You will see multiple business partners as displayed in the screenshot Hint: Only similarity values between 0 and 1 are allowed
Additional ABAP List Viewer with Integrated Data Access Capabilities In our scenario interactive grouping and sorting by “Customer Name” was a frequent user action. Therefore initial grouping and sorting is a valid pattern.
9. Navigate to the “PBO” form routine and implement an initial grouping/sorting by calling the default_layout( ) method on the reference variable of go_alv_display using the appropriate setter methods set_sort_order( ) Hint: See coding part K)
20
Explanation
Screenshot
Code snippet: ZCD263_##_SALV_IDA_FUZZY_SRCH * *
*
K) Optional: Enter Coding for GROUPING & SORTING here... Define Grouping/Sorting Criteria DATA: lt_sort TYPE if_salv_gui_types_ida=>yt_sort_rule. APPEND VALUE #( field_name = 'COMPANY_NAME' is_grouped = abap_true descending = abap_true ) TO lt_sort. Set Grouping/Sorting Criteria go_alv_display->default_layout( )->set_sort_order( lt_sort ).
10. Save, Activate, and Run your program (shortcut Ctrl+S, Ctrl+F3, and F8) If you use remote Desktop connection, some of the shortcuts will not work!
Additional Fine Tuning In order to avoid redundant database requests, it is good style to check whether the user input has been changed or not. Therefore, the values of the input fields must be compared with the values of the last database request. Whenever a new value is entered a message in the status bar of the dynpro is displayed.
11. Navigate to the “PBO” form routine and implement the comparison of the actual value and the user input value
21
Explanation
Screenshot
Code snippet: ZCD263_##_SALV_IDA_FUZZY_SRCH *
J) Fuzzy Search: IF go_alv_display->text_search( )->get_search_term( ) NE g_search_text OR go_alv_display->text_search( )->get_field_similarity( ) NE g_similarity. go_alv_display->text_search( )->set_field_similarity( g_similarity ). go_alv_display->text_search( )->set_search_term( |{ g_search_text }| ). MESSAGE s000(0k) WITH 'New Search Term entered'. ENDIF.
12. Save, Activate, and Run your program (shortcut Ctrl+S, Ctrl+F3, and F8) If you use remote Desktop connection, some of the shortcuts will not work!
Summary Exercise B2 The SAP HANA Text Engine provides text indexing and search capabilities, such as exact search for words and phrases and fuzzy search. The full text Search capabilities together with the Fuzzy Search functionality of HANA helps speed up search within large amounts of text data significantly. Fuzzy Search enables you finding strings that match a pattern approximately (rather than exactly). The SAP List Viewer with Integrated Data Access offers the possibility for the user to display, sort, and group data on SAP HANA database views without introducing a new user interface. The known ALV functions are therefore added to the advantages of using in-memory features of SAP HANA from a user perspective.
22
C. ABAP ON HANA Introduction Estimated total time: 45 minutes Objective In this exercise you will learn how easy it is to leverage the full power of HANA by using the new features provided in the application server ABAP 7.4. The exercise comprises three parts, in the first part, an existing HANA view is exposed as an external view in the ABAP Data Dictionary. In the second, an existing HANA view is enhanced and the external view synchronized accordingly. Finally, in the last part of the exercise, a database procedure proxy is created for an existing database procedure. Content Exercise C1 – Expose a HANA view as an External View Exercise C2 – Enhance an existing view by a new field Exercise C3 – Create a Database Procedure Proxy
Exercise C1 – Expose a HANA view as an External View In the following exercise you will: Expose an existing calculation view as an external view Inspect the view in SE16 Write a SELECT statement on that external view Estimated time: 15 minutes
Explanation 1. Switch to the Modeler perspective by clicking on the corresponding button (or press Ctrl+3 and enter Modeler)
2. In the “SAP HANA Systems” view, navigate in the Content folder to teched.cd263.exercise.a: :CA_OPEN_INVOICES_## (where ## denotes your group number)
Screenshot
23
Explanation
3. In the mentioned view, open the context menu for the calculation view and choose “Data Preview”
4. Switch to the “Raw Data” tab and inspect the results as shown in the screenshot It may happen, that you have a different column order. Note: In the course of this exercise, you’ll deal with the results of this view several times, so you might want to have a deeper look now and memorize a certain value for a later comparison
5. Switch to the ABAP perspective
Screenshot
24
Explanation
6. In the “Project Explorer“ view, select your development package ZCD263EX_## (## denoting the group number)
7. Now, you’ll create a new external view. For this purpose, choose “New” > “Other ABAP Repository Object” in the context menu
8. Select “Dictionary View” and hit “Next” Hint: You can filter the list by typing “View” in the edit box.
Screenshot
25
Explanation
9. Enter ZCA_##_OPEN_INV as name (where ## is your group number). Add a description. Select the radio button “External View” and choose your personal view teched.cd263.exercise.a. CA_OPEN_INVOICES_##. Finally hit “Next” to continue. Hint: In the field “HANA View” you might want to use the auto completion, just enter CA_OPEN_INV and hit CTRL+SPACE
10. Select the transport request you’ve created earlier in the previous exercise (if there is no transport request, just create a new one)
11. Activate your external view by clicking the corresponding icon (or press CTRL+F3)
Screenshot
26
Explanation
12. Inspect your external view via the well-known transaction SE16 Hint: You can open the transaction using the shortcut Alt+F8, and enter SE16 in the dialog window. Enter ZCA_##_OPEN_INV in the “Table Name” field, press Return (to enter the selection screen) followed by F8
13. Open the report ZCD263_##_SHOW_OPEN_INV Hint: Use the shortcut CTRL+SHIFT+A and enter the report name Or use Navigate->
14. Write a SELECT statement to retrieve the data from the external view ZCA_##_OPEN_INV into the ABAP Internal Table gt_figures.
Screenshot
27
Explanation
Screenshot
Code Snippet: ZCD263_##_SHOW_OPEN_INV SELECT bp_id AS customer_id company_name AS customer_name avg_days_open gross_amount_converted AS sum_gross_amount FROM zca_##_open_inv INTO CORRESPONDING FIELDS OF TABLE gt_figures ORDER BY bp_id.
15. Run your report
Hint: You might notice that several empty columns appear. The population of these fields will be done in the next exercise
Summary Exercise C1 You have now successfully accessed a HANA calculation view via an external view using OPEN SQL. You are now able to:
Inspect an existing calculation view in the HANA content Create an external view, exposing the HANA object in the DDIC Write a simple SELECT statement to retrieve the data that’s calculated in the HANA database
28
Exercise C2 – Enhance the view with additional fields In this exercise you will add some additional fields in the HANA calculation view and adapt the dependent ABAP objects accordingly. Finally, the previously empty fields will be populated in the result view of the ABAP report. The following steps will guide you to: Create additional fields in the calculation View Synchronize your previously created external view Enhance the select statement in the ABAP report Estimated time: 15 minutes
Explanation
1. Switch to the modeler perspective
2. Open your calculation view teched.cd263.exercise.a. CA_OPEN_INVOICES_## (double-click on the view in the SAP HANA Systems pane)
3. Click on the node JoinInvoices in the “Scenario” pane (left hand side)
Screenshot
29
Explanation 4. Add field POSTAL_CODE to the output of the JoinInvoices node Hint: The field POSTAL_CODE appears in both analytical views. Due to the cardinality of the join, you can choose any of them
5. Click on the Projection node
6. Add the fields COUNTRY, POSTAL_CODE, and CITY to the output of the projection node
7. Save and Activate the calculation view Hint: Have a look at the “Job Log” view and make sure that the activation of the calculation view completed successfully
8. Investigate the Data Preview, e.g. via the “Data Preview” icon in the upper right corner or via the context menu as described in the previous exercise C1
Screenshot
30
Explanation
Screenshot Click
9. Click on Raw Data Compared to the result of the data preview in the previous exercise C1, you can now see the columns you just added to the calculation view
10. The next step is to adjust the external view accordingly. Switch back to the ABAP perspective
11. Open your external view ZCA_##_OPEN_INV
12. Press the “Synchronize” button in the upper right corner of the editor to adjust the external view, i.e. to enhance the external view with the new fields. After synchronization, the external view shows the three additional fields, i.e. COUNTRY, POSTAL_CODE, and CITY 13. Activate the external view Note: The additional fields can be inspected via the transaction SE16 (as described in the previous exercise C1)
31
Explanation
Screenshot
14. The last step is to adjust the ABAP report. To do so, open your report ZCD263_##_SHOW_OPEN_INV
15. Enhance the SELECT statement as shown in the screenshot by copying the code snippet below
Code Snippet: ZCD263_##_SHOW_OPEN_INV SELECT bp_id AS customer_id company_name AS customer_name avg_days_open country city postal_code gross_amount_converted AS sum_gross_amount FROM zca_##_open_inv INTO CORRESPONDING FIELDS OF TABLE gt_figures ORDER BY bp_id.
32
Explanation
Screenshot
16. Run the report (press F8). The previously empty fields are now populated
Summary Exercise C2 You have now enhanced a HANA calculation view, synchronized the existing external view accordingly, and adapted the ABAP report for displaying the additional columns in the result set. You are now able to:
Enhance an existing calculation view Synchronize an external view after a change to the underlying HANA database view Enhance the ABAP report and thus the user interface with additional fields
33
Exercise C3 – Call a Database Procedure In this exercise you will call an existing database procedure and write the retrieved data to a list. The used database procedure returns all invoices which are paid on a given date. The invoices consist of header data, item data, product details, and customer details. With one single request to the database, different tables are queried without the necessity to bloat the data as a JOIN would.
Estimated time: 15 minutes
Explanation
Screenshot
1. Switch to the Modeler perspective 2. Click on M33 and
Open the SQL console via the corresponding icon in the “SAP HANA Systems” view 3. Enter a call statement for the database procedure teched.cd263::DP_PAID_IN VOICES_ON_DATE with the data in ABAP’s date format “YYYYMMDD” (e.g. ‘20131027’) and place holders (i.e. a question mark) for each of the four tabular output parameters
Code Snippet call "teched.cd263::DP_PAID_INVOICES_ON_DATE" ( '20131027', ?, ?, ?, ?);
4. Execute the procedure call by pressing the corresponding icon
34
Explanation
5. You will get four result tabs: a. Invoice header data b. Invoice item data c. Product information d. Customer information Note: The screenshot only depicts the Product information
6. Switch to the ABAP perspective
7. Create a new “Other ABAP repository object” in your package ZCD263EX_##
8. Choose the “Database Procedure Proxy” and continue via the "Next" button Hint: As mentioned earlier, you can filter the list by typing e.g. “prox” in the input field
Screenshot
35
Explanation 9. In the dialog window, use ZDP_CD263_##_PAID_INVOIC ES as proxy name, enter a valid description, choose the “HANA Procedure” teched.cd263.DP_PAID_INV OICES_ON_DATE, and continue via the “Next” button Note: The name of the “Parameter Types Interface” ZIF_ZDP_CD263_##_PAID_IN VOICES is added automatically Hint: Try to enter “DP_PAID” in the “HANA Procedure” input field and trigger the auto completion via the shortcut Ctrl+Space
10. Add the database procedure proxy to your transport request and press the “Finish” button
Screenshot
36
Explanation
Screenshot Before
11. In principle, the DB procedure proxy is ready to use now. However, the DDIC does not know that the fields IV_PAYMENT_DATE, ET_INVOICE_HEADERCREATED_AT and Change to ET_INVOICE_HEADERCHANGED_AT contain ABAP dates. In order to add this information, use the “DDIC Type Override” functionality and insert SNWD_DATE for the fields which have D as “ABAP Type”
12. Activate the database procedure proxy
13. Navigate to the generated “Database Procedure Interface” by clicking on the corresponding link
14. In the interface ZIF_ZDP_CD263_##_PAID_IN VOICES you can find the (structure) type definitions you will need later on in the ABAP report
37
Explanation
Screenshot
15. Open report ZCD263_##_DP_PAID_INVOIC ES in your package ZCD263EX_## Hint: You can use the shortcut Ctrl+Shift+A, enter “ZCD263_##” in the search field, and select the report from the “Matching items” list Or use Navigate ->
16. Define the table types for the ABAP internal tables and write the CALL DATABASE PROCEDURE statement Hint: You can make use of the auto completion, just enter the statement including the proxy name, press Ctrl+Space, and then Shift+Enter to generate the signature
Code Snippet: ZCD263_##_DP_PAID_INVOICES DATA lt_header DATA lt_item
TYPE WITH TYPE WITH WITH
DATA lt_customer TYPE WITH DATA lt_product TYPE WITH
SORTED TABLE OF zif_zdp_cd263_##_paid_invoices=>et_invoice_header UNIQUE KEY invoice_guid. SORTED TABLE OF zif_zdp_cd263_##_paid_invoices=>et_invoice_item UNIQUE KEY item_guid NON-UNIQUE SORTED KEY by_header COMPONENTS invoice_guid. SORTED TABLE OF zif_zdp_cd263_##_paid_invoices=>et_customer UNIQUE KEY customer_guid. SORTED TABLE OF zif_zdp_cd263_##_paid_invoices=>et_product UNIQUE KEY product_guid.
CALL DATABASE PROCEDURE EXPORTING iv_payment_date = IMPORTING et_invoice_header = et_invoice_item = et_product = et_customer =
zdp_cd263_##_paid_invoices pay_date lt_header lt_item lt_product lt_customer.
38
Explanation
Screenshot
17. Activate the report, run it (press F8), and choose the payment date, e.g. use the value 14.09.2013
18. You see all invoices with their items, product details, and customer details
Summary Exercise C3 You have now – with only one call to the database – retrieved data from four different database tables. This has been achieved by exposing a HANA procedure as database procedure proxy in DDIC and easily consuming this proxy object in an ABAP report using the new ABAP language statement CALL DATABASE PROCEDURE. You are now able to:
Call a database procedure in the SQL Script console Create a database procedure proxy Override the database’s types to get special ABAP data types like the ABAP date format Call a database procedure from an ABAP program
39
D. ODATA & SAPUI5 Introduction Estimated total time: 40 minutes Objective This exercise is the last phase or our end-to-end scenario: You will now finally build a SAPUI5 application based on the consumption of an external view developed in the previous exercise. From the technical point of view, the external view is consumed via a SAP NetWeaver Gateway OData service, which provides the necessary information to the SAPUI5 application.
Content Exercise D1 – OData service Exercise D2 – SAPUI5 application
Exercise D1 – OData service In this exercise, a SAP NetWeaver Gateway OData service is created for the consumption of the external view ZCA_OPEN_INV_SOL. After creation and registration of the OData service, several possibilities for testing an OData service will be shown. Estimated time: 20 minutes
Explanation
1. Go to the ABAP perspective in the SAP HANA Studio
2. Click to open the SAP GUI (or press Ctrl+6) Hint: Alternatively, you can directly open a transaction using shortcut ALT+F8 and enter the transaction code in the popup window
Screenshot
40
Explanation
3. Confirm with OK
4. Go to the SAP NetWeaver Gateway Service Builder, i.e. insert transaction code SEGW in the OKCODE field and hit the return key
5. Create a new Gateway service
Screenshot
41
Explanation
6. Enter the corresponding information in the dialog window (remember ## is your group number): Project: ZCD263_##_GW_SERVICE Description: Package: ZCD263EX_## Click on the check mark button to continue
7. This exercise uses an external DDIC view as data basis. In order to do so, import a Data Model, i.e. right-click on Data Model and select “Import” > ”DDIC Structure”
8. Insert the external view ZCA_OPEN_INV_SOL as ABAP Structure and hit the return key Hint: Alternatively, you can use the external view ZCA_##_OPEN_INV you’ve developed in the previous exercises
Screenshot
42
Explanation 9. The list of output variables of the external view is displayed. Change the Object Name to Customer Change the Usage of all fields, except for the field BP_ID, from the initial value Key to Property (using the drop-down list functionality) Change the Name of field BP_ID to CustomerId as indicated in the screenshot Continue via the check mark
on the lower right hand side of the screen If you do not have error click on Continue
10. The entity type Customer in the service builder should now be similar to the one shown in the screenshot
Screenshot
43
Explanation
11. Create an entity set based on the entity type Customer, i.e. right-click on “Entity Sets” and select “Create”
12. Create the entity set Customers based on the “Entity Type Name” Customer Click on Continue Hint: You can use the value help for the “Entity Type Name”
13. Go to the newly created “Entity Set” Customers
Screenshot
44
Explanation
Screenshot
14. Check the box “Addressable” Note: You only see “A” as field label. You may want to enlarge the column or use the mouse-over functionality 15. The entity set Customers should now be similar to the one given in the screenshot
Remark: Addressable If the addressable check box is not set, the consumption of the entity set Customers in the SAPUI5 application via the OData service in Exercise D2 will not work
16. Save the Gateway service using the save icon (or press Ctrl+S)
17. You can use your existing workbench request (select from “Own Requests”) or create a new one
45
Explanation
18. In case you selected “Own Requests”, this dialog window opens and you can select a workbench request and continue using the check mark button
19. Confirm the workbench request dialog window(s) Note: You receive two workbench request prompts, one for the GW service (screenshot on the right hand side) and one for the GW model (no screenshot in this document)
20. Next step is to generate the OData provider class, i.e. to generate the runtime objects of your OData service
Screenshot
46
Explanation
21. Confirm the dialog window Note: The dialog displays the name of model and service classes generated for the OData service
22. The generation of ABAP classes necessitates the selection of a package, wherein the classes will reside. Use the package ZCD263EX_## and save
23. In the following dialog window(s), select again your workbench request
24. In the bottom part of the GW service builder you see “Messages” for the successful creation of the model and service classes
Screenshot
47
Explanation
25. Now, let’s do the registration of the created OData service (double-click on M33)
26. “Register” the OData service using the corresponding button
27. Confirm the “Warning!” dialog
28. Enter the system alias LOCAL Hint: The value help might not show the corresponding entry but you can just enter it
Screenshot
48
Explanation
29. In the “Add Service” maintenance window, you need to specify your package ZCD263EX_## in the “Creation Information” section. Continue via the check mark button
30. Successively, three workbench request dialog windows appear, namely for the “Gateway Model Metadata” (shown in the screenshot), for the “Gateway Service Groups Metadata”, and for the “ICF Service”. Use your request as explained above and continue via the check mark button
31. If everything worked fine the status is shown as indicated in the screenshot
32. Now we will implement the actual consumption of the external view in the OData service. Therefore, the GetEntitySet (Query) needs to be implemented
Screenshot
49
Explanation
33. Select “Go to ABAP Workbench” Note: If you receive the information that your project has been modified, save it before you continue
34. Confirm the dialog. You will be forwarded to the source code editor in the ABAP perspective of the SAP HANA Studio
35. You’ll find the initial implementation of class ZCL_CD263_##_GW_SERVI _DPC_EXT as displayed in the screenshot
Screenshot
50
Explanation
Screenshot
36. Insert the method redefinition in the “Protected Section” of the class definition. Hint: You can copy-andpaste the code snippet below the screenshot
Code Snippet: ZCL_CD263_##_GW_SERVI_DPC_EXT METHODS customers_get_entityset REDEFINITION .
37. The light-bulb indicates an issue with the coding. A click on the icon gives the list suggested “quick fixes” and allows to apply the displayed “quick fix” to add the implementation of the CUSTOMERS_GET_ENTITYSE T method
38. Add the implementation of the method CUSTOMERS_GET_ENTITYSE T Hint: You might want to copy-and-paste the coding below the screenshot Note: If you preferred to used your external view, modify the SELECT statement accordingly Code Snippet: ZCL_CD263_##_GW_SERVI_DPC_EXT SELECT * FROM zca_open_inv_sol INTO CORRESPONDING FIELDS OF TABLE et_entityset.
51
Explanation
Screenshot
39. Save and activate the class Remark: At this point the OData service is ready to use. In principle, you can now directly continue with exercise D2. The following steps shows an option, how to test the created OData service. Alternative test options are shown in the Appendix
40. Option Browser: TM Open the Google Chrome Browser via the Windows Start Menu
41. Enter the service URL and hit the return key A logon dialog is displayed, enter your user name CD263-## and password (Welcome1) combination Hint: The URL is given below the screenshot (you need to replace ## with your group number)
URL http://coe-he-083.wdf.sap.corp:50080/sap/opu/odata/sap/zcd263_##_gw_service_srv/?sap-ds-debug=true
52
Explanation
Screenshot
42. The response of the browser should look similar to the html document displayed in the screenshot Hint: Using the option ?sap-ds-debug=true you can navigate, e.g. you can click on the hyper reference to navigate to the entity set Customers
43. The browser response to the mentioned navigation looks similar to the one shown in the screenshot
Summary Exercise D1 Congratulations! You have successfully created, registered, and tested a SAP NetWeaver Gateway OData service based on the consumption of an external DDIC view. Let’s now consume this OData service in a SAPUI5 Application
53
Exercise D2 – SAPUI5 application This exercise shows how to build a simple SAPUI5 application displaying a list of customer information. The necessary data for the user interface is retrieved using the SAP NetWeaver Gateway OData service, which has been developed in the previous exercise. Remark: The following step-by-step description uses the OData service ZCD263_SOL_GW_SERVICE_SRV from the solution package. You may alternatively want to use your own service ZCD263_##_GW_SERVICE_SRV from Exercise D1. Estimated time: 20 minutes
Explanation
1. Go the ABAP perspective in the SAP HANA Studio
2. Right-click into the project explorer pane (just somewhere below the existing project)
3. The first step is to develop the SAPUI5 application locally, i.e. the application will only be available on your local machine (not in the ABAP) backend system. Select “New” > “Other…” (or use the shortcut Ctrl+N) Note: The SAPUI5 application is created locally on your machine. The creation of the necessary objects in the backend will later be performed using the SAPUI5 team provider approach
Screenshot
54
Explanation
4. In the following wizard, use the option “OData Development” > “Starter Application Project” and continue with “Next”
5. Enter the project name ZCD263_##_UI5, select HTML5 from the drop-down box, and continue with “Next”
Screenshot
55
Explanation
6. On the “Starter Application Templates” dialog select the second option (SAPUI5) and continue with “Next”
7. In the next step, the OData service is selected that is used to retrieve the information from the ABAP backend system. In the first step, click on the “Catalog” button to see a list of registered OData services
8. Select the OData service ZCD263_SOL_GW_SERVICE_SRV (or alternatively your OData service) and continue with “OK” Hint: If you don’t find your OData service on the list, you may need to refresh the list using the corresponding icon
Screenshot
56
Explanation
9. In the OData Service dialog, you can now see the Service URL and some service details. Check the information and continue with “Next”
10. The next step is to define the view layout of the SAPUI5 application. Add a view title, e.g. Customer Information The entity set Customers is already selected in the “Entity Set Navigation” Add fields of the OData service to the view using the “+” button
Screenshot
57
Explanation
11. In the “Add Fields” dialog, select all fields (just use the “Select All” button) and continue with “OK”
12. Back in the “List Template View Layout” dialog, use the up- and down-arrow buttons to order the list of fields as shown in the screenshot. This is the last step in the (local) creation of the SAPUI5 application. Click on the “Finish” button to finalize the process
13. So far, only a local version of the SAPUI5 application exists. In order to productively use it, the application needs to be imported into the ABAP backend system, namely into the BSP repository using the SAPUI5 team provider. In order to do so, right-click on the folder in the “Project Explorer” pane
Screenshot
58
Explanation
14. Select “Team” > “Share Project…”
15. Share the project using the “SAPUI5 ABAP Repository” option and continue with “Next”
Screenshot
59
Explanation
16. In the “Share Project” dialog, enter M33 in the connection input field and browse for the ABAP backend connection
17. In the selection window you should only see the connection M33 [PUBLIC], if you have a longer list, either type M33 in the input field or scroll down the list and select the mentioned entry. Continue with “OK”
18. Back in the “Share Project” dialog, you should now see the system connection details to system M33. Continue with “Next”
Screenshot
60
Explanation
19. The connection to the ABAP backend system requires logon credentials. Enter the client 800, your username CD263-## and password and continue with “Next”
20. The import of the SAPUI5 applications requires the creation of a new BSP application in the backend. Use the following information: Name: ZCD263_##_UI5 Description: Package: ZCD263EX_## and continue with “Next”
Screenshot
61
Explanation
21. You are asked for a transport request, just select your request from the list and press “Finish”
22. The following information can just be confirmed (use the checkbox on the right hand side to suppress this dialog) Note: This version check informs you that the version of the SAPUI5 libraries in your Eclipse installation is higher than the ones in the M33 system. For this exercise this does not lead to any unconveniences
23. In the “Project Explorer” pane, the “>” icon indicates that there are local changes in the project which have not been submitted to the backend system
Screenshot
62
Explanation
24. In order to submit the local changes, right-click on the project folder and use “Team” > “Submit”
25. The “Submit Changes” dialog shows the list of objects that will be submitted to the BSP repository. Finalize the submission of files using the “Finish” button
Screenshot
63
Explanation
Screenshot
26. Now, the SAPUI5 application is ready to use and you can test it TM e.g. using the Google Chrome browser and the URL given below Hint: You can retrieve the URL using the transaction SICF in a similar way as for the OData service URL described in the Appendix (use ZCD263_##_UI5 as filter in the transaction SICF and use the service path /sap/bc/ui5_ui5/…)
URL http://coe-he-083.wdf.sap.corp:50080/sap/bc/ui5_ui5/sap/zcd263_##_ui5/index.html?sap-client=800
Summary Exercise D2 Congratulations! You have successfully created and tested a SAPUI5 application using SAP NetWeaver Gateway as OData provider to retrieve data from the SAP HANA database. With this final exercise, you have successfully finished all steps of our end-to-end scenario from SAP HANA entities via their consumption in the ABAP application server to the display in a SAPUI5 application!
64
Appendix Additional Material for Exercise D1 Exercise D1 describes how to test the OData service in the Browser. In addition, this appendix shows two more options for testing OData services, i.e. using the transaction SICF or the “SAP NetWeaver Gateway Client” transaction /iwfnd/gw_client.
1. Option SICF: Go to the ABAP perspective in the SAP HANA studio, open a SAP GUI, and go to transaction SICF Hint: You may have asked yourself where to retrieve the service URL. This option allows for retrieving it
2. Enter your OData service name, e.g. ZCD263_##_* and hit F8 or click on the corresponding icon
65
3. Select your OData service and test it using the “Test Service” routine TM
Hint: The Internet Explorer might be the default browser on your system. You can then either copy the service URL to the TM Google Chrome browser or proceed via “Open as…” and TM select the Internet Explorer
4. For the test of the OData service logon credentials are required. Enter your username (CD263-##) and password combination in the authorization dialog window and continue with “OK”
5. Option SAP NetWeaver Gateway Client: Another option is to use the “SAP NetWeaver Gateway Client”. For this option, go to the ABAP perspective of the SAP HANA studio, open a SAP GUI, and go to the GW client transaction /iwfnd/gw_client Note: The transaction code must be prefixed with /n or /o
66
6. Enter the “Request URI” in the input field and hit execute (or press F8)
You may want to copy (and replace ## with your group number): /sap/opu/odata/sap/zcd263_##_gw_service_srv/Customers
7. The expected response of the http request can be seen in the “HTTP Response” window of the screenshot
Thank you for participating in this SAP TechEd Virtual Hands-On Workshop! Please, take a few minutes to answer a couple of feedback questions concerning your session. Find a shortcut to the survey on the desktop of your virtual laptop image or visit https://www.sapsurvey.com/cgi-bin/qwebcorporate.dll?idx=FSQCZ7.
67
Enterprise Procurement Model (EPM)
68
ADT Shortcuts If you are using a remote desktop session some of the shortcuts will not work!
Edit Ctrl+Shift+A Open development object Ctrl+F2 Check development object Ctrl+F3 Activate development object Ctrl+Shift+F3 Activate all inactive objects Ctrl+Space Code completion Ctrl+1 Quick fix proposal Ctrl+< Add comment Ctrl+Shift+< Remove comment Shift+F1 Format source aka pretty printer Help F1 ABAP keyword documentation F2 Show code element information Ctrl+3 Search for commands & views Ctrl+Shift+L List all keyboard shortcuts Navigate
F3 Open definition Alt+Left Backward history Alt+Right Forward history Ctrl+T Quick hierarchy F4 Open Type Hierarchy Ctrl+O Quick outline Ctrl+Shift+G Where-used list Run, Debug
F8 Run current ABAP object Alt+F8 Select & run ABAP application Ctrl+Shift+B Toggle breakpoint F5, F6, F7, F8 Step into, over, return, resume
© 2012 by SAP AG. All rights reserved. SAP and the SAP logo are registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo are trademarks or registered trademarks of Business Objects Software Ltd. Business Objects is an SAP company. Sybase and the Sybase logo are registered trademarks of Sybase Inc. Sybase is an SAP company. Crossgate is a registered trademark of Crossgate AG in Germany and other countries. Crossgate is an SAP company.
View more...
Comments