Developer’s Journal: ABAP Search Help For HANA Data

by on May 1, 2012 at 12:35 pm

Introduction

In the last blog, I discussed techniques for accessing the HANA Catalog information from ABAP and how to create an ABAP internal table from a HANA object without a matching data dictionary object. You can probably tell that I’m building up to a tool which can function as a generic HANA catalog viewer, showing both metadata about HANA database objects and a content preview. Before I build that tool, I want to make selection of the catalog objects as simple as possible. Therefore I would like to implement an ABAP Search Help which gets its data from HANA instead of the underlying ABAP database. Ultimately I want it to work in the UI like the following video. Please note: I’m running NetWeaver 7.31 so I have the SuggestValues feature which was new in NetWeaver 7.02.  However ultimately the solution here is a normal Data Dictionary Search Help which could be used on any ABAP release level.

The source code for this example can be downloaded here. It contains the Search Help defintion, the Function Module/Group for the Search Help exit implementation and the DDic Structure with the search help binding which allows the connection between the importing parameters. Please note that you will also need to download the source code content from my previous blog as well.

Search Help Exit

Normally when an ABAP developer implements a Search Help, they only supply the name of the underlying table or view and all the selection work is done for them by the Search Help framework. In this case, however, I needed complete control over the selection logic so that I could use ADBC and my HANA Catalog Utility class from the previous blog in order to query the HANA database for available objects.

The definition of the Search Help itself isn’t all that special in this case. I need to know the currently selected Database Connection, Schema, and Object Type (Table or View) in order to perform a query. Therefore I map these fields as my importing parameters for the Search Help.

The major difference comes in the fact that the selection method is blank in this search help.  Instead I supply the name of a function module – ZHANA_OBJECT_SEARCH as the Search help exit. This function module must have a pre-defined interface, but can then function as the implementation of my search help.

Search Help Exit Function Module

All search help exit function modules, must have the same function interface so that it can be called by the search help framework.

 function zhana_object_search.
 *"----------------------------------------------------------------------
 *"*"Local Interface:
 *"  TABLES
 *"      SHLP_TAB TYPE  SHLP_DESCT
 *"      RECORD_TAB STRUCTURE  SEAHLPRES
 *"  CHANGING
 *"     VALUE(SHLP) TYPE  SHLP_DESCR
 *"     VALUE(CALLCONTROL) LIKE  DDSHF4CTRL STRUCTURE  DDSHF4CTRL
 *"----------------------------------------------------------------------

There are various control steps in the processing of the search help exit which can be used to over ride processing of the various search help events. The only one which we need to implement in this case is the callcontrol-step of SELECT. This is the primary query event of the search help. From this event we can read the current importing values from the shlp-selopt table.

 if callcontrol-step = 'SELECT'.

     data lr_model type ref to zcl_hana_catalog_utilities.
     data ls_search type zhana_obj_search.
     field-symbols <ls_selopt> type ddshselopt.
     data lx_root type ref to cx_root.

     read table shlp-selopt with key shlpfield = 'CON_NAME'
         assigning <ls_selopt>.
     if sy-subrc = 0.
       ls_search-con_name = <ls_selopt>-low.
     endif.
     read table shlp-selopt with key shlpfield = 'SCHEMA'
         assigning <ls_selopt>.
     if sy-subrc = 0.
       ls_search-schema = <ls_selopt>-low.
     endif.
     read table shlp-selopt with key shlpfield = 'OBJ_TYPE'
         assigning <ls_selopt>.
     if sy-subrc = 0.
       ls_search-obj_type = <ls_selopt>-low.
     endif.
     read table shlp-selopt with key shlpfield = 'OBJ_NAME'
         assigning <ls_selopt>.
     if sy-subrc = 0.
       ls_search-obj_name = <ls_selopt>-low.
     endif.

