You are on page 1of 87

ABAP Part I

Lesson 01: ABAP New syntax


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 2


Lesson Objectives

 After completing this lesson, participants will be


able to -
 Know ABAP New syntax ( SAP NW 7.4 onwards )

 Being fluent to the basic up gradations of coding in SAP


 Learning new SAP provided facilities from ABAP 7.4
 Adapting with the new syntaxes form 7.4

 Log on to SAP and do the Basic Navigations Copyright © Capgemini 2015. All Rights Reserved 3
Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 4


Inline data declaration

 Definition: Inline data declarations are a new way of declaring variables and field
symbols at operand positions

Declaration of Variable:
DATA(V_DATA) =  'ABC 199 XYZ'.
WRITE: 'Output:', V_DATA.

Output:

Copyright © Capgemini 2015. All Rights Reserved 5


Inline data declaration

Declaration of table work areas:


LOOP AT itab INTO DATA(wa).   
  ...
ENDLOOP.
Declaration of actual parameters:
 Old method
DATA a1 TYPE …
DATA a2 TYPE …
oref->meth( IMPORTING p1 = a1
            IMPORTING p2 = a2
           … )
 New Method
oref->meth( IMPORTING p1 = DATA(a1)
            IMPORTING p2 = DATA(a2)
           … ).

Copyright © Capgemini 2015. All Rights Reserved 6


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 7


Explicit type declaration

 TYPES ty_matnr TYPE matnr.
DATA(tp_matnr) = NEW ty_matnr( 9001 ).

Output in debug mode:

Copyright © Capgemini 2015. All Rights Reserved 8


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 9


Standard internal table declaration

TYPES t_itab TYPE STANDARD TABLE OF i WITH DEFAULT KEY.
DATA(dref) = NEW t_itab( ( 100 ) ( ) ( 3000 ) ).
Output in debug mode:

Here as we have declared the internal table as standard table so the values
stored as 100->0->3000

Copyright © Capgemini 2015. All Rights Reserved 10


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 11


Sorted internal table declaration

TYPES t_itab TYPE SORTED TABLE OF i WITH UNIQUE KEY table_line.
DATA(dref) = NEW t_itab( ( 100 ) ( ) ( 3000 ) ).

Output in debug mode:

Here as we have declared the internal table as sorted table so the values
stored as 0->100->3000

Copyright © Capgemini 2015. All Rights Reserved 12


Sorted internal table declaration

If you declared some specific component in type then you have to write
‘ Component = ‘ in new statement otherwise you will get an error.

Copyright © Capgemini 2015. All Rights Reserved 13


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 14


Internal table with more components

TYPES: tt_data TYPE  MD_RANGE_T_MATNR.

DATA(ta_data_multi_comp) =
NEW tt_data( ( sign = 'I' Option = 'EQ' low = '00463928'  )
                ( sign = 'I' Option = 'EQ' low = '00463929'  )  ).

Copyright © Capgemini 2015. All Rights Reserved 15


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 16


How to work with deep structure

 TYPES: BEGIN OF ty_alv_data,
         kunnr   TYPE kunnr,
         name1   TYPE name1,
         ort01   TYPE ort01,
         land1   TYPE land1,
         t_color TYPE lvc_t_scol, “structure
       END OF ty_alv_data.
TYPES: tt_alv_data TYPE STANDARD TABLE OF ty_alv_data WITH DEFAULT KEY.
DATA(o_alv_data) = NEW tt_alv_data(
( Build 1st row
( Build inner rows i.e for t_color ) )
( Build 2nd row
( Build inner rows i.e for t_color ) )
)

Copyright © Capgemini 2015. All Rights Reserved 17


How to work with deep structure

Code Snippet for Deep Structure


 Field t_color is again a structure

Copyright © Capgemini 2015. All Rights Reserved 18


How to work with deep structure

Output in debug mode:

Copyright © Capgemini 2015. All Rights Reserved 19


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 20


MOVE-CORRESPONDING for Internal Tables

 You can use MOVE-CORRESPONDING not only for structures but also for internal
