SlideShare a Scribd company logo
1 of 55
Unit 4: Basic ABAP Language Elements
• In this lesson you will become familiar with the difference between data
types and data objects and you will learn how to define and use these in
a program. You will also learn some basic ABAP statements.
• You will be working with structures and internal tables, as well as
program flow control and logical expressions.
Lesson: Working with Elementary Data Objects
Lesson Overview
• You are supposed to use simple variables in your programs and edit
these with simple statements.
Business Example
Data Types and Data Objects
• A formal variable description is called data type. In contrast, a variable
concretely defined by means of a data type is called data object.
• Let's have a look at the ABAP standard types predefined by SAP
(implemented types) first.
• These are divided into two groups:
• Complete and
• incomplete types.
• The following implemented ABAP standard types are complete.
• This means that they already contain the type-related, fixed length
information:
• Complete ABAP standard types
• D
Type for date(D), format: YYYYMMDD, length 8 (fixed)
• T
Type for time (Time), Format: HHMMSS, length 6 (fixed)
• I
Type for integer (I), length 4 (fixed)
• F
Type for floating point number (F), length 8 (fixed)
• STRING
Type for dynamic length character string
• XSTRING
Type for dynamic length byte sequence (HeXadecimal string)
• The following standard types do not contain a fixed length (incomplete).
With these, the length of the variable has to be specified for data object
definitions.
• Incomplete ABAP standard types
• C
Type for character string (Character) for which the fixed length is to be
specified
• N
Type for numerical character string (Numerical character) for which the
fixed length is to be specified
• X
Type for byte sequence (HeXadecimal string) for which the fixed length is
to be specified
• P
Type for packed number (Packed number) for which the fixed length is to
be specified. (In the definition of a packed number, the number of
decimal points may also be specified.)
• For more information on predefined ABAP types, refer to the keyword
documentation on the TYPES or DATA statement.
Declaration of local types
TYPES type_name TYPE …
DATA myvarTYPE type_name-
DATA myvar2 LIKE myvar.
ABAP Program
type_name
Defining
Data
Objects
• Data objects are always defined with the DATA key word.
• You can use an ABAP standard type, a local type, or a global type to type
a data object.
• You can refer to an already defined data object when defining additional
variables (LIKE addition).
• If the type information is missing in a variable definition, the standard
type C is assumed.
• In contrast, if the length is missing, then the appropriate default length
for the (incomplete) standard type is used.
• The "DATA myvar." statement without type or length information thus
defines a character variable with a length of 1 as the default length of
type C is one.
• Literals and constants belong to the fixed data objects.
• You can use literals to specify fixed values in your programs.
• There are numeric literals (specified without quotation marks) and text
literals (specified with quotation marks).
• You define constants using the CONSTANTS statement.
• The VALUE addition is required for constants.
• Local data types can only be used in the program where they are
defined.
• Global data types, in contrast, can be used throughout the entire
system.
Basic ABAP Statements
• You can use the MOVE statement to transfer the contents of a data object
to another data object.
• The following two syntax variants have the same effect:
• MOVE var1 TO var2.
• var2 = var1.
• If both data objects var1 and var2 are of different types, then there is a
type conflict.
• In this case, a type conversion is carried out automatically, if a
conversion rule exists.
• For detailed information on copying and the conversion rules, refer to
the keyword documentation for the MOVE statement.
• The CLEAR statement resets the contents of a data object to the type-
specific initial value.
Performing Calculations
• In ABAP you can program arithmetic expressions nested to any depth.
Valid operations include:
• + Addition
• - Subtraction
• * Multiplication
• / Division
• ** Exponentiation
• DIV Integral division without remainder
• MOD Remainder after integral division
• the following statement provides the current length of the content of a
character variable.
• length = STRLEN( cityfrom ).
Program Flow Control And Logical Expressions
Conditional Branches
IF statements
Nested IF statements
CASE statement
• In ABAP you have two ways to execute different sequences of
statements, depending on certain conditions:
• In the IF construct you can define any logical expressions as check
conditions.
• You can use nested IF statements, using the ELSEIF clause.
• You can use the CASE construct to clearly distinguish cases.
• The content of the field specified in the CASE part is checked against the
data objects listed in the WHEN branches to see whether they match.
• In both constructs the condition or match check happens sequentially
from the top down.
• As soon as the statement block of a branch has been executed, the
system immediately jumps to ENDIF or ENDCASE. 
• When writing application programs, you often need to formulate
conditions.
• These are used mostly to control the flow of the program, or to decide
whether to exit a processing block.
• You formulate a condition using logical expressions. A logical condition
can be either true or false.
Logical Expressions
• Comparisons Between Different Data Types
• Comparing Strings
Comparing Data Objects
Comparison between different data types
Comparing Strings
• To combine several logical expressions together in one single expression
which is true only if all of the component expressions are true, link the
expressions with AND.
• To combine several logical expressions together in one single expression
which is true if at least one of the component expressions is true, link
the expressions with OR.
• To negate the result of a logical expression, you can precede it with the
NOT operator.  SAP VIDEO
Combining Several Logical Expressions (AND, OR)
• In a loop, a statement block is executed
several times in succession. There are four
kinds of loops in ABAP:
• Unconditional loops using the DO statement.
• Conditional loops using the WHILE statement.
• Loops through internal tables and extract
datasets using the LOOP statement.
• Loops through datasets from database tables
using the SELECT statement.
DO.
Statements
IF <abort_condition>. EXIT. END IF
ENDDO.
DO n TIMES.
Statements
ENDDO.
WHILE <condition>.
Statements
ENDWHILE.
SELECT … FROM <adtab> …
Statements
ENDSELECT.
LOOP AT <internal table> …
Statements
ENDLOOP.
Loop counter
sy-index
Loop counter
sy-index
Loop counter
sy-index Loops
• To process a statement block several times unconditionally, use the
following control structure:
• DO [n TIMES] ...
[statement_block]
ENDDO.
• Use the TIMES addition to restrict the number of loop passes to n.
• If you do not specify any additions, the statement block is repeated until
it reaches a termination statement such as EXIT or STOP.
Unconditional Loops
• To repeat a statement block for as long as a certain condition is true,
use the following control structure:
• WHILE log_exp
[statemaent_block]
ENDWHILE.
• log_exp can be any logical expression.
• The statement block between WHILE and ENDWHILE is repeated as long
as the condition is true or until a termination statement such
as EXIT or STOP occurs.
Conditional Loops
Terminating Loops
• ABAP contains termination statements that allow you to terminate a
loop prematurely.
• There are two categories of termination statement:
• 1- those that only apply to the loop,
• 2- and those that apply to the entire processing block in which the loop
occurs
• The termination statements that apply only to the loop in which they
occur are CONTINUE, CHECKand EXIT.
• The STOPand REJECT statements terminate the entire processing block.
• DO 4 TIMES.
IF sy-index = 2.
CONTINUE.
ENDIF.
WRITE sy-index.
ENDDO.
• The list output is:
1 3 4
The second loop pass is terminated without the WRITE statement being
processed.
Terminating a Loop Pass Unconditionally
• DO 4 TIMES.
CHECK sy-index BETWEEN 2 and 3.
WRITE sy-index.
ENDDO.
• The list output is:
2 3
• The first and fourth loop passes are terminated without
the WRITE statement being processed, because sy-index is not between
2 and 3.
Terminating a Loop Pass Conditionally
• DO 4 TIMES.
IF sy-index = 3.
EXIT.
ENDIF.
WRITE sy-index.
ENDDO.
• The list output is:
1 2
• In the third loop pass, the loop is terminated before
the WRITE statement is processed.
Exiting a Loop
• You can have several nested WHILE or DO loops together.
• Several nested loops may affect your program performance. ->
• You use the MESSAGE statement to send dialog messages to the users
of your Program.
• When you do this, you must specify the three digit message number
and the message class.
Dialog Messages
Dialog Messages
MESSAGE tnnn(message_class) [ WITH v1 [ v2 ] [ v3 ] [ v4 ] ] .
• Message number and message class clearly identify the message to be
displayed.
• You use the message type to specify where the message is to be
displayed.
• You can test the display behavior for using the different message types
by means of the DEMO_MESSAGES demo program that is shipped in the
SAP standard.
• For further information on the syntactical alternatives to the MESSAGE
statement, refer to the keyword documentation. 
• In this lesson, we will continue with the definition of structured data
objects (structure variables). Also, this chapter will teach you how to
use basic ABAP statements for structured data objects.
Lesson: Working with Structures
Lesson Overview
• You are to process your own first data structures.
Business Example
• In ABAP, you can define structured data objects (called structure
variables or simply structures).
• This allows you to combine values that belong together logically into
one data object.
• Structures can be nested.
• This means that components can be made up of more structures or
even internal tables.
• In the program, structure variables are defined with the DATA
statement, in the same way as elementary data objects.
• A Dictionary structure.
• A transparent table (that is then used as a structure type)
• a structure type that is declared locally in the program
When you set the types, you can refer to:
• The following graphic shows the definition of a structure variable using
a locally declared structure type.
Declaration of a
Local Structure
Type
Definition of a
structure
variable
• You can use the TYPES statement to define local structure types. Here
the components are enclosed by
BEGIN OF structure_type_name,
... ,
END OF structure_type_name.
• You can assign any type you want to each component by using the TYPE
addition. For more details, refer to the keyword documentation for the
TYPES statement. ->
• If necessary, you can also define a structured data object directly. To do
so, all you have to do is replace the leading key word TYPES with DATA.
DATA: BEGIN OF structure_name,
... ,
END OF structure_name.
• Components of a structure are always addressed using a hyphen:
structure_name-component_name.
• For this reason, you should not use hyphens in names.
• The MOVE-CORRESPONDING statement copies the contents of the
source structure to the target structure one component at a time.
• Here, only those components are considered that are available under
the same name in both the source and the target structure.
• All other components of the structures remain unchanged.
• The individual value assignments can each be executed using MOVE.->
MOVE-CORRESPONDING
Create a Structure in the ABAP Dictionary
Create a Nested Structure in the ABAP Dictionary
• Define structured data objects (structure variables)
• Use basic ABAP statements for structured data objects
• Create a structure in the ABAP Dictionary
You should now be able to:
• The input help (F4 help) is a standard function of the R/3 System.
• The user can display the list of all possible input values for a screen field
with the input help
• The possible input values can be enhanced with further information.
• This standard process can be completely defined by creating a search
help in the ABAP Dictionary.
• There are two types of search help:
• Elementary Search Helps
• Collective Search Helps
Overview of Search Helps
Search Helps (F4 help)
• Your assignment is to:
• Modify the “Flight Report” created earlier so that it shows the Airline
Code, No. Flight, Flight Date, Total amount of bookings, Total occupied
seats, and Total free seats.
• Create a structure for the report fields.
• Make it possible to filter by Airline Code and Flight No.
• Attach a search help to the input fields filters.
Unit 4: Case Study: Flight Information Report Summary