Now that we have all of our search input criteria, we can use the HANA Catalog Utilities class from the previous blog to search for all tables or views which match those criteria.   Here is a subset of that logic.  See the downloadable source code sample for complete implementation.

         create object lr_model
           exporting
             iv_con_name = ls_search-con_name.

         if ls_search-obj_type = 'T'. "table
           data lt_tables type zhana_tables.
           field-symbols <ls_table> like line of lt_tables.

           lv_table = ls_search-obj_name.
           lt_tables = lr_model->get_hana_tables(
               iv_schema   = lv_schema    " Schema
               iv_table    = lv_table     " Table (can be wildcard with %)
               iv_max_rows = callcontrol-maxrecords ). " Maximum Number of Rows
 ****Map to LT_SHLP
           loop at lt_tables assigning <ls_table>.
             append initial line to lt_shlp assigning <ls_shlp>.
             <ls_shlp>-con_name = ls_search-con_name.
             <ls_shlp>-obj_type = ls_search-obj_type.
             <ls_shlp>-schema   = ls_search-schema.
             <ls_shlp>-obj_name = <ls_table>-table_name.
           endloop.
         else.

The final activity is to place the query results back into the search help. This is done by calling the function module  F4UT_RESULTS_MAP.

     call function 'F4UT_RESULTS_MAP'
       exporting
         source_structure   = 'ZHANA_OBJ_SEARCH'
 *       apply_restrictions = abap_true
       tables
         shlp_tab           = shlp_tab
         record_tab         = record_tab
         source_tab         = lt_shlp
       changing
         shlp               = shlp
         callcontrol        = callcontrol
       exceptions
         illegal_structure  = 1
         others             = 2.
     if sy-subrc <> 0.
     endif.

Structure for Parameter Mapping

The final step in order to get the input parameter mapping shown in the video to work within Web Dynpro is to map the search help into a data dictionary structure and the use that structure for the basis of the Web Dynpro Context Node.  The importing parameters from other attributes in this Context Node will then be transferred automatically by the framework (even for Suggest Values).

You can make the explicit assignment of the new search help to the OBJ_NAME field and then use the Generate Proposals button to automatically map the input fields of the search help to the corresponding fields of the structure.

The final step is to use this structure as the source Dictionary structure of the Context Node and you have the Value Help working as described in the video at the opening of this blog.

 

 

 

Posted in Blog .


Add a comment




Learning Content to Use With the New ABAP 7.02 Trial

by on December 13, 2010 at 4:21 pm

With the recent release of the ABAP 7.02 trial edition, many people might be looking for good learning materials and demos to try out all the new functionality available in this release level.  In this blog I try to collect some of these sources.

SCN Content

One of your first stops after installing the ABAP 7.02 trial (or if you are looking for something to read during the installation process), should be the new functions and features page here on SCN. It does a nice job of summarizing the high level feature areas and give you an excellent starting point to perform further research.

There have also been several blogs released in the last week, all focused on the 7.02 ABAP topic and of the things you can try in 7.02 once you have the trial installed.

All of these provide great starting points, particularly for learning new ABAP syntax or workbench capabilities.

Although not directly SCN hosted, it’s probably important to note that the 7.02 version of help.sap.com is now live. I personally find the New Features section of the online help useful when learning the delta features.  For example if you want an overview of the new functionality in Web Dynpro ABAP in 7.02, here is the link you should start with on help.sap.com.

TechEd 2010

TechEd was also a great source of information on the new features in ABAP 7.02.  Don’t forget that many of the sessions were recorded and can be viewed at any time. These sessions can be viewed here: http://www.virtualsapteched.com/

Particularly on the topic of new features you want to learn about in this trial, you might watch the replays of CD105 – What’s New in Web Dynpro ABAP 7.01 and 7.02 and CD203 – Best Practices for Designing Web Dynpro ABAP User Interface.

If you attended TechEd this year, you might have noticed that we didn’t give out the source code to the attendees for many of the usual workshops.  This was mostly because the source code was based upon NetWeaver 7.02 and without a trial edition at that release level yet, it wouldn’t do anyone much good.  Thankfully we now have the 7.02 trial, so we have started uploading some of the code to the SAP Code Exchange.

I have created a Code Exchange project to house transports that can be imported into the 7.02 to deliver some of the demos and exercises we used at TechEd: https://cw.sdn.sap.com/cw/groups/sap-teched-2010-abap-702-examples-and-demo

image

Currently I have uploaded the content from CD160 – Introduction to Web Dynpro ABAP, CD105 – What’s New in Web Dynpro ABAP 7.01 and 7.02, CD203 – Best Practices for Designing Web Dynpro ABAP User Interfaces, and CD266 – Update Your ABAP Development Skills to NetWeaver 7.0 and Beyond.