tables now. Components of the same name are assigned row by row.
 New additions EXPANDING NESTED TABLES and KEEPING TARGET LINES
allow to resolve tabular components of structures and to append lines instead of
overwriting existing lines.

 Example:
MOVE-CORRESPONDING itab1 TO itab2 EXPANDING NESTED TABLES
                                  KEEPING TARGET LINES.

Copyright © Capgemini 2015. All Rights Reserved 21


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 22


Table expressions

Table expressions replace READ TABLE statement

 You need to use the square bracket [ ]. Within the bracket, you would need to
specify the component you want to use as the key.
 When table entry doesn’t exist, a catchable exception
CX_SY_ITAB_LINE_NOT_FOUND is raised.
 Demo program attached.

Copyright © Capgemini 2015. All Rights Reserved 23


Table expressions

Demo Code Snippet

Copyright © Capgemini 2015. All Rights Reserved 24


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 25


GROUP BY clause for Internal Tables

 GROUP BY replace AT NEW or other means of going through grouped data


LOOP AT flights INTO DATA(flight)
     GROUP BY ( carrier = flight-carrid cityfr = flight-cityfrom )
              ASCENDING
              ASSIGNING FIELD-SYMBOL(<group>).
  CLEAR members.
  LOOP AT GROUP <group> ASSIGNING FIELD-SYMBOL(<flight>).
    members = VALUE #( BASE members ( <flight> ) ).
  ENDLOOP.

 Looks like dreaded nested LOOPs, but it isn’t quite that – no quadratic behavior! 
What happens here is that the first LOOP statement is executed over all internal
table lines in one go and the new GROUP BY addition groups the lines. Technically,
the lines are bound internally  to a group that belongs to a group key that is
specified behind GROUP BY.
 Demo program attached.

Copyright © Capgemini 2015. All Rights Reserved 26


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 27


FILTER expressions

 The new FILTER operator enables two kinds of filtering an internal table
i. Filter with single values
ii. Filter with filter table

 Filter with single values: Simply extract the lines from an internal table into a
tabular result, that fulfill a simple value condition.
 DATA(extract) = FILTER #( spfli_tab USING KEY carr_city
              WHERE carrid   = CONV #( to_upper( carrid ) ) AND
                    cityfrom = CONV #( to_upper( cityfrom ) ) ).

 Note: As a prerequisite, the filtered table (spfli_tab) must have a sorted or a hash


key (primary or secondary), that is evaluated behind WHERE

Copyright © Capgemini 2015. All Rights Reserved 28


FILTER expressions

 Filter with filter table: Compare the lines of one table with the contents of another
table, the filter table, and you extract those lines, where at least one match is found
 
 TYPES: BEGIN OF filter,
         cityfrom TYPE spfli-cityfrom,
         cityto   TYPE spfli-cityto,
       END OF filter,
       filter_tab TYPE HASHED TABLE OF filter
                  WITH UNIQUE KEY cityfrom cityto.
DATA(filter_tab) = …        
DATA(extract) = FILTER #( spfli_tab IN filter_tab
              WHERE cityfrom = cityfrom  AND cityto = cityto ).

 Note: Here, the filter table – that can be specified also as a functional method call –
must have a sorted or a hashed key (primary or secondary) that is evaluated.

Copyright © Capgemini 2015. All Rights Reserved 29


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 30


INNER JOIN Improvement

 You can use wildcard like SELECT * in new inner join


  Old syntax
SELECT a~vbeln b~posnr b~matnr FROM vbak AS a INNER JOIN b AS vbap
ON a~vbeln = b~vbeln
INTO TABLE li_vbeln
WHERE a~auart = 'Z1IN'.
 New syntax:
SELECT a~*, b~posnr, b~matnr FROM vbak AS a INNER JOIN vbap as b
ON a~vbeln = b~vbeln
WHERE a~auart = 'Z1IN'
INTO TABLE @DATA(li_vbeln).

Note: The symbol * ( asterisk ) it acts just like the wildcard SELECT * , and for this
sample you will get all fields in VBAK table.

