Showing posts with label sample programs. Show all posts

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
  • 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-