If you access the Code Exchange project and go to the Releases tab (after accepting the Terms of Usage), you will see individual download files. Each contains ABAP transport files for the various areas covered.  There is a file for all the CD266 Exercises and the CD160 exercises.  There are also transports for the various demos, such as the performance demos used in CD203 or the Flash Islands and Silverlight Islands demoed in CD105.

If you need any general advice on how to import transports into the trial edition ABAP AS, I would recommend this blog: http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6380.  Its a little bit older now and focused on an early release level, but the overall process of performing transports is sound.

SAP Press Book

If you are interested in the 7.02 features for ABAP development, then (at the risk of some self promotion) I would also recommend the new SAP Press book – Next Generation ABAP Development 2nd Edition, which is scheduled to begin shipping in early January. This new edition of the book was extended and revised specifically to cover the new features in ABAP development in NetWeaver 7.01 and 7.02. For example, the syntax all throughout the book has been updated to include the new statement chaining and extended expressions possible in NetWeaver 7.02.  There are also completely new topics like Business Objects integration, BRF+, Page Builder, Islands, etc.

The book also comes with a CD that contains the source code of all the projects discussed in the book – source code that you can now actually install and run thanks to the recent release of the 7.02 trial edition.

UPDATED: For a limited time you can use discount code NEXTGENABAP to get a 10% discount on the book when you order from the SAP Press website.

image

Posted in Blog .


5 comments




ABAP Freak Show – Introduction to Web Dynpro ABAP

by on August 3, 2010 at 5:37 pm

You might be wondering why I decided now was a good time to record an ABAP Freak Show series on the basics and architecture of Web Dynpro ABAP. After all shouldn’t I be busy with SAP TechEd 2010 preparations. As it turns out, the two are closely related. As custom development track lead for SAP TechEd 2010, I had the opportunity to really expand the amount of Web Dynpro ABAP development that was offered this year. At the same time I still had to work within budget restrictions. For example I really wanted to have a 4 hour hands-on for Advanced Web Dynpro ABAP. As it turns out I ended up having to break this topic up into 2 – 2 hour lectures and a 2 hour hand-on. I actually ended up with more content hours for Web Dynpro ABAP in the end by running out of 4 hour hands-on slots.

Not all the budgets restrictions worked out as nicely. I really needed to cut a 1 hour lecture. We have been presenting the introduction to Web Dynpro ABAP since 2005 (or some form even before then). I remember going to this session when I was still at customer working at Kimball International. Therefore it became a prime target for our reduction efforts.

In past years we have conducted a 1 hour lecture and a 4 hour hands-on for the introduction to Web Dynpro ABAP. The slides and presentation material are the same between these two sessions and often attendees went to both. Last year I taught both the lecture and hands-on version. By the end of the week in Las Vegas after presenting the same basic material 4 times in as many days, I was pretty sick of hearing it. I would imagine people that attended both the lecture and hands-on sessions probably felt similar.

Therefore we made a decision to no longer offer the 1 hour lecture version. As many customers are still just experiencing Web Dynpro ABAP for the first time as their companies upgrade we want to support their efforts. The 4 hour hands-on will remain. It is session CD160 (Las Vegas / Berlin). We believe that the time spent hands-on with the development environment is one of the best ways to learn the tool.

We didn’t completely discard the lecture version of the materials, however. Instead we decided the best way to service those who wish to begin learning Web Dynpro ABAP is to provide these materials as eLearning Videos all the time (for free) on SDN and Enterprise Geeks. So now you can study these introductory materials any time you want. Then come to TechEd and enforce what you learned via a Hands-On session or built up to try one of the more advanced Web Dynpro ABAP sessions.

Posted in Blog .


Add a comment




ABAP Freakshow – July 29, 2010: Introduction to WDA Part 7

by on July 29, 2010 at 4:29 pm

This eLearning explains in depth the Web Dynpro programming model and how to develop Web Dynpro applications within the ABAP workbench. In this seventh and fial part we explorer integration possibilities in the form of NetWeaver Portal, NetWeaver Business Client, Interactive Forms by Adobe and Flash Islands.

Posted in ABAP Freak Show and eGeek TV .


Add a comment




ABAP Freakshow – July 29, 2010: Introduction to WDA Part 6

by on at 4:27 pm

This eLearning explains in depth the Web Dynpro programming model and how to develop Web Dynpro applications within the ABAP workbench. In this sixth part we look at multiple component usage and navigation plugs.

Posted in ABAP Freak Show and eGeek TV .


2 comments