More Related Content

What's hot

SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed NotesAkash Bhavsar
 
Abap data dictionary
Abap data dictionaryAbap data dictionary
Abap data dictionarySmartGokul4
 
Oops abap fundamental
Oops abap fundamentalOops abap fundamental
Oops abap fundamentalbiswajit2015
 
Sap abap interview questions
Sap abap interview questionsSap abap interview questions
Sap abap interview questionskssr99
 
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERS
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERS500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERS
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERSIICT Chromepet
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionaryvkyecc1
 
HR ABAP Programming Training Material | http://sapdocs.info
HR ABAP Programming Training Material | http://sapdocs.infoHR ABAP Programming Training Material | http://sapdocs.info
HR ABAP Programming Training Material | http://sapdocs.infosapdocs. info
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questionsKranthi Kumar
 
HANA WITH ABAP OVERVIEW
HANA WITH ABAP OVERVIEWHANA WITH ABAP OVERVIEW
HANA WITH ABAP OVERVIEWdheerajad
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overviewsapdocs. info
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)Kranthi Kumar
 
Sap abap part1
Sap abap part1Sap abap part1
Sap abap part1sailesh107
 

What's hot (20)

SAP-ABAP/4@e_max
SAP-ABAP/4@e_maxSAP-ABAP/4@e_max
SAP-ABAP/4@e_max
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
 
