Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
27 views
ABAP Basic
ABAP Basic
Uploaded by
Anay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save ABAP Basic For Later
Download
Save
Save ABAP Basic For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
27 views
ABAP Basic
ABAP Basic
Uploaded by
Anay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save ABAP Basic For Later
Carousel Previous
Carousel Next
Save
Save ABAP Basic For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 55
Search
Fullscreen
Unit 4: Basic ABAP Language ElementsLesson: Working with Elementary Data Objects Lesson Overview ¢ 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.Business Example + You are supposed to use simple variables in your programs and edit these with simple statements.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) el Type for integer (1), 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 «Cc Type for character string (Character) for which the fixed length is to be specified oN 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.fa Defining Data Objects installed ABA® types (standard types in ABAP} | & ~~ zp lz]=* 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 Cis 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 Cis 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 vari TO var2. * var2 = vari,+ If both data objects vari 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 ExpressionsConditional Branches JE statements CASE statement Nested IF statements* 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. >Logical Expressions + 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 lagical expressions. A logical condition can be either true or false.Comparing Data Objects + Comparisons Between Different Data Types * Comparing StringsComparison between different data types
Weaning Eo | eqalto = ewalto NE sok ecual to ° not equal to >< I rok equal to iT I ts than I Hess than le less than or equal 0 < Toss than or equal cr I (rester than > I ‘greater than cE seater than or equal to = (eater than or equal 1»Comparing Strings
SAP VIDEO, Se Statements {fF
. EXIT. ENDIF ENDDO, DO n Times. Statements ENDDO. ne onion, Se Statements ENDWHILE, SELECT ... FROM
.. Statements ENDSELECT. LOOP AT
... Statements ENDLOOP. Loops 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,Unconditional 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.Conditional 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.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.Terminating a Loop Pass Unconditionally * 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 Conditionally + 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.Exiting a Loop * 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.* You can have several nested WHILE or DO loops together. « Several nested loops may affect your program performance. ->Dialog Messages + 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 MESSAGE tnnn(message_class) [ WITH v1[ v2] [v3] [v4] 1. [Description [Dialog behavior [Message appears in i finto continues after intern Modal. box Message _|Program continues without interruption _|Status bar next screen jw [Warning _|Context-dependent [Status bar or modal dialog box je Error Context-dependent |Status bar or modal dialog box ja [Termination [Program cancelled [Modal dialog box x [Short dui Runtime error MESAGE TYPE X triggered [Short dum+ 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. >Lesson: Working with Structures Lesson Overview 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.Business Example + You are to process your own first data structures.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.When you set the types, you can refer to: + A Dictionary structure. + Atransparent table (that is then used as a structure type) © a structure type that is declared locally in the program* The following graphic shows the definition of a structure variable using a locally declared structure type. TYPES: BEGIN OF st_flightinfo, earrid TYPE 5_carr_id, connid type 5_conn_id, fidate TYPE 5_date, seatamax TYPE sflight-seatsmax, seatsocc TYPE sflight-seatsocc, Percentage (3) TYPE p DECIMALS 2, END OF st_flightinfo. DATA 18 flightinfo TYPE st_flightinto.« 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, para; Beem oF 1s_siightints,| carrid TYPE s carr id, ' connta) cope: ope Ad, END OF structure_name. Eigeve FERe acim, = seatenax TYPE sflight-seatsmax, seateoce TYPE sflight-seatscce, L BND OF le_flightinto.* Components of a structure are always addressed using a hyphen: structure_name-component_name. + For this reason, you should not use hyphens in names.MOVE-CORRESPONDING + 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.->Create a Structure in the ABAP Dictionary Create a Nested Structure in the ABAP DictionaryYou should now be able to: + Define structured data objects (structure variables) + Use basic ABAP statements for structured data objects * Create a structure in the ABAP DictionaryOverview of Search Helps + 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 HelpsSearch Helps (F4 help) S wing Code Ea Fight No. J ie a * © Es x wt we ow & % so xUnit 4: Case Study: Flight Information Report Summary + 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.
You might also like
Latest Algorithm Design Using Pseudocode
PDF
No ratings yet
Latest Algorithm Design Using Pseudocode
28 pages
SAP ABAP Basic Concepts
PDF
No ratings yet
SAP ABAP Basic Concepts
33 pages
3 - ABAP Programming Part2
PDF
No ratings yet
3 - ABAP Programming Part2
58 pages
ABAP Programming
PDF
No ratings yet
ABAP Programming
90 pages
3 ABAP Programming
PDF
No ratings yet
3 ABAP Programming
105 pages
Complete Abap Basic
PDF
67% (6)
Complete Abap Basic
729 pages
Introduction To ABAP: DATA Variable - Name Type Variable - Type
PDF
No ratings yet
Introduction To ABAP: DATA Variable - Name Type Variable - Type
4 pages
01 Abap1
PDF
No ratings yet
01 Abap1
72 pages
Abapprogrammingoverview 090715081305 Phpapp02
PDF
No ratings yet
Abapprogrammingoverview 090715081305 Phpapp02
72 pages
Abapprogrammingoverview 090715081305 Phpapp02
PDF
No ratings yet
Abapprogrammingoverview 090715081305 Phpapp02
72 pages
ABAP Language: WRITE 'Hello World!'
PDF
No ratings yet
ABAP Language: WRITE 'Hello World!'
17 pages
Algorithm Design
PDF
No ratings yet
Algorithm Design
28 pages
Programming Techniques: There Are 3 Parts
PDF
No ratings yet
Programming Techniques: There Are 3 Parts
4 pages
1abap Overview
PDF
No ratings yet
1abap Overview
50 pages
ABAP Programming Overview
PDF
No ratings yet
ABAP Programming Overview
393 pages
Advanced ABAP
PDF
No ratings yet
Advanced ABAP
45 pages
ABAP - T02-001 - ABAP Basic Statements - v1.02
PDF
No ratings yet
ABAP - T02-001 - ABAP Basic Statements - v1.02
50 pages
BC100 Intro To Abap Footnotes
PDF
No ratings yet
BC100 Intro To Abap Footnotes
4 pages
QR V1 - 2 Abap
PDF
No ratings yet
QR V1 - 2 Abap
3 pages
ES-26 Exer-2 Prelab
PDF
No ratings yet
ES-26 Exer-2 Prelab
21 pages
Chapter 3 ABAP Editor (Write Statement and Elementary Data Types)
PDF
No ratings yet
Chapter 3 ABAP Editor (Write Statement and Elementary Data Types)
27 pages
1 0 Cobol Funda
PDF
No ratings yet
1 0 Cobol Funda
24 pages
Pseudocode, Flowcharts & Programmin
PDF
No ratings yet
Pseudocode, Flowcharts & Programmin
18 pages
Introduction To ABAP - Karun
PDF
No ratings yet
Introduction To ABAP - Karun
4 pages
02 Abap2 090715081258 Phpapp02
PDF
No ratings yet
02 Abap2 090715081258 Phpapp02
68 pages
Report On The Things I Have Covered in ABAP: Advanced Business Application Programming
PDF
No ratings yet
Report On The Things I Have Covered in ABAP: Advanced Business Application Programming
11 pages
Abap Overview
PDF
No ratings yet
Abap Overview
41 pages
07 - ABAP - Common Control Statements
PDF
No ratings yet
07 - ABAP - Common Control Statements
36 pages
Visual Application Development EN 2013: Year Semester September
PDF
No ratings yet
Visual Application Development EN 2013: Year Semester September
29 pages
Shift Circular. Shift Right by 2 Places
PDF
No ratings yet
Shift Circular. Shift Right by 2 Places
3 pages
Programming Notes-1
PDF
No ratings yet
Programming Notes-1
17 pages
JK Notes
PDF
No ratings yet
JK Notes
131 pages
Casio Picaxe Manual
PDF
No ratings yet
Casio Picaxe Manual
20 pages
PLSQL Imp
PDF
100% (1)
PLSQL Imp
24 pages
Control Statement (Visual Basic)
PDF
No ratings yet
Control Statement (Visual Basic)
11 pages
Unit II - Determinate and Indeterminate Loops
PDF
100% (1)
Unit II - Determinate and Indeterminate Loops
15 pages
Chapter 7,8
PDF
No ratings yet
Chapter 7,8
12 pages
Sequence and Selection Control Structure
PDF
No ratings yet
Sequence and Selection Control Structure
11 pages
ABAP Programming Overview
PDF
No ratings yet
ABAP Programming Overview
72 pages
Fox Syntax
PDF
No ratings yet
Fox Syntax
11 pages
Class Notes
PDF
No ratings yet
Class Notes
15 pages
Programming (3)
PDF
No ratings yet
Programming (3)
36 pages
ABAP Basics: ABAP Stands For Advanced Business Application Programming. It Is A Programming
PDF
No ratings yet
ABAP Basics: ABAP Stands For Advanced Business Application Programming. It Is A Programming
18 pages
PL-SQL
PDF
No ratings yet
PL-SQL
45 pages
Pseudocodes
PDF
No ratings yet
Pseudocodes
19 pages
Pseudocode Notes
PDF
No ratings yet
Pseudocode Notes
13 pages
Cheat Sheet - Modern ABAP
PDF
No ratings yet
Cheat Sheet - Modern ABAP
11 pages
ABAP's Baiscs
PDF
No ratings yet
ABAP's Baiscs
23 pages
Interview Questions
PDF
No ratings yet
Interview Questions
9 pages
7 and 8 Programming Concepts UPDATED (MT-L)
PDF
No ratings yet
7 and 8 Programming Concepts UPDATED (MT-L)
23 pages
VB-UNIT-2-Notes
PDF
No ratings yet
VB-UNIT-2-Notes
24 pages
Sap Abap V.1
PDF
No ratings yet
Sap Abap V.1
442 pages
Account Category Reference (ACR) – Grandfather of Automatic Account Determination
PDF
No ratings yet
Account Category Reference (ACR) – Grandfather of Automatic Account Determination
42 pages
CFIN S4 HANA
PDF
No ratings yet
CFIN S4 HANA
18 pages
Three way match functionality SAP
PDF
No ratings yet
Three way match functionality SAP
7 pages
BTE in SAP
PDF
No ratings yet
BTE in SAP
33 pages
GST Config
PDF
No ratings yet
GST Config
11 pages
ABAP SAP
PDF
No ratings yet
ABAP SAP
63 pages
Validation and Substitution SAP
PDF
No ratings yet
Validation and Substitution SAP
32 pages
IDOC SAP
PDF
No ratings yet
IDOC SAP
3 pages
End User Manual
PDF
No ratings yet
End User Manual
374 pages
AUC
PDF
No ratings yet
AUC
37 pages
Document Implementation
PDF
No ratings yet
Document Implementation
1 page
Methods of Preservation
PDF
No ratings yet
Methods of Preservation
7 pages