Copyright © Capgemini 2015. All Rights Reserved 31


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 32


NEW keyword for creating Objects

 You can use ‘NEW’ to instances an object instead of use CREATE OBJECT.

   Old syntax
DATA : lo_myclass TYPE REF TO ZCL_MYCLASS.
CREATE OBJECT lo_myclass EXPORTING myname = 'India'.
 New syntax:
lo_myclass = NEW zcl_Myclass( myname = 'India' ).

Note: Key word ‘NEW’ is used to create instance of class ZCL_MYCLASS, Here
lo_myclass is the object name.

Copyright © Capgemini 2015. All Rights Reserved 33


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 34


CONVERSION_EXIT_ALPHA_INPUT/OURPUT

 You don’t need use CONVERSION_EXIT_ALPHA_INPUT and


CONVERSION_EXIT_ALPHA_OUTPUT;
You just need ALPHA keyword formatting option with OUT or IN.

KUNNR value of ‘12345’ changes to ‘000001235’, 5 zero added as KUNNR length is 10 CHAR

Copyright © Capgemini 2015. All Rights Reserved 35


Contents

 Inline data declaration


 Explicit type declaration
 Standard internal table declaration
 Sorted internal table declaration
 Internal table with more components
 How to work with Deep structure
 MOVE-CORRESPONDING for Internal Tables
 Table expressions
 GROUP BY for Internal Tables
 FILTER expressions
 INNER JOIN
 NEW keyword for creating Objects
 CONVERSION_EXIT_ALPHA_INPUT/OURPUT
 Using SWITCH statement

Copyright © Capgemini 2015. All Rights Reserved 36


Using SWITCH statement

 Using SWITCH statement as replacement of CASE


Using CASE you need to keep mentioning what variable you’re filling in every
branch in CASE Statement but If you use SWITCH statement, you don’t need to do it
Case statement:
CASE LV_INDICATOR.
WHEN 1. LV_DAY = 'January'.
WHEN 2. LV_DAY = 'February'.
ENDCASE.
Switch statement:
DATA(lv_day) = SWITCH char10( lv_indicator
WHEN 1 THEN 'January‘
WHEN 2 THEN 'February' ).
 Note: Using SWITCH statement, you don’t need mention LV_DAY variable in every
branch

Copyright © Capgemini 2015. All Rights Reserved 37


Summary

 We have learned ABAP New syntax ( SAP NW 7.4 onwards )


 Some new key word like FILTER expression, NEW, Table
expression.

 Web Link:
https://blogs.sap.com/2016/03/02/old-and-new-abap-syntax-
overview-sheet/
http://www.saptutorial.org/new-abap-language-in-abap-7-4/

Copyright © Capgemini 2015. All Rights Reserved 38


ABAP Part – 2
FUZZY SEARCH

Lesson 02: Fuzzy search


Contents

 Introduction to Fuzzy Search


 Examples of Fuzzy Search
 Configuration in CDS View

Copyright © Capgemini 2015. All Rights Reserved 40


Lesson Objectives

 After completing this lesson, participants will be


able to -
 Know the meaning of Fuzzy Search and How to Implement
In HANA Data base.
 Configure Fuzzy search logic.

Copyright © Capgemini 2015. All Rights Reserved 41


Contents

 Introduction to Fuzzy Search


 Examples of Fuzzy Search
 Configuration in CDS View

Copyright © Capgemini 2015. All Rights Reserved 42


Introduction to Fuzzy Search

 What is Fuzzy search


 Fuzzy Search is a fast and fault-tolerant search feature for SAP HANA.

 Definition:
 The term ”fault-tolerant search” means that a database query returns records
even if the search term (the user input) contains additional or missing characters
or other types of spelling errorenterprise.
 Fuzzy search can be used in various applications, for example:
 Search for documents on ‘Driethanolamyn’ and find all documents that contain the
term ‘Triethanolamine’.
 Fault-tolerant search in structured database content: Search for a product called
‘coffe krisp biscuit’ and find ‘Toffee Crisp Biscuits’
 Fault-tolerant check for duplicate records: Before creating a new customer record
