Archive for 2013

5 Basic Things in ABAP Programming

Basic things in ABAP with example
Arithmetic expressions in ABAP
In ABAP you can program the following valid arithmetic expressions,
·         +                     Addition
·         -                      Subtraction
·         *                     Multiplication
·         /                      Division
·         **                   Exponentiation
·         DIV                 Integral division without remainder
·         MOD             Remainder after integral division
Parameters
In our previous program we have written a set of commands for the arithmetic operations but the input to the variables where hardcoded in the program itself, now what if the user wants to enter the value during runtime?
What if he wants to enter different values each time?
So, we have to write a program which asks input from the user and gives the output.
To get input from user we should use the abap keyword ‘PARAMETERS’.
Ex:
PARAMETERS: input1 type I,
            input2 type I.
 The variable Result should not be defined in parameters because we are not going to get an input to the variable result. (Therefore result should be defined by ‘DATA’)
Data types in abap
Data types
A data type or simply type is a classification for identifying types of data, such as integer, numeric, character etc. that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored.
Here in abap we can classify them into two groups.
·         Complete ABAP standard types ( length will be fixed except string and xstring)
·         Incomplete ABAP standard types


Complete types:
·         D
Type for date (D), format YYYYMMDD, LENGTH 8
·         T
Type for time (T), format HHMMSS, LENGTH 6
·         I
Type for integer (I), LENGTH 4
·         F
Type for floating point number (F), LENGTH 8
·         String
Type for dynamic length character string
·         Xstring
Type for dynamic length byte sequence (HeXadecimal string)
Incomplete types:
·         C
Type for character string, length should be specified.
·         N
Type for numerical character, length should be specified.
·         X
Type for byte sequence, length should be specified.
·         P
Type for packed number, length should be specified as well as decimal points should be specified.

So with these data types the user can define a variable in the program, (as how we used Integer in our program)
Conditional branches and logical expressions
In ABAP you have two ways to execute different sequences of statements.
·         IF
·         CASE



                                IF-statement
CASE-statement
IF input1 > 0
  Statements
ELSEIF input1 < 0
  Statements
ELSEIF input1 = 0
  Statements
ENDIF.

CASE input1.
When ‘0’.
Statements
When ‘100’
Statements
When ‘200’
Statements
ENDCASE.

 As we know about the IF-statement and CASE-statement lets update our previous program (arithmetic calculation) using these conditional statements.


As you can see the keyword ‘PARAMETERS’ is used for getting input from user, we are getting three inputs from the user.
1.       Operand1 (input1)
2.       Operand2 (input2)
3.       The operators ( ‘+’ ‘-’ ‘*’ ‘/’)
And the output is stored in the variable ‘RESULT’ which is defined by the ‘DATA’ keyword.
Next comes the conditional operator,
IF-statement:
 It checks whether the value in variable ‘SYMBOL’ is one of the symbols described there.
If the symbol is any of these ‘+, - , *, /’ it comes to the next statement (i.e. CASE-statement) or else it executes the ‘ELSE’ part.
CASE-statement:
Depending upon the symbol the case statement is executed i.e. when the symbol is ‘+’ it executes the addition and when the symbol contains the value ‘-‘ the operation subtraction is performed.
Whenever an operation is performed the result is stored in the variable ‘RESULT’, and at the end of the CASE-statement we are printing the result in the screen.
Now, come back to the IF-statement (line 16).
If the symbol contains value which is not defined there, it comes to the ELSE part.
The ELSE part contains the code for writing an error ‘symbol is not defined in the program’.
In line 16 the Relational operator OR is described after every condition.
See how the compiler reads the program.
Line16 -> Checks whether the value in symbol is ‘+’ OR‘-‘ OR‘*’  OR ‘/’ .
(If the value in symbol is any of the following above Line18 is executed or else Line 30 is executed)
Do you know :
·         Always give preference in using CASE-statements than IF-statements because it’s more transparent and performs better.
·         Always provide space between parentheses and operators since they are ABAP keywords

Wednesday, June 12, 2013
Posted by Unknown

Sample ABAP Program


Getting Hands Dirty : ABAP-EDITOR

I would like to remind a few things, 
SAP is a Three (3) tier architecture. 
  • The one we would be interacting is ‘PRESENTATION LAYER’; 
  • Your server is the ‘APPLICATION LAYER’ and finally 
  • The ‘DATABASE’. 
All your programs will be executed in the application layer, presentation layer is just to a GUI.
And in SAP-ABAP, SQL commands can be used; we can have NATIVE SQL or OPEN SQL. But will go with OPEN SQL.
------------------------------------------------------------------------------------------------------------