Abap data dictionary
Abap data dictionaryAbap data dictionary
Abap data dictionary
 
Oops abap fundamental
Oops abap fundamentalOops abap fundamental
Oops abap fundamental
 
SAP ABAP data dictionary
SAP ABAP data dictionarySAP ABAP data dictionary
SAP ABAP data dictionary
 
Sap abap interview questions
Sap abap interview questionsSap abap interview questions
Sap abap interview questions
 
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERS
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERS500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERS
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERS
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
 
HR ABAP Programming Training Material | http://sapdocs.info
HR ABAP Programming Training Material | http://sapdocs.infoHR ABAP Programming Training Material | http://sapdocs.info
HR ABAP Programming Training Material | http://sapdocs.info
 
Field symbols
Field symbolsField symbols
Field symbols
 
Dialog programming ABAP
Dialog programming ABAPDialog programming ABAP
Dialog programming ABAP
 
SAP ABAP OVERVIEW
SAP ABAP OVERVIEWSAP ABAP OVERVIEW
SAP ABAP OVERVIEW
 
Alv theory
Alv theoryAlv theory
Alv theory
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
 
Abap dictionary 1
Abap dictionary 1Abap dictionary 1
Abap dictionary 1
 
HANA WITH ABAP OVERVIEW
HANA WITH ABAP OVERVIEWHANA WITH ABAP OVERVIEW
HANA WITH ABAP OVERVIEW
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
 
