Introduction to ABAP4 - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Introduction to ABAP4

Description:

Write a Report program. Write an Interface program. How we will ... Blank lines can be placed anywhere in the program and should be used to improve readability. ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 36
Provided by: toddb47
Category:

less

Transcript and Presenter's Notes

Title: Introduction to ABAP4


1
Introduction to ABAP/4
2
What is ABAP/4?
  • Advanced Business Application Program
  • Release 4
  • Why do we need to develop ABAP/4 applications in
    SAP R/3?

3
Why use ABAP?
  • ABAP/4 is the programming language SAP developers
    use to build transactions and customize SAP R/3.
  • The main purpose of ABAP/4 is to provide
    additional functionality to existing SAP
    applications.
  • We tend not to use ABAP/4 to develop custom
    applications from scratch.

4
Purpose of ABAP/4
  • The two most common uses of ABAP/4 are
  • Producing custom reports
  • Developing custom interfaces

5
Reports Interfaces
  • Report - The ABAP program reads specific data
    from the SAP database and then displays this data
    on the screen or writes it to a printer.
  • Interface - The ABAP program reads data from the
    SAP database and writes it to an external file to
    be used by another system (e.g. mainframe).

6
In this course we will?
  • Learn enough ABAP/4 to access the SAP database
    using SQL.
  • Write format this data to a printer / screen.
  • Write this data to an external file
  • SO YOU CAN
  • Write a Report program
  • Write an Interface program

7
How we will proceed
  • We will learn various parts of an ABAP/4 program
    first.
  • We will then put these parts together to develop
    a complete program.

8
Defining a program
  • REPORT program name
  • The report has various features to format output
    to the screen or printer we will talk about these
    features later.

9
Commenting your code
  • It is expected that you will have sufficient
    comments in all the ABAP/4 programs you write.
    Why?
  • It is EXPECTED of all PROFESSIONAL software
    developers.
  • Due to the high turnover rate of SAP R/3 ABAP/4
    consultants, other people may be stuck
    maintaining your program.

10
Adding comments in ABAP/4
  • 1 To comment an entire line use an asterisks
    ().
  • This program will

11
Adding comments in ABAP
  • 2 To comment part of a line use the double quote
    ()
  • WRITE HELLO This statement will.

12
Variables and Constants
  • We have given the program a name and added a
    description of the program in the comments.
  • To manipulate and gather data for processing we
    need variables, records, and constants.

13
A variable is
  • - A symbolic reference to a memory location that
    stores information temporarily. These variables
    persist only during the execution of the program,
    and the data they contain is lost when the
    execution is complete - unless the data is
    transferred to a database table or system file.

14
Variables
  • MUST be declared before they are used.
  • Can be declared anywhere in the program, BUT for
    consistency they should be declared at the
    beginning of a program or subroutine.
  • Begin each variable with a letter and then a
    mixture of letters and numbers

15
Variables
  • Use the underscore (_) to separate distinct
    words. DO NOT use the hyphen ( -) this has a
    special purpose that we will discuss later.
  • NO reserved words (the same name as an ABAP
    command)

16
Variables
  • Standard SCOPE rules apply. Variables defined at
    the program level are considered global,
    variables in subroutines are visible only to the
    subroutine.

17
Declaring variables
  • DATA var(LENGTH) TYPE type DECIMALS number
    VALUE initial value
  • var is the name of the variable
  • (length) is the size of the variable

18
  • TYPE is the type of variable. The possible data
    types for variables in ABAP are

19
Data types for ABAP/4
  • Type/Description/Example
  • C Character hello world
  • D Date 19990101
  • F Floating point 3e4
  • N Numeric text 10000
  • P Packed Decimal 22.50
  • T Time 104500
  • H Hexadecimal 23A

20
We will only use
  • C, D, P, I, T, and maybe N.
  • The DECIMAL is the number of decimal places for
    the packed decimal type.
  • The size of the field digits before the decimal
    digits after the decimal.
  • IF A FIELD HAS 6 DIGITS BEFORE THE DECIMAL AND 2
    DIGITS AFTER , IT MUST BE DECLARED AS A SIZE 8.
  • VALUE is the initial or default value for the
    field at execution.

21
Example 1
  • Declare a variable that will hold the persons job
    title, it should be 10 characters in length and
    be initialize to MANAGER.
  • DATA JOB_TITLE (10) TYPE C VALUE MANAGER.

22
Example 2
  • Declare a variable to store the persons date of
    birth. Initialize the value to December 31, 1900.
  • DATA DATE_OF_BIRTH (8) TYPE D VALUE 19901231.

23
Your turn
  • Declare a variable that will store the employee
    income. It is comprised of 8 digits before the
    decimal point and 2 digits following it.
    Initialize the variable to 1 DOLLAR.

24
Answer
  • DATA EMP_INCOME (10) TYPE P DECIMALS 2 VALUE
    1.00.

25
Constants
  • Data that doesnt change its value during program
    execution.
  • Defines the same as DATA variables.
  • Example
  • CONSTANTS PLANT_NUM TYPE I VALUE 6523.

26
Run-time Parameters
  • Allows us to pass data to the ABAP/4 program at
    run time.
  • PARAMETERS parameter name TYPE type.
  • For all the options see page 16 in the book.

27
ABAP/4 Statements
  • ABAP/4 does not care where a statement begins on
    a line. - As a result, you should indent sections
    of code for readability.

28
ABAP/4 Statements
  • Multiple statements can be placed on a single
    line. To improve readability this is not
    recommended.
  • Blank lines can be placed anywhere in the program
    and should be used to improve readability.
  • ALL ABAP/4 statements (except comments) must end
    with a period (.).

29
Coding Statements
  • We will now discuss how to display data
    including
  • Moving data into a variable
  • Moving data between variables
  • Writing data to the report/screen
  • Coding our first complete ABAP/4 program

30
MOVE
  • Move data into or between variables is done using
    the move statement. There are two forms of the
    move statement.
  • MOVE value TO var
  • var value

31
Moving data into a variable
  • MOVE 10 TO PERSON_AGE.
  • OR
  • PERSON_AGE 10.

32
Moving data from one variable to another
  • Move the contents of PERSON_AGE to DISPLAY_AGE
  • MOVE PERSON_AGE TO DISPLAY_AGE
  • or
  • DISPLAY_AGE PERSON_AGE.

33
Computations
  • COMPUTE var expression.
  • ADD value TO var.
  • SUBTRACT value FROM var.
  • MULTIPLY value BY var.
  • DIVIDE value BY var.

34
Outputting text
  • To output data to the screen we use the write
    command.
  • WRITE text.
  • WRITE field name.

35
WRITE
  • WRITE Boyle.
  • WRITE LAST_NAME.
Write a Comment
User Comments (0)
About PowerShow.com