in a CRM system, search for similar customer records and verify that there are no
duplicates already stored in the system.

Copyright © Capgemini 2015. All Rights Reserved 43


Introduction to Fuzzy Search

 So in short it can find values in big data sets without actually hitting the search
term exactly right.
 The fuzzy search algorithm calculates a fuzzy score for each string comparison.
The higher the score, the more similar the strings are. A score of 1.0 means the
strings are identical. A score of 0.0 means the strings have nothing in common.
 You can request the score in the SELECT statement by using the SCORE()
function.
 You can sort the results of a query by score in descending order to get the best
records first the best record is the record that is most similar to the user input).
When a fuzzy search of multiple columns is used in a SELECT statement, the
score is returned as an average of the scores of all columns used. So not only
does it find a “fault tolerant” match, it also puts a score behind it:
 For example, when searching with ‘SAP’, a record like ‘SAP Deutschland AG &
Co. KG’ gets a high score, because the term ‘SAP’ exists in both texts. A record
like ‘SAPPHIRE NOWOrlando’ gets a lower score, because ‘SAP’ is only a part of
the longer term ‘SAPPHIRE’ (3 of8 characters match)

Copyright © Capgemini 2015. All Rights Reserved 44


Contents

 Introduction to Fuzzy Search


 Examples of Fuzzy Search
 Configuration in CDS View

Copyright © Capgemini 2015. All Rights Reserved 45


Examples of Fuzzy Search

 Example: 1 ( Twitter data )


 Twitter data from millions of tweets
 This is a download of Twitter data from March 2006 to November 2009
 The data set consists of “tokens,” which are hashtags (#data), URLs, or
emoticons (Twitter smileys or other “faces” created using keyboard characters)
 The data comes from analysis on the full set of tweets during that time period,
which is 35 million users, over 500 million tweets, and more than 1 billion
relationships between users.
 When doing a fuzzy search, The table needs to be structured in a certain way.
This can easily be done by using SQL to create your table. This can be done by
the following command:

Copyright © Capgemini 2015. All Rights Reserved 46


Examples of Fuzzy Search

 CREATE COLUMN TABLE “S0007457730”.“TWITTERINFOCHIMPS3” 
(“TOKEN_TYPE” VARCHAR(10)NOT NULL ,
   “YEAR_MONTH” VARCHAR(6),
       “COUNT” INTEGER CS_INT,
 “TOKEN_TEXT” SHORTTEXT(200) LANGUAGE DETECTION (‘EN’)
PHRASE INDEX RATIO 0.200000 FUZZY
SEARCH INDEX ON SEARCH ONLY ON FAST PREPROCESS ON)
 In general fuzzy searches can be performed on:
 TEXT
 SHORTTEXT
 VARCHAR, NVARCHAR
 DATE
 All data types with a full-text index

Copyright © Capgemini 2015. All Rights Reserved 47


Examples of Fuzzy Search

 If we choose SHORTTEXT as Text type fuzzy searches can be the most


sophisticated. Note that the ‘FUZZY SEARCH INDEX’ structure will improve
performance as it increases the memory of the loaded table. Set it in advance as
you cannot modify it later.

Copyright © Capgemini 2015. All Rights Reserved 48


Examples of Fuzzy Search

 Example 2: (Give all records containing ‘SAP’ as part of the


hash tag)

SELECT SCORE() AS score, * FROM TWITTERINFOCHIMPS3


WHERE CONTAINS(TOKEN_TEXT,’SAP’,
FUZZY(0.7,’textSearch=compare,bestMatchingTokenWeight=0.7′))
AND TOKEN_TYPE = ‘hashtag’
ORDER BY score DESC;
The dataset comes back with over 800 records and my highest ranked scored
values are:

Continued in Next Page.

Copyright © Capgemini 2015. All Rights Reserved 49


Examples of Fuzzy Search

The Results continued from the last page:

Copyright © Capgemini 2015. All Rights Reserved 50


Contents

 Introduction to Fuzzy Search


 Examples of Fuzzy Search
 Configuration in CDS View

Copyright © Capgemini 2015. All Rights Reserved 51


Configuration in CDS View

 Fuzzy search logic is implemented in CDS Views.


 The steps to configure Fuzzy search logic is as below.
 1) Create a Search Help [ZH_EPM_OIA_SO] using the SE11 transaction. Make