Sap abap part1
Sap abap part1Sap abap part1
Sap abap part1
 
Sap abap
Sap abapSap abap
Sap abap
 

Viewers also liked

SAP-HANA - Loading ff into_table_sap hana
SAP-HANA - Loading ff into_table_sap hanaSAP-HANA - Loading ff into_table_sap hana
SAP-HANA - Loading ff into_table_sap hanaYasmin Ashraf
 
ABAP Material 05
ABAP Material 05ABAP Material 05
ABAP Material 05warcraft_c
 
0101 sap introduction
0101 sap introduction0101 sap introduction
0101 sap introductionvkyecc1
 
0105 abap programming_overview
0105 abap programming_overview0105 abap programming_overview
0105 abap programming_overviewvkyecc1
 
Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1Kranthi Kumar
 
Beginner’s guide to sap abap 1
Beginner’s guide to sap abap 1Beginner’s guide to sap abap 1
Beginner’s guide to sap abap 1Panduka Bandara
 
Sap pm tables
Sap pm tablesSap pm tables
Sap pm tablesvbpc
 
ABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type GroupABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type Groupsapdocs. info
 
Sap table relation
Sap table relationSap table relation
Sap table relationRameeza09
 
SAP Table Logics
SAP Table LogicsSAP Table Logics
SAP Table Logicsguestf3438c
 
Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...
Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...
Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...Hortonworks
 

Viewers also liked (13)

SAP-HANA - Loading ff into_table_sap hana
SAP-HANA - Loading ff into_table_sap hanaSAP-HANA - Loading ff into_table_sap hana
SAP-HANA - Loading ff into_table_sap hana
 
Informatica mdm online training
Informatica mdm online trainingInformatica mdm online training
Informatica mdm online training
 
ABAP Material 05
ABAP Material 05ABAP Material 05
ABAP Material 05
 
0101 sap introduction
0101 sap introduction0101 sap introduction
0101 sap introduction
 
0105 abap programming_overview
0105 abap programming_overview0105 abap programming_overview
0105 abap programming_overview
 
Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1
 
Beginner’s guide to sap abap 1
Beginner’s guide to sap abap 1Beginner’s guide to sap abap 1
Beginner’s guide to sap abap 1
 
Sap pm tables
Sap pm tablesSap pm tables
Sap pm tables
 
ABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type GroupABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type Group
 
Sap table relation
Sap table relationSap table relation
Sap table relation
 
Module pool programming
Module pool programmingModule pool programming
Module pool programming
 
SAP Table Logics
SAP Table LogicsSAP Table Logics
SAP Table Logics
 
Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...
Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...
Modern Data Architecture for a Data Lake with Informatica and Hortonworks Dat...
 

Similar to Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions

Similar to Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions (20)

CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
 
Java platform
Java platformJava platform
Java platform
 
12.6-12.9.pptx
12.6-12.9.pptx12.6-12.9.pptx
12.6-12.9.pptx
 
