Thursday 16 May 2013

ABAP System Variables


ABAP System Variables


ABAP system variables is accessible from all ABAP programs. These fields are filled by the runtime environment. The values in these fields indicate the state of the system at any given point of time.
The complete list of ABAP system variables is found in the SYST table in SAP. Individual fields of the SYST structure can be accessed either using “SYST-” or “SY-”.
WRITE:/ 'ABAP System Variables'.
WRITE:/ 'Client : ', sy-mandt.
WRITE:/ 'User : ', sy-uname.
WRITE:/ 'Date : ', sy-datum.
WRITE:/ 'Time : ', sy-uzeit.
Output
ABAP-System-Variables

Thursday 9 May 2013

ABAP Variables


ABAP Variables



ABAP Variables are instances of data types. Variables are created during program execution and destroyed after program execution.
Use keyword DATA to declare a variable.
DATA: firstname(10) TYPE c,
      index         TYPE i,
      student_id(5) TYPE n.
While declaring a variable we can also refer to an existing variable instead of data type. For that use LIKE instead ofTYPE keyword while declaring a variable.
DATA: firstname(10) TYPE c,
      lastname(10)  LIKE firstname. " Observe LIKE keyword
Structured Variable
Similar to structured data type, structured variable can be declared using BEGIN OFand END OF keywords.
DATA: BEGIN OF student,
      id(5)     TYPE n,
      name(10)  TYPE c,
      dob       TYPE d,
      place(10) TYPE c,
      END OF student.
We can also declare a structured variable by referring to an existing structured data type.
TYPES: BEGIN OF address,
       name(10)   TYPE c,
       street(10) TYPE c,
       place(10)  TYPE c,
       pincode(6) type n,
       phone(10)  type n,
       END OF address. 

Data: house_address  type address,
      office_address like house_address.
Each individual field of the structured variable can be accessed using hyphen (-). For example, name field of the house_address structure can be accessed using housing_address-name.
Character is the default data type.
DATA: true.  " By default it will take C as data type

ABAP Data Types and Constants


ABAP Data Types and Constants


Data Type describes the technical characteristics of a Variable of that type. Data type is just the blue print of a variable.
Predefined ABAP Types
DATA TYPEDESCRIPTIONDEFAULT LENGTHDEFAULT VALUE
CCharacter1‘ ‘
NNumeric10
DDate800000000
TTime6000000
XHexa Decimal1X’0′
IInteger40
PPacked80
FFloat80
User defined data types
Use TYPES keyword to define the data types.
TYPES: name(10) TYPE c,
       length   TYPE p DECIMALS 2,
       counter  TYPE i,
       id(5)    TYPE n.
Structured data types
Structured data type is grouping of several simple data types under one name.
Use the keywords BEGIN OF and END OF to create a structured data type.
TYPES: BEGIN OF student,
        id(5)     TYPE n,
        name(10)  TYPE c,
        dob       TYPE d,
        place(10) TYPE c,
        END OF student.
Constants
Constants are used to store a value under a name. We must specify the value when we declare a constant and the value cannot be changed later in the program.
Use CONSTANTS keyword to declare a constant.
CONSTANTS: pi  TYPE p DECIMALS 2 VALUE '3.14',
           yes TYPE c VALUE 'X'.

Friday 3 May 2013

First abap program


Let us write a “Hello SAP ABAP” program.
Navigate to ABAP editor under Tools node in SAP easy access.
First-ABAP-Program-1
Double click on “ABAP Editor” to open the editor. ABAP editor can also be opened by entering t-code SE38 in the command field.
First-ABAP-Program-2
This is the ABAP editor’s initial screen. Enter the name of the program you want to create and press create. All the customer programs must begin with “Y” or “Z”.
First-ABAP-Program-3
In the next popup screen(Program attributes) enter the title for your program, select Executable program as type and press save.
First-ABAP-Program-4
Press Local Object to store the program in the temporary folder.
First-ABAP-Program-5
This is the screen where you can write the ABAP code.
First-ABAP-Program-6
Write the code. Press save, then syntax check( Ctrl + F2 ).
First-ABAP-Program-7
If there are any syntax errors, it ill be displayed at the bottom of the screen as shown above. Correct the errors and again check the syntax.
First-ABAP-Program-8
Successful syntax check message will be displayed in the status bar. Then activate( Ctrl + F3 ) the program.
First-ABAP-Program-9
In the following screen select your program and press continue. Then run(F8) the program.
First-ABAP-Program-10
The output will be displayed as shown above.

Wednesday 1 May 2013

SAP Transaction Code


What is SAP transaction code?


SAP Transaction code is a short cut key attached to a screen. Instead of using SAP easy access menu we can also navigate to a particular screen in SAP by entering the transaction code (T-code for short) in the command field of the standard toolbar.
What-is-SAP-Tcode
Some of the useful transaction codes for ABAP developers.
T CODEDESCRIPTION
SE11ABAP Data Dictionary
SE16Data Browser
SE37Function Builder
SE38ABAP Editor
SE41Menu Painter
SE51Screen Painter
SE71SAP Script Layout
SE80ABAP Workbench
SE91Message Maintenance
SE93Maintain Transaction