Wednesday 18 March 2015

                                                     ABAP/4


ABAP/4: 4th generation language.
ABAP stands for Advanced Business Application Programming Development.
Features of ABAP:
Designed based on c language.
Platform independent language.
Case incentive language.
It is friendly business oriented language.
ABAP is rich in datatypes.
Event driver programming language.
It is database independent.
Designed based on object oriented programming.
Highly user friendly language.
Supports web based applications also.

ABAP Workbench: It is a set of tools which contains an environment for developing the objects.

SE means system engineering.
The various tools are:
•       ABAP Editor(SE38)
•       Data Dictionary
•       Menu Painter
•       Screen Painter
•       Function Builder
•       Debugger
•       Object Navigator




Note: All work bench tools are highly integrated with each others.

Shortcut keys:
Cntrl+F2 - Check
Cntrl+F3 - Activate
Cntrl+S - Save
F5 – Create
F6 - Change
F8 – Display.


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.


Data types:
Data types are references to the data object.

TYPES: BEGIN OF student,
                id(5)     TYPE n,
                name(10)  TYPE c,
                dob       TYPE d,
                place(10) TYPE c,
        END OF student.




Character data type:
C: Character
N: Numeric
D: Date
T: Time
Numeric data type:
I: Integer
P: Packed
F: Float

X: Hexadecimal




Predefined data types:
Which is already there in ABAP programing.
Elementary data types:
It allows only one single data type.
User defined data types:
We can create our own data type for reusability.
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.



Data objects:

The object which holds the data type is called as data object. The object occupies the memory space in the program.
E.G.
Data var1(10) type c.
Write var1.
Data var1(10) type c.
Var1 = 9000.
Data var1(10) type c.
Move ‘444’ to var1.
Data var1(10) type c.
Write ‘u3000’ to var1.

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'.

Activation Objects:
All your development work when we save first time its store in temporary memory in application layer. When we activate this to store permanent memory.

Pretty printer:
After compilation program click on pretty printer it will automatically adjust the program.

Adding color:
To print background color dark:
Color 7.
To print background color light:
Color 7 intensified off.
To print only letters in color:
Color 7 inverse.

Two comments:
1. Line level comments   (*)
1. Inline level comments (“).

Set boarder line of program of output screen:
Line-size 100.

To remove title of program from print area:
No standard page heading.

Test symbols:
1. Text translation.
2. Reusability.
3. Alinements.
Go to-> Test elements-> Test symbols.
Dlen: define length.
Mlen: maximum length.






In the text symbols screen we can maintain the messages with a 3 character identifier.
Then use the following message statement.
MESSAGE text-001 TYPE 'I'.

System structure [syst]:
It is the temporary memory created by system itself. Total171 system fields.

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.
Positions:
Left: color 5.
Right: color 5 right-justified.
Center: color 5 centered.

Selection screen:
An input screen to program is called selection screen.
Selection screen text:
Goto->text elements->selection text->create text->save it.

PARAMETERS: p_matnr TYPE matnr.


Output:






Selection screen heading & frame:
Selection-screen begin of block b1 with frame title text -1ao.
Selection screen end of block b1.

Check box in selection screen:
Parameters: chk1 as checkbox.

Input field mandatory:
Parameter: var1 type I obligatory.
Default values:
Parameter: var1 type I default 100.

How to change program package:
Give a program name.
Go to object directory entry.

Click change, Give package & save it.

Radio button:
RAD1 radio button group gp1.
RAD2 radio button group gp1.
Note: we can’t declare single radio button.

Set radio button in position with comment:
Selection-screen begin of line.
Selection-screen position 1.
Parameters: RAD1 radio button group gp1.
Selection-screen, comment 3(15) text-1ao.
Selection-screen end of line.

Looping statements:
Do, While.
Difference between exit & stop:
Exit will come out from the loop.
Stop is terminate the program.

Difference between while & do:
In case of while the process check the condition first & enter in to the loop.
In case of do process enter in to the loop & check the condition. Only do can uses for the infinite, not while.

Types of internal tables:
1. Index tables.
A. sorted tables: Index field table. It will not allow duplicate records.
B .standard tables: Index field table.
2. Hashed tables.
One field must be key field. We can’t use append, collect statement for hashed.

Difference between internal tables & index tables:
Data base tables are stored in DB server.
Internal tables are virtual tables these are created run time only.
 Size of Internal tables:
Internal tables have 2 giga bytes of memory space. The initial size of 8kb which can be extended further.
Difference between field group & symbol:
Field group holds [work area] single value.
Internal table holds multiple values.
How to eliminate duplicate records:
Delete adjacent duplicates.
Occurs: To allocate memory for internal tables.
Clear itab[ ]: Clear the data not a memory.
Refresh itab[  ]: Refresh the body & also the data.
Free itab[ ]: Delete memory after using the program.
Collect: Used to summarize the records.
Append: Copy the data from body to header.
Tables: Tables create the work area.

How to print 3rd record from the internal itab:
Read table itab index 3.
                Or
Loop at itab.
If sy-tabix = 3.
Write itab.
Endif.
Endloop.
How to print records from N1 to N2 from itab:
Loop at itab from N1 to N2.
Write itab.
Endloop.
How to transfer the data from itab1 to itab2 whose structure is same:
Itab2 = itab1.
   Or
Append lines of itab1 to itab2.
From INDEX1 to INDEX2.

How to find out number of records in internal table:


Syntax: Data: g_line type i.
Describe tables s+1 lines g_lines.
Write: g_line.

Can we sort the sorted internal table?
No.
How to find the behind screen program?
Go to-->System-->Status
STRING OPERATIONS:
To adding multiple strings:
Concatenate var1 var2 var3 var4 into var4.
If we want space:
Concatenate var1 var2 var3 into var4.
Separated by space.
To split a strings:
Split var4 at, into var1, var2, var3.
Replace string:
Replace ‘TEST’ in var4 with ‘123’.
To replace more than one:
Replace all occurrence of ‘,’ in var4 with ‘@’.
To translate capital letters:
TRANSLATE var4 to upper case.
To translate character:
TRANSLATE var4 using ‘AXNYPZ’.
To shift the string:
Shift var1 by 2 places.
Shift var1 right by 2 places.
Shift var1 circular by 2 places.
To remove gaps in front of string: 
Condense var5.
To remove gaps in front & after the string:
No-gaps.
To print in a particular position is called offset:
Var1 = var4 + 10(5).
To find how many characters in string:
Var6 = strlen(var4).

STRING COMPARATOR:
To contents any:
If p_var1 ca ‘123’.
Write: / ‘ca successes’.
Endif.
To contents only:
It’s accept in order which we given in heart coded.
If p_var1 co ‘123XYZ’.
Write: / ‘CO success…’
Endif.

To contents string [but it accepts only what exactly given in total coded]:
If p_var1 cs ‘abc’.
Write: / ‘cs success’.
Endif.
To contents patterns: [there should be one character in front given abc, * represent more than one character after given abc].
If p_var1 cp3 + abc *
Write: / ‘cp success….’

CONTROL BREAK STATEMENTS:
At first
Endat.

At new
Endat.

At end of
Endat.

At last
Endat.

Note: Before applying the control break statements in internal table processing we need to sort out the data in the internal table.
Tips: control break statements are work only in loop condition.


SAP memory is global and can be used to pass data across main sessions whileABAP memory is local and is uses to pass data across internal sessions. GET PARAMETER and SET PARAMETER are used to write and read to SAP memorywhile IMPORT FROM MEMORY and EXPORT TO MEMORY are used for ABAP memory.


No comments:

Post a Comment