SAP ABAP SELECT STATEMENT

Module Objectives

•Explain database Tables / data browser
•Use the SELECT statement and the WHERE clause
•Describe the SELECT SINGLE statement
•Explain the ORDER BY addition
•Describe retrieving individual columns
•Exclude duplicate records during selection
•Describe the SELECT statement syntax
•Define aggregate expressions
•Familiarization with ABAP 7.40 select statement new features
•Discuss performance and best practices
•SQL Console


SELECT Statement - Basic Form

the select statement is very simple in ABAP, we just use Keyword SELECT the we specified all columns of the table which we want to get we use * to show all columns with FROM keyword we specified the table. then we use a variable which will hold the result of the table and, in the end, we use ENDSELECT  to end the select query.

Select_query
Select Query


Selecting specific fields from database table

Selecting specific fields from table

Selecting specific fields from database table

Inline Declaration after INTO for ABAP 7.40

instead of defining all the fields in ABAP 7.40 we can do inline declaration and its very easy and convient.

inline declaration
Inline Declaration

Retrieving a Single Record - SELECT SINGLE

inorder to retrive a single record with query we use SINGLE keyword please check the below code to have a clear idea.

single record
single record

Select-options

inorder to select data based on range like date range or number range we have special query to handle such requirment, please check the example below.

select_options
Select-options

Restricting Data Selection - WHERE clause

we can place condtion in select query using WHERE clause, so we can have a result based on our particular requirment.

where_clause
Restricting data using Where clause

SELECT INTO TABLE

using select into table we can easily populate the internal table using this keyword, to use this keyword we need to have structure of table ready please check the example below.

Select into table
Select into table

INTO CORRESPONDING FIELDS OF Table


into corresponding fields
Into Corresponding fields of table

Aggregates

New possible expressions
  • elementary values
  • arithmetic expressions
  • arithmetic functions abs, ceil, floor, div, mod
  • castings with cast
  • string concatenations
Aggregates
Aggregates

case statments are very usefull in query inorder to select specific values please check two examples to have a clear idea about case.
case Expression
Case Expression

SQL Expressions for JOIN

Column Specification

–In the SELECT list, you can specify all columns of a data source using the syntax data_source~* from 7.40, SP08 on. This can be handy when working with joins.
joins
Sql Expressions for Join
-The operators LIKE and IN can be used in ON conditions.
-individual comparisons can be joined using OR .

sql joins
Sql Joins

For All Entries

instead of join join we can use All entries for keyword to join data of two tables.
For All Entries
For All Entries

Performance

performance
Performance report

Select 

Select use * only recommended when we are getting more than 90% of the fields and use aggregate function when applicable

From

Select from transparent tables and avoid cluster tables, find alternate transparent ones instead.

Into

Use INTO TABLE rather than INTO a work area if you are selecting more than 1 record. there is no performance issue with using INTO CORRESPONDING FIELDS.

WHERE


use a full key search if possible, otherwise, use an index of a partial key search if using for all entries make sure that the internal table is not empty and has no duplicate entries.

SQL Console in Eclipse 

  • The SQL Console is a powerful tool that helps the ABAP developers to work with Open SQL Select statement.
  • It can display the result of select query without the need of ABAP programming.
  • One can open more than one SQL Console and work parallel SQL Console any number of times.

Comments

  1. Sap Abap Select Statement >>>>> Download Now

    >>>>> Download Full

    Sap Abap Select Statement >>>>> Download LINK

    >>>>> Download Now

    Sap Abap Select Statement >>>>> Download Full

    >>>>> Download LINK qd

    ReplyDelete
  2. Great post.It seems to be interesting and gave me lot of information,Thank for sharing it.I am looking forward for new articles.keep it up.
    Inventory management software

    ReplyDelete

Post a Comment

Popular posts from this blog

SAP ADOBE FORMS

ABAP AUTHORIZATION CONCEPT