Pl sql best practices document
Pl sql best practices documentPl sql best practices document
Pl sql best practices document
 
E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
 
Data structure
Data structureData structure
Data structure
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
 
STORAGE CLASS.pptx
STORAGE CLASS.pptxSTORAGE CLASS.pptx
STORAGE CLASS.pptx
 
Unit 4 plsql
Unit 4  plsqlUnit 4  plsql
Unit 4 plsql
 
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptxAlgorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
PPT 19.pptx
PPT 19.pptxPPT 19.pptx
PPT 19.pptx
 
Java introduction
Java introductionJava introduction
Java introduction
 
Getting started with CATIA V5 Macros
Getting started with CATIA V5 MacrosGetting started with CATIA V5 Macros
Getting started with CATIA V5 Macros
 
8. data types
8. data types8. data types
8. data types
 
Lsmw ppt in SAP ABAP
Lsmw ppt in SAP ABAPLsmw ppt in SAP ABAP
Lsmw ppt in SAP ABAP
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Recently uploaded (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions

  • 1. Unit 4: Basic ABAP Language Elements
  • 2. • In this lesson you will become familiar with the difference between data types and data objects and you will learn how to define and use these in a program. You will also learn some basic ABAP statements. • You will be working with structures and internal tables, as well as program flow control and logical expressions. Lesson: Working with Elementary Data Objects Lesson Overview
  • 3. • You are supposed to use simple variables in your programs and edit these with simple statements. Business Example
  • 4. Data Types and Data Objects
  • 5. • A formal variable description is called data type. In contrast, a variable concretely defined by means of a data type is called data object. • Let's have a look at the ABAP standard types predefined by SAP (implemented types) first. • These are divided into two groups: • Complete and • incomplete types.
  • 6. • The following implemented ABAP standard types are complete. • This means that they already contain the type-related, fixed length information: • Complete ABAP standard types • D Type for date(D), format: YYYYMMDD, length 8 (fixed) • T Type for time (Time), Format: HHMMSS, length 6 (fixed) • I Type for integer (I), length 4 (fixed)
  • 7. • F Type for floating point number (F), length 8 (fixed) • STRING Type for dynamic length character string • XSTRING Type for dynamic length byte sequence (HeXadecimal string)
  • 8. • The following standard types do not contain a fixed length (incomplete). With these, the length of the variable has to be specified for data object definitions. • Incomplete ABAP standard types • C Type for character string (Character) for which the fixed length is to be specified • N Type for numerical character string (Numerical character) for which the fixed length is to be specified
  • 9. • X Type for byte sequence (HeXadecimal string) for which the fixed length is to be specified • P Type for packed number (Packed number) for which the fixed length is to be specified. (In the definition of a packed number, the number of decimal points may also be specified.) • For more information on predefined ABAP types, refer to the keyword documentation on the TYPES or DATA statement.
  • 10. Declaration of local types TYPES type_name TYPE … DATA myvarTYPE type_name- DATA myvar2 LIKE myvar. ABAP Program type_name Defining Data Objects
  • 11. • Data objects are always defined with the DATA key word. • You can use an ABAP standard type, a local type, or a global type to type a data object. • You can refer to an already defined data object when defining additional variables (LIKE addition).
  • 12. • If the type information is missing in a variable definition, the standard type C is assumed. • In contrast, if the length is missing, then the appropriate default length for the (incomplete) standard type is used. • The "DATA myvar." statement without type or length information thus defines a character variable with a length of 1 as the default length of type C is one.
  • 13. • Literals and constants belong to the fixed data objects. • You can use literals to specify fixed values in your programs. • There are numeric literals (specified without quotation marks) and text literals (specified with quotation marks). • You define constants using the CONSTANTS statement.
  • 14. • The VALUE addition is required for constants. • Local data types can only be used in the program where they are defined. • Global data types, in contrast, can be used throughout the entire system.
  • 16. • You can use the MOVE statement to transfer the contents of a data object to another data object. • The following two syntax variants have the same effect: • MOVE var1 TO var2. • var2 = var1.
  • 17. • If both data objects var1 and var2 are of different types, then there is a type conflict. • In this case, a type conversion is carried out automatically, if a conversion rule exists. • For detailed information on copying and the conversion rules, refer to the keyword documentation for the MOVE statement. • The CLEAR statement resets the contents of a data object to the type- specific initial value.
  • 19. • In ABAP you can program arithmetic expressions nested to any depth. Valid operations include: • + Addition • - Subtraction • * Multiplication • / Division • ** Exponentiation • DIV Integral division without remainder • MOD Remainder after integral division
  • 20. • the following statement provides the current length of the content of a character variable. • length = STRLEN( cityfrom ).
  • 21. Program Flow Control And Logical Expressions
  • 22. Conditional Branches IF statements Nested IF statements CASE statement
  • 23. • In ABAP you have two ways to execute different sequences of statements, depending on certain conditions: • In the IF construct you can define any logical expressions as check conditions. • You can use nested IF statements, using the ELSEIF clause. • You can use the CASE construct to clearly distinguish cases. • The content of the field specified in the CASE part is checked against the data objects listed in the WHEN branches to see whether they match.
  • 24. • In both constructs the condition or match check happens sequentially from the top down. • As soon as the statement block of a branch has been executed, the system immediately jumps to ENDIF or ENDCASE. 
  • 25. • When writing application programs, you often need to formulate conditions. • These are used mostly to control the flow of the program, or to decide whether to exit a processing block. • You formulate a condition using logical expressions. A logical condition can be either true or false. Logical Expressions
  • 26. • Comparisons Between Different Data Types • Comparing Strings Comparing Data Objects
  • 29. • To combine several logical expressions together in one single expression which is true only if all of the component expressions are true, link the expressions with AND. • To combine several logical expressions together in one single expression which is true if at least one of the component expressions is true, link the expressions with OR. • To negate the result of a logical expression, you can precede it with the NOT operator.  SAP VIDEO Combining Several Logical Expressions (AND, OR)
  • 30. • In a loop, a statement block is executed several times in succession. There are four kinds of loops in ABAP: • Unconditional loops using the DO statement. • Conditional loops using the WHILE statement. • Loops through internal tables and extract datasets using the LOOP statement. • Loops through datasets from database tables using the SELECT statement. DO. Statements IF <abort_condition>. EXIT. END IF ENDDO. DO n TIMES. Statements ENDDO. WHILE <condition>. Statements ENDWHILE. SELECT … FROM <adtab> … Statements ENDSELECT. LOOP AT <internal table> … Statements ENDLOOP. Loop counter sy-index Loop counter sy-index Loop counter sy-index Loops
  • 31. • To process a statement block several times unconditionally, use the following control structure: • DO [n TIMES] ... [statement_block] ENDDO. • Use the TIMES addition to restrict the number of loop passes to n. • If you do not specify any additions, the statement block is repeated until it reaches a termination statement such as EXIT or STOP. Unconditional Loops
  • 32. • To repeat a statement block for as long as a certain condition is true, use the following control structure: • WHILE log_exp [statemaent_block] ENDWHILE. • log_exp can be any logical expression. • The statement block between WHILE and ENDWHILE is repeated as long as the condition is true or until a termination statement such as EXIT or STOP occurs. Conditional Loops
  • 33. Terminating Loops • ABAP contains termination statements that allow you to terminate a loop prematurely. • There are two categories of termination statement: • 1- those that only apply to the loop, • 2- and those that apply to the entire processing block in which the loop occurs • The termination statements that apply only to the loop in which they occur are CONTINUE, CHECKand EXIT. • The STOPand REJECT statements terminate the entire processing block.
  • 34. • DO 4 TIMES. IF sy-index = 2. CONTINUE. ENDIF. WRITE sy-index. ENDDO. • The list output is: 1 3 4 The second loop pass is terminated without the WRITE statement being processed. Terminating a Loop Pass Unconditionally
  • 35. • DO 4 TIMES. CHECK sy-index BETWEEN 2 and 3. WRITE sy-index. ENDDO. • The list output is: 2 3 • The first and fourth loop passes are terminated without the WRITE statement being processed, because sy-index is not between 2 and 3. Terminating a Loop Pass Conditionally
  • 36. • DO 4 TIMES. IF sy-index = 3. EXIT. ENDIF. WRITE sy-index. ENDDO. • The list output is: 1 2 • In the third loop pass, the loop is terminated before the WRITE statement is processed. Exiting a Loop
  • 37. • You can have several nested WHILE or DO loops together. • Several nested loops may affect your program performance. ->
  • 38. • You use the MESSAGE statement to send dialog messages to the users of your Program. • When you do this, you must specify the three digit message number and the message class. Dialog Messages
  • 39. Dialog Messages MESSAGE tnnn(message_class) [ WITH v1 [ v2 ] [ v3 ] [ v4 ] ] .
  • 40. • Message number and message class clearly identify the message to be displayed. • You use the message type to specify where the message is to be displayed. • You can test the display behavior for using the different message types by means of the DEMO_MESSAGES demo program that is shipped in the SAP standard.
  • 41. • For further information on the syntactical alternatives to the MESSAGE statement, refer to the keyword documentation. 
  • 42. • In this lesson, we will continue with the definition of structured data objects (structure variables). Also, this chapter will teach you how to use basic ABAP statements for structured data objects. Lesson: Working with Structures Lesson Overview
  • 43. • You are to process your own first data structures. Business Example
  • 44. • In ABAP, you can define structured data objects (called structure variables or simply structures). • This allows you to combine values that belong together logically into one data object. • Structures can be nested. • This means that components can be made up of more structures or even internal tables. • In the program, structure variables are defined with the DATA statement, in the same way as elementary data objects.
  • 45. • A Dictionary structure. • A transparent table (that is then used as a structure type) • a structure type that is declared locally in the program When you set the types, you can refer to:
  • 46. • The following graphic shows the definition of a structure variable using a locally declared structure type. Declaration of a Local Structure Type Definition of a structure variable
  • 47. • You can use the TYPES statement to define local structure types. Here the components are enclosed by BEGIN OF structure_type_name, ... , END OF structure_type_name. • You can assign any type you want to each component by using the TYPE addition. For more details, refer to the keyword documentation for the TYPES statement. ->
  • 48. • If necessary, you can also define a structured data object directly. To do so, all you have to do is replace the leading key word TYPES with DATA. DATA: BEGIN OF structure_name, ... , END OF structure_name.
  • 49. • Components of a structure are always addressed using a hyphen: structure_name-component_name. • For this reason, you should not use hyphens in names.
  • 50. • The MOVE-CORRESPONDING statement copies the contents of the source structure to the target structure one component at a time. • Here, only those components are considered that are available under the same name in both the source and the target structure. • All other components of the structures remain unchanged. • The individual value assignments can each be executed using MOVE.-> MOVE-CORRESPONDING
  • 51. Create a Structure in the ABAP Dictionary Create a Nested Structure in the ABAP Dictionary
  • 52. • Define structured data objects (structure variables) • Use basic ABAP statements for structured data objects • Create a structure in the ABAP Dictionary You should now be able to:
  • 53. • The input help (F4 help) is a standard function of the R/3 System. • The user can display the list of all possible input values for a screen field with the input help • The possible input values can be enhanced with further information. • This standard process can be completely defined by creating a search help in the ABAP Dictionary. • There are two types of search help: • Elementary Search Helps • Collective Search Helps Overview of Search Helps
  • 55. • Your assignment is to: • Modify the “Flight Report” created earlier so that it shows the Airline Code, No. Flight, Flight Date, Total amount of bookings, Total occupied seats, and Total free seats. • Create a structure for the report fields. • Make it possible to filter by Airline Code and Flight No. • Attach a search help to the input fields filters. Unit 4: Case Study: Flight Information Report Summary

Editor's Notes

  1. How presentation will benefit audience: Adult learners are more interested in a subject if they know how or why it is important to them. Presenter’s level of expertise in the subject: Briefly state your credentials in this area, or explain why participants should listen to you.
  2. Lesson descriptions should be brief.
  3. How presentation will benefit audience: Adult learners are more interested in a subject if they know how or why it is important to them. Presenter’s level of expertise in the subject: Briefly state your credentials in this area, or explain why participants should listen to you.
  4. Lesson descriptions should be brief.
  5. How presentation will benefit audience: Adult learners are more interested in a subject if they know how or why it is important to them. Presenter’s level of expertise in the subject: Briefly state your credentials in this area, or explain why participants should listen to you.
  6. Lesson descriptions should be brief.