The one you are seeing above is the screen when you log-in to SAP from your desktop or PC  
<the screen above is the presentation layer>

On top of the window are the menus, below the menu there is a text box with a green tick, here is where we should enter the ‘TRANSACTION CODE’.
Here are some are some commonly used transaction code.

TRANSACTION CODE
DESCRIPTION
SE80
OBJECT NAVIGATOR
SE38
ABAP EDITOR
SE37
ABAP FUNCTION MODULES
SE24
CLASS BUILDER
SE11
ABAP DICTIONARY
SE51
SCREEN PAINTER
SMARTFORMS
SAP SMART FORMS

So, first let’s have a sample report program.
Go to Transaction -> SE80 -> REPOSITRY BROWSER -> <in the drop down choose> PROGRAM -> <below the drop down enter the program name> ZSAMPLE and press ENTER.
screen 1.1

A popup will appear as above conforming to create a program, click YES.


Un Check the TOP INCL <if you check it will include a ‘TOP INCLUDE in your program>
and 'enter'.

                                                                           screen 1.2

Choose Status as ‘TEST PROGRAM’ and click SAVE.


                                                   screen 1.3

It will ask for package, for now save it as local object.
Finally your program editor will be opened.

Now, we are going to write a program to do all the arithmetic operations.
I have given all the definitions on the program itself as comments. Comments can be given by following ‘*’ or  ' “ ' symbol.

The first part is to define variables;
We are having three variables in our program, input1, input2 and result.
All of the variables are integer format.
To define a variable in SAP you have to write a keyword “DATA”.
If you have multiple variables to be defined use the keyword “DATA” followed by “:“ and at the end of the type use ‘,’ (comma) instead of ‘.’ (Full stop) and when final variable is declared use “.”.
And now the arithmetic operations take place, the result is stored in the variable result.To display the result,we should use a keyword “WRITE” similar to cout and printf in c and c++..CLEAR keyword clears the memory of the variable next to it, so after that the variable will not be holding any values.


Remember,

  • The program we created is a 'REPORT' program ( That is the reason we choose 'EXECUTABLE PROGRAM' for type in screen screen 1.2)
  • ABAP is not case sensitive.
  • And at the same time after every statement don’t forget to add full stop for line termination.

Saturday, June 1, 2013
Posted by Unknown

SAP ABAP - A Brief Introduction to Reports and Module Pool Programming


Getting Started: SAP-ABAP
Just a few steps ahead before we get our hands dirty. It’s necessary to know the concept and other technical related things in ABAP.
ABAP stands for Advanced Business Application Programming.
It’s a programming language similar to COBAL and the programs we do will not be stored as a separate external file like JAVA/C++ programs. All ABAP programs reside inside the SAP database.
As in other programming languages, an ABAP program is either an executable unit or a library, which provides reusable code to other programs and is not independently executable.
ABAP distinguishes two types of executable programs:
·         Reports ( Can be executed directly )
·         Module pools ( They can be executed only via a ‘TRANSACTION CODE’ )
  
REPORTS:
Reports follow a relatively simple programming model whereby a user optionally enters a set of parameters and the program then uses the input parameters to produce a report in the form of an interactive list. Reports are used to display data from the SAP database. Mostly they use the SAP standard screen ‘1000’.

Example:
You have created a report program which gives the employee id of all the employees in your company filtered by some parameter (take department code as parameter).so when you execute the program it will ask for department code and gives the result.
Here is the example of the output, how it would look like.