sure it is an Elementary Search Help.
 2) Enter the name of the CDS view name [SEPMAPPS_CDS_OIR] in “Selection
method” input field.
 3) Use the “Enhanced Options” section to configure the fuzzy search options
[Refer screenshot given in Next step 4].
 4) Create Search help parameters such as SO_ID and COMPANY_NAME and
mark them as importing parameter, if you want to search for
both company_name and so_id. You can also mark both the parameters as
exporting parameters, if you want to display both, company_name and so_id, as
output of the fuzzy search as shown in the snapshot below. 

Copyright © Capgemini 2015. All Rights Reserved 52


Configuration in CDS View

Copyright © Capgemini 2015. All Rights Reserved 53


Configuration in CDS View

 5) Currently, the SE11 transaction does not support enhanced options in the test


mode. You need to test them in a normal screen or by using a report with the type-
ahead API.
 6) Fuzzy Search is a fast and fault tolerant search and finds strings that match a
pattern approximately(rather than exactly) means it returns records even if the
search term contains additional or missing characters or other types of spelling
error.
 7) Fuzzy search algorithm calculates a fuzzy score for each string comparison.
 8) We can call Fuzzy Search by using CONTAINS() function with FUZZY() option in
WHERE clause of a SELECT Statement such as:

Continued in Next Slide.

Copyright © Capgemini 2015. All Rights Reserved 54


Configuration in CDS View

Syntax for Fuzzy search as below:

Copyright © Capgemini 2015. All Rights Reserved 55


ABAP Part – 3

Lesson 03 : ALV with IDA (Integrated Data Access)


Lesson Objectives

 After completing this lesson, participants will be


able to -
 Proficient about SALV IDA . They can show data, enable
hotspot and add buttons in toolbar in SALV IDA.

Copyright © Capgemini 2015. All Rights Reserved 57


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 58
SALV IDA Introduction

Most important changes / improvements

• Real-time, regardless size of output table


• Only VISIBLE rows are copied from Database
• Every scroll is a „separate” SELECT statement
• Data volume transfered from DB to application
server is drastically reduced
• Code-to-data paradigm (aka Code Pushdown)
Data intensive operations moved to database.
Tools: CDS View, HANA View (using SQL
Script)
• Application layer divided into two areas:
• Orchestration Logic – handles business
processes
• Calculation Logic – performs operations on
data

Copyright © Capgemini 2015. All Rights Reserved 59


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 60
What is SALV IDA

 The new SALV IDA (Integrated Data Access) works more on


code push-down concept. Means, you don’t select the data and
send that to the ALV, instead you generate the ALV for the DB
table, DB view or a CDS views. CDS views are new concept in
740 which I will cover in future articles.
 The IDA framework then analyze the required columns, analyze
the filters to get the required where condition and execute the
select query. Additionally it also analyze the view port — the
only visible section of the ALV — the visible rows and columns.
Using this info, the framework would trigger a new query on the
DB to get only those required data. Sweet!
 One thing to note, IDA ALV would work on any database but
you many not get all the great performance benefits if you not
using the HDB.

Copyright © Capgemini 2015. All Rights Reserved 61


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 62
Why to use SALV IDA

 The existing ALV is has more functionality on the application


layer. That makes it very very slow. The full data is being
selected and sent to the ALV framework, which translates that
into display on the GUI container.
 Since the entire data is being selected beforehand, the
framework has to parse the data as required. Assume you have
set a filter which only displays a single record in ALV output but
the huge dataset was selected. Furthermore, you have a many
records which you are sorting – again this is happening on the
application layer.
 With HANA database aka HDB aka in-memory DB, many of the
operation which can be executed on the front-end can be send
to the database – the code pushdown.

