Quantcast
Channel: SCN : Blog List - ABAP for SAP HANA
Viewing all 99 articles
Browse latest View live

Code Push Down for HANA Starts with ABAP Open SQL

$
0
0

What is Code Push Down?

One of the key differences for developing applications in ABAP for HANA is that you can push down data intense computations and calculations to the HANA DB layer instead bringing all the data to the ABAP layer and the processing the data to do computations. This is what is termed as Code-to-Data paradigm in the context of developing ABAP applications optimized for HANA.

 

Where does Code Push Down Start?

It is a general misconception that if one wants to do code push down in ABAP for HANA you always need to either use HANA native SQL or build complex HANA artefacts in order to achieve this.

But in reality the Code Push Down for HANA  from ABAP can very well start with ABAP Open SQL. Let us see How and Why?

 

The New Enhanced Open SQL

It has been SAP's constant endeavour to improve Open SQL with each release of ABAP Application Server in order make it the most efficient channel for accessing data  in a manner that is database agnostic.

Since the release of NW AS ABAP 7.4 SP5 this attempt has manifested in the form several cool and advanced features letting go of many earlier limitations from open SQL


"Change is the Only Constant" - Heraclitus

In order to make use the advanced features of Open SQL one needs to accommodate a minor change in the way we have been writing Open SQL statement for a while now.

 

SELECT so_id AS sales_order_no,       currency_code,       gross_amount,   FROM snwd_so  INTO TABLE @lt_so

As shown in the above code snippet the most significant changes are the following in terms of the syntax

  1. The column list needs to be separated by commas
  2. The  host variables used within the open SQL statement needs to be escaped by an "@" symbol

In order to extend the existing functionalities of open SQL with new features a minor change had to be incorporated with the syntax hence this change.

But for sure we all would agree that positive changes are always welcome

 

Old is Gold but New is Platinum

The existing Open SQL statements with the old syntax will remain intact and syntactically valid. But if you want to make use of some of the advanced features of the new Open SQL you need start using the new syntax. Below is a summary(but not a complete list) of some of the new features supported in Open SQL,

 

Extended features supported by the new Open SQL

Following are a couple of new features supported by extended Open SQL syntax

  • Support for arithmetic expressions and computed columns in the projection list.

Remember the days when you need to loop through the internal table fetched using the Open SQL statement in order to compute/derive the value for an additional column. You don't have to do that any more. You can have computed columns part of the projection list.


  • Support for string expressions part of the project list

       You can now have string expression with in your projection , for instance to create new concatenated column using columns from the tables accessed 

This is only the tip of the ice berg for a more comprhensive list of all new features supported by the latest Open SQL syntax refer to the following link

Code Push Down for HANA using Open SQL

As it is already evident with the extended syntax for Open SQL , the new Open SQL still remains preferred approach for Code Push Down to HANA and it very diligently augments and supports the other optimization techniques like AMDP and CDS.


What are the advantages of using Open SQL to do code push down?

  1. Your ABAP code will remain database agnostic and will run on any ABAP server independent what is the underlying database
  2. You implicitly take advantage of all transparent optimizations that have been achieved in the Database Interface level
  3. All default performance optimizations like use of buffer and house keeping activities like client handling etc are automatically taken care of

 

5 Ways of achieving Code Push Down to HANA from ABAP using Open SQL

  1. Let us first get started Start using the new Open SQL syntax. Remember it is easy to convert your existing Open SQL statements to new syntax without any side effects.
  2. Use aggregate functions where relevant instead of doing the aggregations in the ABAP layer
  3. Use arithmetic and string expressions within Open SQL statements instead of looping over the data fetched to do the arithmetic and string operations
  4. Use computed columns in order to push down computations that would otherwise be done in a long loops
  5. Use CASE and/or IF..ELSE expressions within the Open SQL in order embed the logic of conditional expression which in the past would have been done after fetching the results from the database.

If you want to play around with the new Open SQL syntax we have cool new feature in the latest released version of ABAP in Eclipse called "SQL Console". To know more about this feature refer to my colleague Vijayan Balasubramanianblog on the new SQL Console in AiE here.


Get "Involved"

Do you want to have the first hand experience of the latest Open SQL features in addition to other exciting features for ABAP Development for SAP HANA? If you say yes, why do you wait?

Get enrolled for the Open SAP course on ABAP Development for SAP HANA and get "involved"  and be part of the exciting journey.

Wishing you loads of fun!!!

 

 

Tell me, and I will forget. Show me and I may remember. Involve me, and I will understand.Confucius


Lets explore AMDP - What is happening ?

$
0
0

Introduction


AMDP(ABAP managed database procedures) enables coding SQL Script inside an ABAP Class method directly. OK, we are writing it inside the class methods, but where it is getting executed ? Answer is HANA Database for sure. How it is happening ? Let us explore.

 

Create a AMDP enabled class

 