MODULE POOL:
Module pools are used to get data from the user and store   in   the SAP database as well as to display them from the database. They contain user defined screens designed using screen painter. (Remember whenever we create screens in module pool program we have to name them in numbers, and so we should not name our screens as ‘1000’ because its SAP’s standard screen is 1000, which it uses in report programming and selection screens. Each screen has its own flow logic, which is divided into a "PBO" (Process before Output) and "PAI" (Process after Input) section. The term “dynpro” (dynamic program) refers to the combination of the screen and its flow logic.
After all your programming you can’t directly execute a module pool program, you have to create a ‘TRANSACTION CODE’.
What is a transaction code?
Transaction code is a short cut key attached to a screen. It should have only numbers and characters (ztcode or zt42).for example if you create a transaction code for your program, and enter the transaction code the program will be executed and the corresponding screen will be called.
To make it clear and easier lets have an example,
Example:
 <don’t worry about the programming logic, just try to understand this example, we shall see the programming logic later>
You have created a program that first requires a validation (i.e. you have to enter your user_name and password) and then you will be redirected to your screen where you will have all the details of you salary, expense and all.
(to make get the point)
So, here we have to create two screens,
Assume Screen no. 2000 for validating the user_name and password.
Screen no. 2001 for details of salary, expense.
Now create a transaction code, eg; zuser01
Now, when you enter the transaction code this the magic that happens, J
















So, from this you will have clear that PBO Executes before the screen and PAI loads after receiving an input from the user.
So we will have a command like this in PAI.
**********************************************
PAI of screen 2000.
When ‘SUBMIT’ <when submit button is clicked>
Call screen 2001. <the next screen is called>
**********************************************
The next PBO of screen 2001 loads and the screen will be displayed
<remember this is just for you to understand module pool program and the events (PAI & PBO) in them, and programming concepts will be explained later>

OK, now come back to the point so far we have seen executable programs in SAP ABAP. Now we shall have a little explanation for non-executable programs.
Include modules:  An INCLUDE module gets included at generation time into the calling unit; it is often used to subdivide very large programs.
Example:
INCLUDE zemployee.
<here zemployee is the include, when the compiler comes here, it executes all the commands inside zemployee>

Subroutine pools: Subroutine pools contain blocks of code enclosed by FORM /ENDFORM statements and invoked with PERFORM.





Example:

PERFORM zemployee.
When the compiler comes into the above line, the commands or programs inside the subroutine zemployee will be executed <i.e. the commands within FORM and ENDFORM of the subroutine name, here ‘zemployee’>
FORM zemployee
ENDFORM



Function groups:  Function groups are libraries of self-contained function modules   enclosed by FUNCTION / END FUNCTION and invoked with CALL FUNCTION.

Object classes and Interfaces: Object classes and interfaces are similar to Java classes and interfaces; the first define   a set of methods and attributes, the second contain "empty" method definitions, for which any class implementing the interface must provide explicit code.
 
Type pools: Type pools define collections of data types and constants. 

<for the last three, giving examples will make you confuse, when we get our hands dirty we shall have a clear look on those types>

Introduction to SAP


The big picture: SAP AG

Before reading this i personally recommend to read my previous blog  Introduction to ERP


Introduction to SAP – The Company:
SAP AG simply means SAP Inc.
SAP AG is a German multinational software corporation, founded in 1972 by 5 IBM employees (wellenreuther, Hopp, Hector, plattner and Tschira). SAP makes enterprise software to manage business operations and customer relations. SAP is headquartered in Germany and regional offices all around the world.
The first releases, called R1 and R2, were mainframe-only applications. SAP started with a set of financial applications and then added logistics, manufacturing, and HR. In the 1980s, they moved to a true 3-tiered client-server solution and by the early 1990s, R/3 was released to the market.
<We shall see about ‘R/3’ later in SAP-software>
SAP system comprises a variety of modules which fulfils all business needs.
(Sources: Wikipedia  lol)

Introduction to SAP – The Software:
mySAP is not a single product but is a suite of products from SAP including SAP R/3.
Other products in the mySAP product suite includes,
  • SRM (Supplier Relationship Management),
  • CRM (Customer Relationship Management),
  • PLM (Product Lifecycle Management),
  • SCM (Supply Chain Management)
SAP R/3 was officially launched on 6 July 1992. It was renamed SAP ERP and later again renamed ECC (ERP Central Component).
In 2000, SAP renamed their solution mySAP and released the latest version of SAP, ‘ECC’ and the most recent release is ECC 6.0. (ERP Central Computing)
<Heard rumours about ECC 7.0 don’t know whether its true>
SAP ECC 6.0 includes many modules such as HR, Finance, MM covering all enterprise Functions.
SAP's current release strategy is to provide Enhancement Packs with additional functionality instead of releasing new versions of the software.
SAP's Enhancement Pack strategy eliminates major upgrades and allows customers to choose which enhancements to apply to their systems.

SAP NET VIEWER:

SAP first announced NetWeaver in 2003. It’s an open integration and application platform for all SAP applications.
As explained in “The History of SAP” on SAP.com, NetWeaver was an integration platform intended to enable customers to create “applications that support
end-to-end business processes no matter whether they are based on systems from SAP or other providers.”

We can consider SAP NetWeaver as a breadboard,
SAP NetWeaver provides you an application and integration platform, using which you can develop your own application on top of sap NetWeaver use sap NetWeaver for integrating or other non-sap systems
netweaver.jpg

SAP NetWeaver Application Server

The SAP NetWeaver Application Server is the central foundation for the entire SAP software stack. It also provides a platform for other NetWeaver components.There are different installation options for SAP NetWeaver AS they are,
  • SAP NetWeaver AS ABAP
  • SAP NetWeaver As Java
  • SAP NetWeaver As ABAP + Java

Concept of 3 Tier Architecture.

Before we discuss about 3 tier architecture, we first need to understand CLIENT and SERVER.

In Hardware: Server means Central server in a network that provides data,memory and resources for the workstations (clients)
In software: Client request’s a service and server provides the service.

3 tier architecture defines Three layers,
          a. Presentation layer (SAP GUI, it provides user interface for entering and displaying data)
          b. Application layer (Provides interface between presentation layer and database layer)
          c. Database layer (A centralized data base that comprises all the data in the SAP system)
3 tier.jpg

Whenever a user submits a request from the presentation layer, the request is processed in application layer by the dispatcher.
And when accessing Database,the application layer process the request and communicates to the data base.
(In ABAP, SQL query can be written in Open SQL to access the application data in the database,The database interface translates open SQL into Corresponding SQL statements for the specific database i.e Native SQL which makes ABAP programs to be Database-independent)

SAP supports a wide range of database,
ADABAS D
DB2/400
DB2/Common Server
DB2/MVS
INFORMIX
ORACLE
MICROSOFT SQL SERVER

 
(Dispatcher distributes incoming requests to the process).
Ok, now where does the distributed request from dispatcher go to process?

There are number work processes which are responsible to process the request in the application layer,
  • D – Dialog work process
Responsible for the execution of dialog steps triggered by an active user.

  • U – Update work process
Executes update request

  • E – En queue (lock)
Administrates the lock table in the shared memory.

  • B - Background work process
Executes program that run without interacting with the user.

  • S – Spool work process (print)
Pass sequential data flow to printer.

Apart from work process there are additional services for internal and external communications,
  • Message Server (MS)
Handles communication between the distributed dispatcher in the Application server.

  • Gateway reader (GW)
Responsible for communication between SAP systems or between SAP systems and external application systems.

  • Internet Communication manager (ICM)
Enables communication with SAP system using web protocol such as HTTP.
A standard SAP project system is divided into three environments, Development, Quality and Production.

The development system is where most of the implementation work takes place.

The quality system is where all the final testing is conducted before moving the transports to the production environment.

The production system is where all the daily business activities occur.  It is also the client that all the end users use to perform their daily job functions.

To all company, the production system should only contain transports that have passed all the tests.

Introduction to SAP – Modules:

Here are some of the modules used in SAP (please note all modules are not mentioned here).
SAP Modules list is classified into 3 types

1) SAP Functional Modules :
People who study Functional modules are SAP Functional Consultant – They are responsible for customizing SAP as per customer demand. They talk with developers to code custom ABAP programs as per client requirements.
2) SAP Technical Modules and
They are responsible for coding ABAP/Java Programs
3) SAP New Dimensional Modules also known as SAP New Modules.
      They are a combination of the Functional and Technical modules.