Copyright © Capgemini 2015. All Rights Reserved 63


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 64
ALV with IDA: Basic Components

• Support for any DB – all data is buffered in internal table

• Drill-down
• Aggregation
• Grouping

• Fuzzy search
• Integrated text search

Copyright © Capgemini 2015. All Rights Reserved 65


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 66
ALV with IDA: Programming interface

Calling for one table in the program


• Simple program in two lines with a table
   DATA(lo_alv) = cl_salv_gui_table_ida=>create( iv_table_name
 =  'BSEG' ).
  lo_alv->fullscreen( )->display( ).
• Simple Program in two lines with CDS View
 DATA(lo_alv) = cl_salv_gui_table_ida=>create( ’ZCDS_VIEW' ).
  lo_alv->fullscreen( )->display( ).

Copyright © Capgemini 2015. All Rights Reserved 67


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 68
Demo Program for SALV IDA

 CDS View
We Need to create the CDS View First then we will consume
this CDS view and make use of SALV IDA

Copyright © Capgemini 2015. All Rights Reserved 69


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 70
Show Complete CDS View Output

With this program we are printing out the complete CDS view
data with SALV

Copyright © Capgemini 2015. All Rights Reserved 71


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 72
Handling Selections in SALV IDA

We need to declare a select option as p_bupaid

Then we need to pass the entered selection criteria to the ALV


dynamically

Copyright © Capgemini 2015. All Rights Reserved 73


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 74
Set Field Catalog for Fields

We can set field catalog texts and tooltip texts for each fields
present in the alv.
SET_FIELD_HEADER_TEXTS method does this for us.

Copyright © Capgemini 2015. All Rights Reserved 75


Set Field Catalog for Fields

In SALV IDA we can obtain the fields considered for the ALV.
Then we can extract the available fields by method
get_available_fields and then we will get rid of all the fields
ending with _GUID . After we pass the same data with
set_available_fields then Alv is going to show us all the fields
required.

Copyright © Capgemini 2015. All Rights Reserved 76


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 77
Setting Field operation criteria at runtime

We can disable different functionalities for designated


fields by method call. In the example disable
aggregation will disable the mathematical operations on
field GROSS_AMOUNT and WEB_ADDRESS

Copyright © Capgemini 2015. All Rights Reserved 78


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 79
More Display Options

We have the freedom to set the fields interchangeable in the ALV . To do


that we refer to enable_alternating_row_pattern for the display option .
Normally for reports the program title is set as we enter in the program
description. But for IDA-ALV we can overwrite that at runtime by calling
method set_title in display options. We can also set the initial grouping if
applicable with a particular field by specifying that in default layout
properties. We can also disable some standard functionalities if needed
by calling the standard_functions.

Copyright © Capgemini 2015. All Rights Reserved 80


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 81
Adding a button

Copyright © Capgemini 2015. All Rights Reserved 82


Adding a button

Finally this code will add a button in the toolbar area and will act
when a line selection is active.

Copyright © Capgemini 2015. All Rights Reserved 83


Contents

 SALV IDA Introduction


 What is SALV
 Why to use SALV
 ALV with IDA – Basic Components
 ALV with IDA – Programming Interface
 Demo Program on SALV IDA
 Show Complete CDS View Output
 Handling Selections in SALV IDA
 Set Field Catalog for fields
 Setting Field operation criteria at runtime
 More display options
 Adding a button
 For Hotspot
Copyright © Capgemini 2015. All Rights Reserved 84
For Hotspot
TRY.
o_salv_ida->field_catalog( )->display_options(
)->display_as_link_to_action( 'MSGNR' ).
SET HANDLER me->handle_hot_spot FOR
o_salv_ida->field_catalog( )->display_options(
).
CATCH cx_salv_ida_unknown_name
cx_salv_call_after_1st_display.
ENDTRY.

Copyright © Capgemini 2015. All Rights Reserved 85


Summary

 In this lesson, you have learnt:

Copyright © Capgemini 2015. All Rights Reserved 86


Thank you

Copyright © Capgemini 2015. All Rights Reserved 87

You might also like