Here I created a AMDP enabled class and wrote necessary implementation as below(Please don't look into the logic. Its all weird ).

class.JPG

Now I activated the class and executed the method GET_MATERIAL_DESC.

For each of the exporting variables specified, it created  SQL Views in the ABAP Schema .

 

view.JPG

(Did you  notice the View name)

 

For each of the methods we are creating in the AMDP class, it will create 2 database procedures in the HANA DB. Both the view creation and procedures creation will be done when the class method is used first.(That is when it is executed for the first time - This make sense. Now it is so easy to transport the developments to Quality or Production system. We don't need to bother about the HANA here ) .

Lets go the procedures created by it.

procedure1.JPG

     1.CLASSNAME=>METHODNAME Procedure

          This procedure will contain the actual logic which we have written inside the AMDP Class method. Only difference is, it will replace the objects specified in the USING clause with the view name.

procedure2.JPG

     2.CLASSNAME=>METHODNAME#stub#timestamp procedure

          This procedure is a wrapper procedure for the real one created . This procedure will call the first procedure and project the returned result set.

               procedure3.JPG

Limitations of AMDP - Why is it so ?

     Below are some key limitations of AMDP classes. Let us see, why it is so.

       

            1.Methods with returning parameters cannot be implemented as AMDPs : A Procedure does not return anything. Which exports multiple outputs.

            2.Method parameters have to be tables or scalar types - No Single line concept here in procedure returns.

            3.Method parameters have to be passed as values : Well, how you will pass it by reference from ABAP to HANA SQL Script ?

 

Regards

Sreehari

    

New in AS ABAP 7.4 SP8 - Use of Secondary Database Connection when calling AMDP Methods

$
0
0

Just a recap of ABAP Managed Database Procedures (AMDP)   another amazing feature for code push down introduced in AS ABAP 7.4 SP5,

AMDP allows you to do code-push down to HANA and is ideal in cases where there is  scope for making use of HANA specific features during code push down. AMDPs enable you to create database procedures directly in ABAP using e.g. SQL Script and to seamlessly integrate it in modern ABAP development. An AMDP can be implemented using an ABAP method.


An overview about the new AMDP features introduced in AS ABAP 7.4 SP8 byHorst Kellercan be found hereABAP News for 7.40, SP08 - ABAP Managed Database Procedures (AMDP)

 

In general AMDP methods when called are executed on SAP standard database (primary HANA database). From AS ABAP 7.4 SP8 onwards it is possible to call AMDP method implementation by specifying a database connection explicitly

 

Special Input Parameter

  • An input parameter with the name connection and type DBCON_NAME needs to be declared for an AMDP method.
class zcl_demo_amdp definition  public  final  create public .  public section.    interfaces if_amdp_marker_hdb .    methods increase_price      importing                value(connection) type dbcon_name default ''                value(clnt)       type sy-mandt                value(inc)        type sflight-price      raising   cx_amdp_error.
endclass

Calling the AMDP Method with Connection information

    • Pass initial value or the value "DEFAULT" to use the standard database connection
    • Pass as value a name "R/3*name"(With prefix “R3*” in upper case letters and a user-defined name “name” (case sensitive)) to use a service connection of this name “name”


    ****  Call using Standard Database Connection(Primary HANA DB)    lo_amdp_demo->increase_price(      exporting        connection    = 'DEFAULT'        clnt          = '000'        inc           =  10    ).  
    ****  Call using named Database Connection "SECDB"    lo_amdp_demo->increase_price(      exporting        connection    = 'R/3*SECDB'        clnt          = '000'        inc           =  10    ).

    Restricted Names

    The names "R/3*AMDP_SYNC" and "R/3*AMDP_ADBC" are reserved for the AMDP framework and would lead to exceptions at runtime if used.

    REPLICATE PROGRAMMATICALLY FROM NON SAP Schema to SAP Schema

    $
    0
    0

    Scenario : In many cases, we don't have privileges to execute DML operations [mainly update, delete and insert] on SAP<SID> schema’s tables using database user. In this case, we have to execute DML operations on SAP<SID> schema’s tables through ABAP Statements. In one of my project’s scenario, we have to replicate data from table [ABC] resides in ECCSLT schema into table [ZABC] resides in SAP<SID> schema [Let’s say schema SAPABC].In this case, we have used NATIVE SQL to fetch data from ABC, then put it into ABAP internal table then inserted into ZABC using ABAP statement. Let’s suppose, ABC has more than 200 columns and in order to form native SQL, we have to concatenate all the columns. We can use function module ‘'DDIF_FIELDINFO_GET’ to get the structure of the table,then form the native SQL accordingly.


    Here is the program for the above use-case.

     

      REPORT ZIMPORT_INTO_SAPABC.

      DATA:
    lv_sql
    TYPE string value  ' select 000 as MANDT ,    ',
    lo_stmt
    TYPE REF TO cl_sql_statement,
    lo_result
    TYPE REF TO cl_sql_result_set,
    lr_sql_data
    TYPE REF TO Data,
    lx_root
    TYPE REF TO cx_root,
    mo_hana_conn
    type ref to cl_sql_connection,
    lv_no_of_length
    type i .
    DATA: BEGIN OF INTTAB OCCURS 250.
    INCLUDE STRUCTURE DFIES.
    DATA: END OF INTTAB.
    CREATE DATA lr_sql_data TYPE table of ZABC.
    mo_hana_conn
    cl_sql_connection=>get_connection( con_name = 'ABC' ).
    TRY .
    lo_stmt
    = mo_hana_conn->create_statement( ).
    data  TABLENM TYPE DDOBJNAME   value 'ZABC'.
    call function 'DDIF_FIELDINFO_GET'
    exporting
    tabname             
    = TABLENM
    LANGU               
    = SY-LANGU
    TABLES
    DFIES_TAB           
    = INTTAB
    EXCEPTIONS
    NOT_FOUND           
    = 1
    INTERNAL_ERROR      
    = 2
    OTHERS               = 3.

    if sy-subrc <> 0.
    WRITE:/ 'Field name not found'.
    endif.

    LOOP AT INTTAB.
    if INTTAB-fieldname ne 'MANDT' .
    concatenate lv_sql '   ' SPACE  INTTAB-fieldname ' , '   into lv_sql .
    endif.
    ENDLOOP.
    lv_no_of_length
    = STRLEN( lv_sql ).
    lv_no_of_length 
    = lv_no_of_length - 1 .
    lv_sql
    substring( val = lv_sql off = 0 len = lv_no_of_length ) .
    concatenate lv_sql SPACE  ' from '  SPACE  ' ECCSLT.' ABC’into lv_sql .
    lo_result
    = lo_stmt->execute_query( statement = lv_sql ).
    lo_result
    ->set_param_table( itab_ref = lr_sql_data ).
    lo_result
    ->next_package( ).
    lo_result
    ->close( ).

    field-symbols: <ls_sql> type any table.
    assign lr_sql_data->* to <ls_sql>.
    delete from ZABC.
    modify ZABC from table <ls_sql> .
    CATCH cx_root INTO lx_root.
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception
    EXPORTING
    previous
    = lx_root.
    ENDTRY.

    SAP HANA as Secondary Database

    $
    0
    0

    Small Introduction to SAP HANA - As and when time passes, everyday transactions are increasing, maintaining volume of data became too much load in applications and systems, Finally conventional RDBMS becoming obsolete! Here, Big data concepts knocked the door, eventually SAP started adopting IMDB (In-memory Data base) techniques and introduced HANA (High-Performance ANalytic Appliance) for all these kind of problems.

     

    Initially, HANA developed and targeted for OLAP systems. Now, Accessing HANA schema and Information models (Attribute, Analytic and Calculation views) to OLTP (i.e. SAP ECC/ERP) system has became viable and cost-efficient option. We are going to deal this now (HANA as Secondary Database).

     

    Secondary_DB_architectur.png

    AS ABAP is running on a traditional RDBMS can access SAP HANA by means of a secondary database connection.

     

    With SAP business suite on HANA, HANA is used as the Primary database for transactional (OLTP) systems by facilitating a integration of ABAP developments with HANA and leverage the strengths of SAP HANA within the application logic.

     

    In order to leverage the performance advantage of the SAP HANA database for existing ERP customers without changing existing ERP applications!
    Typically, following situations/scenarios need to be considered SAP HANA as secondary database.

    • Improving the few important reports performance
    • Access the aggregated (Where HANA is stronger with the help of Calculation engine) data from HANA Information Models
    • Real time data analysis in OLTP system (HANA as a Side-car approach)
    • Creation of Custom Accelerators

    Pre-Requisite(s):

    • SLT (SAP Landscape Transformations) Replication between primary and secondary Database
    • Create a logical connection name, DB user, password and connection using DBACOCKPIT in ECC system
    • Replicate appropriate tables to HANA DB

    Below are the two approaches would like to adopt as per the situation.

    1. Native SQL ADBC Approach
    2. Business Application Accelerator (RDA Approach)

     

    Native SQL ADBC Approach: ADBC stands for ABAP Data Base Connection. It is a Class-based API (Application Program Interface) for the Native SQL Interface that allows object orientated and dynamic access to the Native SQL interface. ADBC API Framework makes an object orientated and dynamic access possible.

     

    Business Application Accelerator (RDA Approach): RDA stands for Redirected Database Access. The SAP Business Application Accelerator powered by HANA provides a possibility to run applications in a way that data from performance critical tables is read from a SAP HANA database (Secondary) containing replicated data.

     

     

    We will continue and elaborate the steps and process involved in these two approaches..

    New ABAP for HANA features in SAP NW 7.4 SP08

    $
    0
    0

    With the newly released AS ABAP 7.4 SP8 we have further enhanced the features relevant for Code-Push-Down and DB-Near Programming. The focus has been further strengthen the ABAP Platform as the Sole-Master for all optimized development for HANA. Regarding all the new features introduced in the last release AS ABAP 7.4 SP5 take a look at this blog: New ABAP for HANA features in SAP NW 7.4 SP5

    So what is inside this release for ABAP on HANA developers?



    Advanced Open SQL

    Open SQL is a DB abstraction layer in ABAP that defines a common semantic for all SAP supported databases.

    Several limitations concerning the Open SQK in terms of support standard SQL features (SQL92) have been removed starting with ABAP 7.4 SP05 in such a way that Open SQL can be used with the new advanced features for access to SAP HANA and as well as other database platforms.

    Adv_Open_SQL_features.JPG

        

     

     

    The key idea here is that the Code Push-Down for HANA can start with ABAP Open SQL with the advanced features of Open SQL.

    With NW AS ABAP 7.4 SP8 there are several new features in addition to what was made available in NW AS ABAP 7.4 SP5.

    Just name few of the features that have been introduced,

    • New column specification data_source~* after SELECT statement
    • Inline declarations for target range of SELECT statement
    • New SQL expressions
    • Consumption of parameterized CDS views

    You could also use the Brand new Open SQL Console to play around with the new features of Open SQL.An overview about the new Open SQL features introduced in AS ABAP 7.4 SP8 byHorst Kellercan be found hereABAP News for 7.40, SP08 - Open SQL



    New Features in CDS

    Alongside the advances in the Open SQL CDS was also offered starting AS ABAP 7.4 SP5 as the next generation model for database access with the goal simplifying and harmonizing the way how data models are defined and consumed independent of the consumption technologies. This is yet another avenue for optimized database access and code-push down to the database.

    A nice introduction to the new data modeling capabilities supported by ABAP CDS by Christiaan Edward Swanepoelis available in this blog: New Data Modeling Features in SAP NW ABAP 7.4 SP5

    An overview about the new CDS features introduced in AS ABAP 7.4 SP8 byHorst Kellercan be found hereABAP News for 7.40, SP08 - ABAP Core Data Services (CDS)

     

    Advanced Open SQL vs CDS – When to use What?

    The advanced Open SQL and CDS are meant  to complement each other not  compete

    Here is short guideline on when to choose which technology

    Choose Open SQL when,

    • There is no re-use need for the query
    • There is a need to access system fields, e.g., sy-mandt
    • There is a need for features only available in Open SQL, such as FOR ALL ENTRIES

    Choose ABAP CDS when,

    • There are re-use possibilities of the defined view
    • Scope for use of DDL features not available in Open SQL currently

    Enhancements to AMDP

    Just a recap of ABAP Managed Database Procedures (AMDP)   another amazing feature for code push down introduced in AS ABAP 7.4 SP5.

    AMDP allows you to do code-push down to HANA and is ideal in cases where there is  scope for making use of HANA specific features during code push down. AMDPs enable you to create database procedures directly in ABAP using e.g. SQL Script and to seamlessly integrate it in modern ABAP development. An AMDP can be implemented using an ABAP method.

    More details about AMDP can be found in this document ABAP Managed Database Procedures - Introduction and the video tutorials in our YouTube Channel: ABAP for SAP HANA - YouTube.

    The beauty of using AMDP is that fact that ABAP remains the sole master for managing the entities for code push down but at the same time the application can take advantage of consuming HANA specific features using AMDP.

     

    With the AS ABAP 7.4 SP8 release AMDPs have further been enriched with the following features,

    • AMDP methods can now be enhanced using BAdIs
    • Catchable and handleable exceptions provided for AMDP methods
    • AMDP methods can now access the secondary databases
    • AMDP methods now support tabular changing parameters

    An overview about the new AMDP features introduced in AS ABAP 7.4 SP8 byHorst Kellercan be found here ABAP News for 7.40, SP08 - ABAP Managed Database Procedures (AMDP)

     

    ABAP Development Tools in Eclipse

    With the latest release of ADT the ABAP Development on HANA becomes even more exciting. The new version the tool has several features that make the developer’s experience more fun filled and productive

    Just to name a few,

    • Better integration of ATC into AiE for different lifecycle stages of development
    • Support for incremental development
    • Better assistance for fixing errors during development using quick-fixes

    An overview of the new IDE features available with the latest version of the ADT tool byThomas Fiedler  can be found hereADT 2.31 - New version of ABAP Development Tools available now

     

    I hope the news about the latest features introduced with AS ABAP 7.4 SP8 excites you. The new AS ABAP 7.4 SP8 Developer Edition is already available since 25th September 2014 - See here for more details Developer & Trial Editions: SAP NetWeaver Application Server ABAP and SAP Business Warehouse powered by SAP HANA for more details. Please check back on this ABAP for SAP HANA for detailed information of the new features and how-to use them.





    Something new, something old...

    $
    0
    0

    People of the ABAP for SAP HANA tribe listen up!

    Or better: read up!

     

    When you logged in to your favorite SCN Space, did you notice any change?

    In case you need a little hint to what I am asking about, consider the following screenshots of the ABAP for SAP HANA space overview page (big red arrow included for ease of discovery):.

     

     

    Before last weekend

    before.png

    After the last weekend

    after.png

    Effective today the fabulous Jasmin Gruschke takes over the role of the space moderator from me.

     

    A big thanks for the big effort you already put into this community by patiently providing answer after answer to all sorts of questions around ABAP programming on SAP HANA.

    From now on you can move stray messages to the correct spaces, like SAP HANA and In-Memory Computing for all core SAP HANA topics.

    So that's the "news".

     

    The "old", I mentioned in the title, is that Jasmin will continue to bring her vast topic expertise into this community.

     

    If we would be on a stage I would ask everybody now to make some noise for our newly conceived moderator.

    (Don't feel stopped if you still want to give a round of applause in front of your screen - if you do, please record it with your webcam and upload it here!)

     

    Welcome and thanks again!

    Next stop then would be Mentor, I guess

     

    Cheers, Lars

    openSAP course "ABAP Development for SAP HANA" now in self-paced mode

    $
    0
    0

    Good or bad news?

     

    The openSAP course ABAP Development for SAP HANA successfully launched on September 25th, 2014 with 16695 learners enrolled on day 1 of the course, a number that increased to22952 (incredible!) when the final exam ended on November 10th, 2014.

     

    But that's not the end... the course switched to "self-paced" mode now.

     

    What does that mean?

     

    After the end of a course, the materials remain available in the self-paced area. The only difference is that you can no longer contribute to the discussion forum or earn a Record of Achievement and Confirmation of Participation - but apart from that, you can still learn all the interesting things about ABAP Development for SAP HANA, so join us today!

     

     

    Where to join?

     

    Registration and more information about the ABAP Development for SAP HANA course and the openSAP platform can be found here. And in case you'd like to roll up your sleeves and get a trial system, just visit our technical course guide.

     

    Enjoy the self-paced mode!

     

    Cheers,

      Jasmin & Jens

      (ABAP for SAP HANA Evangelists)

     

     

    openSAP_ABAP_Web.jpg


    ALV IDA and HANA as a secondary database

    $
    0
    0

    Hi all,

     

     

    Introduction

    I was currently doing some research on an ABAP 7.4 system with the new ALV IDA. The ABAP7.4 system uses HANA as a sidecar. So the primary database connection is a classic database and the secondary database connection goes to HANA.

     

    In this ABAP 7.4, there is already the ALV IDA available. So I thought, why not use it and try to find a way use the secondary database connection to use HANA.

     

    I could use the ALV IDA without trying to use the secondary database connection, but that will not help! I'll tell you why.

     

     

    ALV IDA vs "Classic" ALV

    When using the "Classic" ALV, you'll first get your data. Next you'll intantiate your ALV and pass all the data to it. But only some parts of your data are visible on the UI. This is perfectly described by this image. Of course everyone knows this, just trying to make my point .

    salv.png

     

    The ALV IDA will wok a bit different. It will only load the data that will be visible on the UI. This will replace your logic to your database which makes the ALV IDA optimized for HANA.

    ida alv.png

     

    But what will happen if you use the ALV IDA on a not HANA database? The ALV IDA will check your database and dependent on your database it will work differntly. When using HANA it will work as described on the left part of the image and explained above. For non-HANA database, it will work the same as the "Classic" ALV as you can see on the right plart of the image and the first image above. So whatever database you are using, ALV IDA will take care of it

    ida working.png

    For more information about the ALV IDA: SAP List Viewer with Integrated Data Access (ALV with IDA) - SAP GUI - SAP Library

     

     

    ALV IDA on HANA as a Secondary database

    So what I tried to do was to use the ALV IDA in an ABAP7.4 system and use the secondary database to HANA.I created a small ABAP program where I've used the ALV IDA to show the table HRP1001. This table was replicated by the SLT system to HANA. Because HANA was not the primary database, the ALV IDA worked just the same as the "Classic" ALV. But I would like to use ALV IDA on the HANA database. So I started looking in the core of the ALV IDA classes and check what I've found:

    ida alv 2.png

    "GET PARAMETER ID" to get the database connection. Normally this will be empty and it wil use the default connection ( see statement line 61 ).

     

    Knowing this, I tried to set this parameter id with my secondary database connection right before I created my ALV IDA:

    ida1.png

    Now ALV IDA will use HANA !

     

    To be completely sure, I've used ST01 and did a trace on my user. In this trace I could see that ALV IDA will go to HANA for every scroll or every sort!

     

    You'll have to be carefull with this parameter because it stays in the user memory. So it will use this value in every program that uses the ALV IDA if you don't clear it.

     

    Besides this you can also use the HANA Accelerator SWT2DB Add On (SWT2DB) and configure your program to use HANA.

     

    Maybe it could be helpfull in some cases.

     

    Kind regards,

    Wouter

    Modification-free Enhancement of AMDP in AS ABAP 7.4 SP08

    $
    0
    0

    With AS ABAP 7.8 various ABAP (for SAP HANA) features and improvements have been delivered (see here). This is also the case for ABAP Managed Database Procedures (AMDPs).  You can read the ABAP News for 7.40, SP08 - ABAP Managed Database Procedures (AMDP) by Horst Keller.

    In the present blog, I would like to emphasize the modification-free enhancement of AMDP using special Business Add-Ins, so-called AMDP BAdIs.

     

    One the main advantages of the so-called Top-Down approach is that as a developer you remain in your familiar ABAP environment, despite the fact that you may be writing HANA-specific code. This is exactly the case with AMDPs which allow embedding SQLScript code into special class methods (so-called  AMDP methods). Another important advantage is that proven and well-known ABAP capabilities and concepts can then be applied on such objects, e.g. the standard ABAP transport mechanism and the version management.

     

    With ABAP 7.4 SP08, the modification-free enhancement of AMDPs is now possible using so-called AMDP BAdIs. The AMDP BAdIs transmit the effect of the switches from the Switch Framework to the implementation of database procedures in the current database. It allows the definition of a clear contract between extension provider and extension consumer (aka implementer) through a dedicated interface. AMDP BAdIs are created in Enhancement Spots in the transaction SE20 and are later called within an AMDP implementation similarly to other AMDPs.

     

    Below is a short video tutorial showing how to achieve it and additional information on that topic.

     

     

    General information about BAdIs:

    A BAdI is an object-oriented enhancement option, which makes it the most sophisticated enhancement type. The main characteristic of a BAdI is that it provides a mechanism to change the functionality of a well-defined business function without making changes to the delivered source code. Future upgrades of the original business function can be applied without losing the customer-specific enhancements or the need to merge the changes. The two code lines (the original one and the customer-specific coding) are strictly separated but still integrated.


    To note is that the BAdI technology is not limited to SAP applications. BAdI calls can be integrated in customer applications, which in turn can then be enhanced by other customer applications. (More info ...)

     

    Special information and restrictions to be taken into consideration when working with AMDP BAdIs:

     

    During the creation of a AMDP BAdI definition in SE20

    1. New option “AMDP BAdI” must be checked
    2. Filters are not supported
    3. BAdI Interface must only contain AMDP method definition (check the prerequisites of method interfaces for AMDP methods)
    4. Fallback class must be specified
    5. Only AMDP classes can be provided as fallback class or implementation class

    Regarding the implementation of BAdI classes (i.e. Fallback class or  implementation classes)

    1. Only AMDP implementations of the BAdI interface methods must be provided
    2. Only AMDP methods for a database platform can be implemented in a BAdI class  (only SAP HANA currently supported)

    Regarding the invocation of a BAdI within an AMDP method

    1. BAdI invocation has to be declared after the addition USING of the relevant AMDP method.
            USING BADI_NAME=>METHOD_NAME
    2. The call is syntactically similar to a procedure call
            CALL "BADI_NAME=>METHOD_NAME"(
      *          set input and output parameters here
             );

     

    Hope this information helps you. For more information check the online ABAP Keyword documentation in the SAP Help Portal. Various information (guides, tutorial, videos) around the ABAP development for SAP HANA can be found here.

    DEV201@TechEd 2014 Part 1: Introduction into ABAP 7.4 Development for SAP HANA

    $
    0
    0

    First of all I wish you all a Happy New Year!

     

    A lot has been said and done around the topic ABAP Development for SAP HANA in 2014 (openSAP Course, CodeJam events, SAP TechEd && d-code, ...). The session DEV201 (Overview of ABAP 7.4 Development for SAP HANA) exactly covered that topic at SAP TechEd && d-code 2014 in Las Vegas and Berlin. I would like to use this blog series to compile the session and also to refer to some interesting SCN blogs and documents available on the topic.


    The blog series comprises three posts:

    1. DEV201@TechEd 2014 Part 1: Introduction into ABAP 7.4 Development for SAP HANA (current blog)
    2. DEV201@TechEd 2014 Part 2: Detect your custom ABAP code to be adapted
    3. DEV201@TechEd 2014 Part 3: Optimize your custom ABAP code

     

    So let’s start...


    Introduction to the ABAP Development for SAP HANA


    About SAP NetWeaver 7.4

    When we talk about ABAP developments for SAP HANA, then we’re talking about SAP NetWeaver 7.4 (and beyond) which is the follow-up compatible release of SAP NetWeaver 7.03/7.31 and runs on SAP HANA and on all classical databases. It is generally available since May 2013 and Service Release 2 was released to customers in September 2014 with Support Package 8. In the meantime, AS ABAP 7.4 Support Package 9 has also been released.

    ABAP_7.4_intro.png


    AS ABAP 7.4 has been heavily optimized for SAP HANA through a seamless integration of both worlds, but it also contains various enhancement and innovations for the classical databases (we can't say this enough). It is the underlying foundation of solutions such as SAP Business Suite 7 innovations 2013 and SAP Business Warehouse 7.4 powered by SAP HANA.


    SAP NetWeaver 7.4 is the “go-to” release for SAP NetWeaver and especially for all ABAP developments for SAP HANA.

    Just to name a few features contained in AS ABAP 7.4:

    • High user experience with built-in SAPUI5 and SAP Gateway capabilities
    • Easy mobile access and mobile applications development

     

     

     

    The 3 essential ingredients in the context of  ABAP developments for SAP HANA are (of course) the SAP HANA platform, the "Code-to-Data" programming paradigm in ABAP and the Eclipse development platform.

    SAP HANA - The Game Changer

    SAP HANA is first of all a fully-fledged relational database management system, but as you already know it is more than just another database. Its special architecture (in-memory computing, columnar and row-based store, multi-core CPUs, ...) allows the convergence of OLTP and OLAP by processing huge volume of transactional and analytical data at an extreme speed on the same store (one source of truth). SAP HANA also provides specialized engines and application libraries such as predictive analysis and text mining and search.


    In a succinct manner: SAP HANA takes advantage of the latest technology developments and changed the way of developing and executing applications. For example in most of the cases, materialized aggregates and indices are no longer needed. This results in less data redundancy, less data models complexity and the related coding become simpler.Read the blog SAP HANA explained - Again by Graham Robinson.


    "Code-to-Data" - The programming paradigm shift in ABAP

    Till now we've been developing ABAP applications using the so-called "Data-to-Code" paradigm where data is fetched from the database, then stored in internal tables and processed (e.g. aggregated) in the application server. With SAP HANA, the "Code-to-Data" paradigm is recommended. Here we are asked to delegate data-intensive processing to the database and only transfer the computed results to the application server - well, the database is no longer the bottleneck.

     

    This approach allows us to fully leverage the power of SAP HANA in our applications and at the same time to significantly reduce the network load the server footprint.


    Kill (more than) two birds with one stone!

    Read the blog ABAP for SAP HANA and "Code Push-Down" by Jens Weiler.

    Code-to-Data.png

    The "Code-to-Data" paradigm - powered by SAP HANA - impacts the well-known performance guidelines for efficient Open SQL Programming, aka “5 Golden Rules”, which have been out there for a while now. These rules are still valid, but there is a shift in their priorities. Read the blog Performance Guidelines for ABAP Development on the SAP HANA Database by Eric Westenberger.

    Eclipse as the Integrated Development Environment

    Eclipse is SAP’s strategic platform for integrated development environment. It provides an excellent and uniform developer experience across different languages. Various SAP development tools are already available for Eclipse – e.g. SAP HANA, Cloud, BW, Gateway and ABAP with the ABAP Development Tools for SAP NetWeaver (aka ABAP in Eclipse).


    The ABAP development tools for eclipse aremandatory when it comes to full support of ABAP developments for SAP HANA.

    How can your custom ABAP code benefits from SAP HANA?

    In the context of the ABAP development for SAP HANA, there are mainly 3 categories of deliveries provided (together) with SAP NetWeaver 7.4.

    1. The so-called transparent optimizations which don’t require any action from developers. For example, the table buffer enhancements in the database interface and fast data access protocols improving the communication between ABAP and SAP HANA. Thus, a well-written ABAP code (according to the performance guidelines) automatically runs faster on SAP HANA, especially if it has a high database processing time.
    2. The advanced quality assurance tooling and new programming capabilities. 
    3. Last but not least, the best practices and guidelines, but also how-tos and demo applications such as the Open Items Analysis Reference Scenarios which is part of the standard AS ABAP 7.4 delivery as of support package 2.
    DOE.png

    The typical and recommended approach for customers who want to migrate their custom solutions to SAP HANA (or have already done so) follows the pattern "Detect - Optimize - Explore".

     

    • Detect your custom ABAP code to be adapted making use of the advanced quality assurance tooling
    • Optimize your custom ABAP code for SAP HANA by making use of the various programming features
    • Explore the new opportunities provided by SAP HANA and integrate them easily in your custom ABAP applications

    So that was it for the introduction. Looking for the next post of the series? Here you go: DEV201@TechEd 2014 Part 2: Detect your custom ABAP code to be adapted

    how to use the power of AMDP for section headings subtotals,total and row coloring

    $
    0
    0

    I had a requirement given by the business which was a bit difficult. The data was to be pulled from FI and MM module and combined in one report.

    The report had to have 5 sections

    1. For section 1 the data needs to be pulled from FI
    2. Subtotal
    3. For section 2 the data needs to be pulled from MM
    4. For section 3 the data needs to be pulled from FI
    5. Sub total
    6. Grand total

    I decided to explore all this by using the AMDP method. Given below is a screen shot of my procedure for the first 2 points.

    I added one column called color in the structure which i will be using in the ABAP coding. I am also using the select from dummy to add a heading row.

    Finally i do a union all and assign it in the out parameter of the procedure.

     

    Capture1.PNG

    This is for retrieving the data

    Capture2.PNG

    This is for the subtotal

    Capture3.PNG

    In the ABAP Code

    Capture4.PNG

    For coloring the line just add the line highlighted in the layout

    Capture5.PNG

    The final out put

     

     

         Capture6.PNG

    I Hope this helps the fans of code push down.

    DEV201@TechEd 2014 Part 2: Detect custom ABAP code to be adapted

    $
    0
    0

    This is the 2nd blog from the DEV201@TechEd 2014 blog series which is compiling the demo-rich session DEV201 (Overview of ABAP 7.4 Development for SAP HANA) that was held at SAP TechEd && d-code 2014 in Las Vegas and Berlin. I'm also using this opportunity to refer you to some interesting blogs and documents available on the topic.

     

    The blog series comprises three posts:

    1. DEV201@TechEd 2014 Part 1: Introduction into ABAP 7.4 Development for SAP HANA
    2. DEV201@TechEd 2014 Part 2: Detect custom ABAP code to be adapted (current blog)
    3. DEV201@TechEd 2014 Part 3: Optimize your custom ABAP code

     

    Let’s go ahead...


    Detect ABAP custom code to be adapted

    "Will my custom ABAP code still work on SAP HANA?"  is one of the major customer questions in the context of the migration of their existing ABAP-based software (e.g. SAP Business Suite or SAP Business Warehouse) to SAP HANA. The question mainly relates to two areas in which code corrections and adaptations may be required before the migration in order to avoid regressions:

    • Functional correctness
    • (SQL) Performance.

    Before going ahead, I would like to draw your attention to the fact that a migration to SAP HANA is JUST a database migration. The different problematics are common to all databases, but their solutions may be database-specific. Therefore, there is nothing really new here! .

     

     

    What should be detected?

    Regarding the functional correctness:

    After a SAP HANA migration, everything works as before, except:

    • Native SQL (EXEC or ADBC) with vendor-specific statements
    • Database hints
    • Non-robust code relying on undocumented behaviors such as implicit DB sorting order or access to technical pools/clusters of a pool/cluster table
    • Code relying on the existence of secondary DB indices

    The detection of such code constructs is essential and their appropriate correction/adjustment are two mandatory

    detection_01.png

    tasks before a migration as a functional regression is a total no-go for running businesses.

    Notes:

    - Although DB hints are DB-specific, they generally do not need to be adapted in the context of a HANA migration

    - ORDER BY clause or ABAP SORT must be expilicitly specified for code relying on data sorting order

    - Pool and cluster tables are converted into transparent tables during a SAP HANA migration

    - Indices are not generated after a SAP HANA migration in most cases

     

    Regarding the performance:

    After a SAP HANA migration, a well-written ABAP code runs immediately faster, especially code with a long database processing time. And so remains a poorly-written code as such.

     

    “Well-written” and "poorly-written" are meant here according to the classical performance rules for efficient SQL programming.


    Thus it is important to detect potential candidates for optimization by searching for critical SQL constructs - especially those ones with a low DB performance profile. Adapting them before the migration is not mandatory, but may be required in some cases.

    detection_02.png

    The performance plays an important role during the whole software lifecycle - as regressions should be constantly avoided, thus the detection of tunable code is a task that is relevant before and after the migration in order to fully exploit the power of SAP HANA (refer to the classical and the adjusted SQL Performance rules).

     

    But don't forget that you - as customer - are the one deciding how performant your application should be and so defining the scope of detection and optimization activities to be performed.

     

     

    Which support do I get from SAP?

    To assist you in your different detection activities, SAP NetWeaver AS ABAP 7.4 provides advanced quality assurance tooling. Three major tools can be named:

    • ABAP Test Cockpit (transaction SATC)
    • SQL Monitor (transaction SQLM)
    • SQL Performance Tuning Worklist (transaction SWLT)

    In the context of performance analysis, these tools provide an incredible support in identifying the most promising candidates for performance optimization (focus on hotspots). The tools can be used in a all contexts (HANA and non-HANA) and are also available on lower releases as part of the standard delivery as of AS ABAP 7.02 (SP12/SP14) or as ST-PI add-on.

     

    ABAP Test Cockpit

    The ABAP Test Cockpit (ATC) is the standard tool for running static code checks on ABAP development objects. The different findings (functional, performance, security, bugs, …) are reported in a prioritized list. The ATC framework enhances the well-known Code Inspector with new quality assurance processes such as quality gates, exemption approval process and periodic regression tests in a quality system. ATC is fully integrated in the standard development environments (with eclipse-based UI in ADT) and transport tools. Read more (general info)...

     

    ATC is the basis for a smooth SAP HANA migration of custom ABAP code. It assists you in detecting potential functional and performance issues during the transition. As already mentioned. For this purpose, new checks and global check variants (FUNCTIONAL_DB and PERFORMANCE_DB) are provided. Read more (HANA specific)...

     

    Remote static ABAP code checks can be performed on lower SAP NetWeaver releases where neither the check infrastructure or the new code checks are not available (refer to SAP Note 2011106).

     

    SQL Monitor

    SQL Monitor is the recommended standard performance analysis tool when it comes to the runtime monitoring of productive systems without impacting the running business processes. It allows the collection of an extensive set of runtime information (e.g. entry points, elapsed time, records read, …) for each and  every executed SQL statement and thus provides a transparent SQL profile of productive systems. The collected monitoring data are linked to their related ABAP processes (transaction, report name, …) and different aggregation and drill-down options to the related DB operations are provided. The integration of the SQL Trace (ST05) allows a more detailed investigation of given ABAP processes.

     

    SQL Monitor supports you in identifying promising candidates for performance optimization with a high ratio performance improvement and optimization efforts. the tool is part of the standard delivery as of AS ABAP 7.02 SP14 and also available as ST-PI add-on (ST-PI 2008_1_700 SP8) for lower releases (ABAP 7.0 and beyond). Read more ...

     

    SQL Performance Tuning Worklist

    SQL Performance Tuning Worklist offers the possibility to combine the results from the static code checks and the runtime analysis, hence providing a more comprehensive view of the different results. The tool is quite helpful for beginners and advanced users while weighting the reported static check results. The typical approach is to start the identification of performance hotspots with the combined list and then to switch to the more powerful SQL Monitor to deepen the analysis of the root cause – as it provides more insights. The experience shows that experts will find their way directly into the SQL Monitor. Watch this video...

     

    Guides and Best Practices

    In addition to the advanced analysis tooling and the standard documentation in SAP Help portal, guides and best practices written by our experts are provided:


    As next step I'll provide a compact overview of the different programming capabilities delivered with AS ABAP 7.4 which can be used for writing ABAP code optimized for HANA.

     

    Looking for the next and last post of the series? Here you go: DEV201@TechEd 2014 Part 3: Optimize your custom ABAP code

    DEV201@TechEd 2014 Part 3: Optimize your custom ABAP code

    $
    0
    0

    We're reaching the of the DEV201@TechEd 2014 blog series which is compiling the demo-rich session DEV201 (Overview of ABAP 7.4 Development for SAP HANA) that was held at SAP TechEd && d-code 2014 in Las Vegas and Berlin. I'm also using this opportunity to refer you to some interesting blogs and documents available on the topic.

     

    The blog series comprises three posts:

     

    Please bear with me here, for the lengthy blog - It's the last of the series...


    Optimize your custom ABAP code

    SAP NetWeaver 7.4 (and releases beyond) offers various programming capabilities that should be used to easily develop ABAP applications best leveraging the power of HANA, i.e., high performance and advanced native functions such as financials, text mining and predictive analysis. The majority of these new features works on all SAP supported databases (anyDB), but are optimized for in-memory databases such as SAP HANA. So just a few is solely supported on HANA.

     

    Following capabilities were introduced and demoed during the session:

    • SAP List Viewer with Integrated Data Access (ALV with IDA)
    • Search Helps with type-ahead function and full-text search
    • Enhanced Open SQL
    • Advanced view building with ABAP Core Data Services (CDS)
    • Easy access to native HANA capability with ABAP Managed Database Procedures (AMDP)
    • Real-time eventing with ABAP Channels

     

    Where in the world do I start? may be the question coming up to your mind when you think of writing ABAP code that is optimized for HANA.

    Well, we strongly recommend to start with "low hanging fruits" (so-called Quick-Wins) and then to evolve naturally -as the requirement get's more complexe- to the more advanced capabilities. This means check which features fits to your requirements and choose the one where you have the most skills.

     

    Start with low hanging fruits

    It's all about first making use of well-known capabilities that have been enhanced or optimized for HANA. For example, the screenshot above shows a FPM application which makes use of the HANA-optimized ALV re-use component and the fault-tolerant search (aka Fuzzy Search) in the Search GUIBB.

    LowHangingFruits.png

    The application runs in SAP NetWeaver Business Client with an analytical side panel (on the right side) using HANA capabilities which provides more insights to the transactional application.

     

    SAP List Viewer with Integrated Data Access (ALV with IDA)

    ALV with IDA (aka ALV on HANA) is a re-use component which offers the well-known functionality of the classical ALV optimized for in-memory DBs such as HANA. It is a good example for showcasing the implementation and the benefits of the Code-to-Data paradigm in ABAP.

    The main changes are:

    • Only the visible data (rows and columns) is selected
    • Data-centric UI operations such as aggregations, sorting, and grouping are performed on the DB
    • Constraints (e.g. authorization and ranges) are declared and then evaluated on the DB

     

    End-users can now navigate through millions of records in real-time thanks to the much faster data retrieval. There is no fear for data truncation as computations are always performed on the complete data set.

     

    ALV with IDA can be integrated in classical Dynpro and WD4A/FPM applications. Read more...


    ALV_with_IDA.png

    Search Helps with type-ahead and fault-tolerant search

    You now have the possibility to enhance the functionality of a search help object (F4 Help) with a type-ahead and fault-tolerant full-text search. The type-ahead (aka search-as-you-type) function allows a faster user interaction by showing possible search results from the standard F4 help already while typing in a drop-

    search_help.png

    down box beneath the search field. This option works on anyDB.

     

    In addition, the Full Text Fuzzy Search option can be activated. It offers a fault-tolerant cross-column search. This option is DB-specific and currently only supported on HANA.

     

    As a developer, you do not have to modified their UIs in order to enable the enhanced functionality. What you have to do, is simply to select these options in the relevant search help object (SE11).

    The enhanced search help functionality is currently only supported in classical dynpros. Watch here ...

     

    Enhanced Open SQL

    Open SQL is an abstraction layer defining a common syntax and semantics for all SAP certified databases. It has been enhanced and now offers a broader coverage of standard SQL features.

    This enhancement allows a better support of the Code-to-Data paradigm by using extended joins support, sub-queries, SQL functions, expressions, aggregations and many more.

     

    A new Open SQL syntax (with comma separated SELECT list and escaping of host variables with @) was necessary to achieve this. The old syntax is still supported, but the new one is mandatory for a given statement if it makes use of new features. Read more...

     

    PS: In case you are already on ABAP 7.4 and are preparing your code for a HANA migration, then always first try to replace problematic native SQL statements (EXEC and ADBC) with Open SQL.

    OpenSQL.png

    Advanced view building with ABAP Core Data Services (CDS)

    CDS is SAP's next generation of data definition and access for database-centric applications. It uses and extends SQL to capture the business intent. Its integration into the ABAP server provides a new DB abstraction layer simplifying and harmonizing the definition and consumption of semantically rich data models regardless of the application domains (e.g. transactions and analytics) across different SAP platforms.

    CDS_.png

     

    The Code-to-Data paradigm is supported through e.g. various built-in functions, unions, associations and path expressions. ABAP CDS is integrated in the ABAP dictionary. The CDS views are ...

    • defined in a text-based editor (only in ADT)
    • fully and solely managed by AS ABAP
    • supported on anyDB (native integration in HANA)
    • consumed in Open SQL like SE11 views
    • extensible on model level using modification-free view enhancements and on meta-model level using domain-specific annotations

    Read more...

    HelpDesk.png

    Open SQL vs. ABAP CDS

    In case you're asking yourself whether ABAP CDS competes with Open SQL as both are DB abstractions, then the clear and short answer is NO. It's like asking if there is a competition between Open SQL and the classical SE11view building.

    When to use What depends on the scenario requirements: When it comes to re-usability, large feature set and domain-specific consumption of data models, then you will go for ABAP CDS.

     

    ABAP Managed Database Procedures (AMDP)

    Database procedures are subroutines for processing application logic directly in the database. HANA offers procedures in SQLScript (an extension to SQL) which allow followings:

    • expression of complex logics (incl. if/else)
    • definition of local variables
    • parametrization of requests
    • multiple result sets

     

    With AMDP, a class-based framework for managing and calling HANA procedures in AS ABAP, a deeper integration of both worlds is provided. It allows you to fully and easily expose the power of HANA (high performance and advanced native functions) in ABAP applications.

     

    AMDP are provided by mean of marked methods of global classes implementing specific tag interfaces. These so-called AMDP classes and methods can only be edited with ADT and are called in programs like regular ABAP methods.

    AMDP.png

    ABAP developers remain in their familiar development environment and can make use of well-known and robust ABAP concepts and techniques such as the Enhancement Framework and the standard transport mechanism (same by CDS). Read more...

     

    Real-time eventing with ABAP Channels

    This functionality is not HANA-specific and works on anyDB. I smuggled it into the session simply to let you know about this cool stuff. And since we're talking about real-time processing, real-time eventing just fits in the context.

     

    In short: ABAP Channels (ABAP Push Channels + ABAP Messaging Channels) enable the support of event-driven interactive and collaborative scenarios by providing an implementation of the WebSocket protocol in ABAP. So, stop polling and start real-time eventing! Read more...

     

    Explore new opportunities

    Scenarios and applications that weren't possible in the past due to technical restrictions are now reality thanks to the breakthrough technology that is HANA. The possibility is now given to you to rethink both, the way you do business and the way your build applications!

     

    With all these new programming capabilities (especially with AMDP) provided as of AS ABAP 7.4, you can fully and easily integrate the power of HANA in your existing business and e.g. support more agile processes with new innovative applications which were not possible before for performance reasons.

     

    Check it out. SAP HANA: Simplify. Accelerate. Innovate.

     



    That was it. You'll find a comprehensive explanation of the different ABAP language features in the ABAP Keyword Documentation.

    Stay tuned and get your hands dirty.

     

    Carine

    Accessing tables from different schema through AMDP.

    $
    0
    0

    Dear All,

     

     

    Recently we have started working with ABAP on HANA and day by day we are getting more challenges, so one of my best part I am sharing here....

     

    I got a business requirement which was very interesting, the data has to be taken from  different schema's table which is SLT replicated.

    We are executing report from BW on HANA system.

     

    Below I am presenting summarized code, hope that might be useful for ABAP lovers.....

    Report Parts :

    1. Selection On Date and Division Number from VBRK & VBRP (Data to be pulled from cross Schema).

    2. F4 help for Division Number(Data to be pulled from cross Schema)

    3. Display Output


    Before that introduction of  AMDP ABAP Managed Database Procedures - Introduction

     

    Class :

    Definition -

    Defination.PNG

    Implementation -

    1.We can point schema tables like "RD2.VBRP" or RD2.VBRP.

    2.If you want to access current schema tables then you can add tables in 'USING' clause.

    Implimentation.PNG

     

     

     

     

    Program :

     

    Program.PNG

          Output :

     

    Output.PNG

     

     

     

     

     

    Regards,

    Amol


    Call AMDP(ABAP Managed Database Procedure) Inside AMDP Method

    $
    0
    0


    Dear All,

     

    Yet another very interesting topic in AMDP, which is how to call AMDP method inside AMDP method.

     

    Well, before moving forward let's see an overview of AMDP is

    here

    ABAP Managed Database Procedures - Introduction

    Accessing tables from different schema through AMDP.

     

     

    Scenario :-

                        1. Create  AMDP method which will get flight id(airline code) and aggregated price from currency and later will be called in another AMDP.

                        2. Create  AMDP method which will get flight name from airline code which is derived from AMDP in step1.

     

     

    Steps :-

     

    AMDP Definition

     

    Defination.PNG

     

    AMDP Implementation

     

    Implimentation.PNG

     

     

    Calling AMDP in program

     

    Program.PNG

     

    Desire Output

     

    Output.PNG

     

    I hope during realization that might be useful.

     

    -Cheers

    Amol

    Spotlight on parameterized ABAP CDS Views

    $
    0
    0

    Hi everyone!


    I just want to put the light on a feature - in the context of advanced view building with ABAP Core Data Services (CDS) - that is available starting with AS ABAP 7.4 SP8: CDS views with input parameters.


    Yes, as a developer, you can now parameterize your CDS views. It means you can define one general views which produce context-specific result sets by using parameter values passed at execution time. This means that you do no longer need to create a view for each context!

     

    For example:

    1. Language filter in combination with associations
      Instead of creating a a CDS view for each language, only one parameterized view is now needed. The specific language key value is passed at execution time.
    2. Calculation of sales tax
      Instead of creating a a CDS view for each country with the specific value-added tax, only one parameterized view is now needed. The country-specific value-added tax is passed at execution time and used in the related arithmetic expressions.

     

    Watch the compact video tutorial below. It shows how to create and call parameterized views in ABAP.

     

     

     

    Note that views with parameters are not supported on all SAP-certified database - At least SAP HANA does . However, the DDL of the ABAP CDS allows creating and accessing CDS views with parameters independent of the database system.

     

    In case an Open SQL statement SELECT is access such a parameterized view or a view that contains such a view as data source, but the accessed database system does not support them, a non-handleableexception of the class CX_SY_SQL_UNSUPPORTED_FEATURE is raised.


    The recommended approach when using a database-specific features (e.g. views with parameters) in ABAP programs is to use the method USE_FEATURES of the class CL_ABAP_DBFEATURES to check whether the accessed database system supports it.


    Example:

     

    IF abap_true = cl_abap_dbfeatures=>use_features(
           requested_features =

             VALUE #( ( cl_abap_dbfeatures=>views_with_parameters ) ) ).
       "Call of CDS view with input parameters
         SELECT *

           FROM demo_iparameter_02( p_langu       = @sy-langu,
                                    p_saving_rate = '0.04',
                                    p_lc_status   = @p_status )
           INTO TABLE @DATA(lt_data).

     

      cl_demo_output=>display_data(
        EXPORTING
          value = lt_data
          name  = 'Demo: CDS View with Input Parameters'  ).
    ELSE.
       "alternative implementation

        cl_demo_output=>display( 'Database system does not support views with parameters' ).

    ENDIF.

     

    Find more detailed information on this topic in the ABAP Keyword Documentation.

    Spotlight on ABAP CDS View Enhancements

    $
    0
    0

    Hi everyone!

     

    here we go with another "Spotlight on ..." blog!

     

    This time I would like to put the light on the modification-free enhancement of ABAP Core Data Services (CDS) views which is supported starting with AS ABAP 7.4 SP8.

     

    The modification-free enhancement of development objects is necessary, in order to avoid conflicts when a new release of the related application program is to be imported into a system. To avoid such conflicts in the context of ABAP CDS views, developers now have the possibility to create so-called CDS view enhancements which allow the extension of the existing SELECT list in modification-free manner.

     

    One or more view enhancements can be created for a CDS view, with each of them having its own CDS source code. The SELECT list of the view extension can have all elements of a SELECT list with the exception of input parameters, path expressions, and aggregate expressions. A field cannot be defined as key field using the keyword KEY in the view extensions.

     

    Watch the compact video tutorial below and learn how to create CDS view enhancements and call the enhanced CDS views in ABAP.

     

     

     

    Note that currently following views cannot be enhanced using CDS view enhancements:

    • CDS views with an explicit name list
    • CDS views with a  GROUP BY clause
    • CDS views with a UNION clause for union sets

     

    Find more detailed information on this topic in the ABAP Keyword Documentation.

    Spotlight on the Enhanced Search (F4 Help)

    $
    0
    0

    Hi everyone!


    I would like to highlight the Enhanced Search functionalitythat has been delivered with AS ABAP 7.4 SP05 and improved with higher SPs.


    Lately, I’ve received some requests from different channels around the enhanced options of the search helps and especially about suppressing them (when set to active). So I would like to handle the topic in this blog.

     

     

    You may have already noticed the new behaviour in standard transaction such as SE24 and SE38 while typing in the name of a class or report.

     

    As a developer, you can now enhance the functionality of a search help object (F4 Help) with the type-ahead function and Fuzzy Search by just selecting the appropriate settings in the relevant search helps in the ABAP dictionary (SE11).

    se24_SearchHelp.png

    The type-ahead - aka search-as-you-type - function allows a faster, search engine-like user interaction by showing possible search results from the standard F4 help already in a down box beneath the search field. This option works on all SAP-certified databases (anyDB).

     

    In addition, the Fuzzy Search option allows a fault-tolerant, cross-column full-text search. This option doesn't work on all databases currently - But it does on SAP HANA! An accuracy value can be specified for the error tolerance of the full-text search.

    Enhanced_SearchHelp.png

    The enhanced search is currently only supported for classical dynpro screens (SAP GUI) – so not yet for Web Dynpro. But like we at SAP, you surely have a lot of dynpro-based applications in use and thus lot of users who can benefits from this functionality.

     

    Watch the video tutorial below and learn how to enable and use the new functionality.

    PS: The demo in the video is based on AS ABAP 7.4 SP05, but with 7.4 SP06 and higher (recommended), developers do not longer have to modify the dynpros in order to enable the enhanced search.

     

    "No programming - Just setting!" sounds good, but as it always is, when you tell developers that everything works automatically, questions around exceptions handling are raised up...

    In the present context: How to deactivate the enhanced search?

     

    They are two possibilities to do that and I would like to explain how to achieve it:

    • User-specific deactivation
    • Field-specific deactivation (global)

     

    User-specific deactivation of the enhanced search

    Every user can influence the enhanced search function. The prerequisite here is that it must be set to active in the search help. The user-specific deactivation can be done in SAP Logon under  Options> Interaction DesignVisualization 2 .

     

    Three options are available in the Enhanced Search area.:

    • Show Enhanced Search Automatically
    • Show Enhanced Search With Shortcut (Ctrl+Shift+Q)
    • Do Not Show Enhanced Search
      SAP_Logon_Options.png

    Deactivation of the enhanced search for specific fields (for all users)

    A developer can explicitly (programmatically) suppress the enhanced search for specific fields.

    He has to do as follows in the relevant programm:

     

    1. Create a PBO module that disables the function on the relevant fields (see below)
      MODULE disable_type_ahead_xxxx OUTPUT.  cl_dsh_dynpro_properties=> disable_type_ahead (          fields = value #( ( conv string( 'INPUT-FIELD_1' ) )                                    ( conv string( 'INPUT-FIELD_2' ) )  )                      ).
      ENDMODULE.
      PS: For those who are not familiar with the syntax used above: This is still ABAP!
      You can read more about the new modern and declarative ABAP language syntax in this blog by Horst Keller.
    2. Call the PBO module the appropriate PBO section of the relevant dynpro screen

     

    That's it! Read more on the enhanced search in the online ABAP documentation on the SAP Help Portal.

    Handling of SELECT-OPTIONS parameters within AMDP

    $
    0
    0

    The ABAP Managed Database Procedures (AMDP) framework provides the higher level of integration of the advanced HANA capabilities into ABAP applications. It allows creating and managing SQLScript-based DB procedures from the ABAP platform by using so called AMDP methods.


    One difficulty faced by developers when working with AMDPs is the handling of SELECT-OPTIONS parameters (selection tables or range tables). The present blog will exactly tackle that topic.


    Simply explained, the handling of SELECT-OPTIONS parameters in the context of AMDPs requires two steps:

    1. Conversion of the selection tables into an SQL WHERE clause using method CL_SHDB_SELTAB=>COMBINE_SELTABS( )
    2. Handling of dynamic WHERE clauses within the AMDP method using the function APPLY_FILTER

     

    Step 1: Conversion of SELECT-OPTIONS parameters into an SQL WHERE clause

    For those of you who have been generating dynamic WHERE clauses till now using the class CL_LIB_SELTAB: Do no longer use it again and if possible even replace such calls (as explained below) in your existing code!

     

    The new class CL_SHDB_SELTAB - especially its static method COMBINE_SELTABS( )- shall be used for this purpose instead. It provides a comfortable coverage of the conversion functionality for SAP HANA (refer to SAP Note 2124672SMP login required). This conversion routine includes checks for SQL injections during the conversion of the selection tables into an SQL WHERE clause.

     

    Here is a simple demo report showing how to convert the SELECT-OPTIONS parameters into a WHERE clause:

    amdp_select_options_01.png


    As shown above, you just have to pass an internal table (defined here using the new value operator VALUE) filled with as many SELECT-OPTIONS parameters as required by your scenario. The name of the relevant field (NAME) and of the data reference to the corresponding SELECT-OPTIONS table (DREF) is required for each entry. In case of relevance, it is recommended to specify the exporting parameter IV_CLIENT_FIELD with 'CLIENT' or 'MANDT' (depending on the related table field name) to ensure the addition of the client filter to the WHERE clause.

     

    The method returns the dynamic WHERE condition as a string which can then be passed to the AMDP method. Let’s now go to the next step.

     

    Step 2: Handling of dynamic WHERE clauses within the AMDP method

    What needs to be done is very simple: The SQLScript statement APPLY_FILTER is used to apply the selection criteria to the relevant dataset which can be a database table/view, a HANA view (except Analytical view) or an intermediate table variable.

     

    Below you can see a code simple showing how to apply the dynamic WHERE clause in both cases; directly on a data source (table or view) [CASE 1] or on an intermediate dataset (table variable) [CASE 2].

    amdp_select_options_023.png

    The APPLY_FILTER function expects two parameters. The first one is the dataset to which you want to apply the filter and the second one is the generated WHERE clause which is passed as a string argument. Find more information about the APPLY_FILTER function in the SAP HANA SQLScript reference.

     

     

    Summary:

    1. Static method COMBINE_SELTABS( ) of the new class CL_SHDB_SELTAB shall be used for the conversion of SELECT-OPTIONS parameters (selection tables or range tables) into an SQL WHERE clause when running on HANA DB.
      • The optional parameter IV_CLIENT should be specified with 'CLIENT' or 'MANDT') when applicable
      • This class implementation is provided for HDB (refer to SAP Note 2124672SMP login required)
    2. The class CL_LIB_SELTAB and its methods are obsolete
    3. Use the SQLScript function APPLY_FILTER to apply the selection criteria to the selected data in the AMDP
      • The function can be applied on database tables/views, HANA views (except Analytical views) or table variables


    That's it... bye!

    Viewing all 99 articles
    Browse latest View live


    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>