Functional module.
  1. 1. SAP FI module         : FI stands for Financial Accounting.
  2. 2. SAP CO module       : CO stands for Controlling.
  3. 3. SAP CRM module    : CRM stands for Customer Relationship Management.
  4. 4. SAP HR module       : HR stands for Human Resources.
  5. 5. SAP MM module     : MM stands for Materials Management
Technical Module
  1. 1. SAP ABAP module : ABAP stands for Advanced Business Application Programming.
  2. 2. SAP Basis module    : Basis also known as Basis Admin is typically the administration
  3. 3. SAP BI module         : BI stands for Business Intelligence.

Do you know?
  1. SAP is implemented in 9 out of every 10 fortune 500 company.
  2. SAP consultants enjoy a premium remuneration over their IT counterparts working in other technologies like Java, .net etc.
  3. SAP R/3 means SYSTEM APPLICATION and PRODUCTS IN DATA PROCESSING ‘R’ stands for REAL TIME data processing and 3 stands for Three-tier architecture.
  4.  SAP should be pronounced as ‘Ess-ayy-pe’ not as SAP.
  5.  NetWeaver otherwise called as integration platform.
  6.  Every dispatcher requires atleaset,
  • 2 dialog work process,
  • 2 background work process,
  • 1 update work process,
  • 1 spool work process,
  • And only one Enqueue process is needed for each system
Next we shall have the introduction to ABAP
Tuesday, May 28, 2013
Posted by Unknown
  • About Me

  • My Picture
  • I Live in Chennai,INDIA.I work there.Am much passionate towards SAP.
  • Popular Post

    Followers

    - Copyright © 2013 SAP ABAP Tutor - Powered by Blogger - Designed by Askar Imran-