Tuesday, December 30, 2008

ABAP List Viewer

ABAP List Viewer(ALV)

-> The ALV Grid Control (ALV = SAP List Viewer) is a flexible tool for displaying lists. The tool provides common list operations as generic functions and can be enhanced by self-defined options. This allows you to use the ALV Grid Control in a large range of application programs.
-> SAP provides a set of ALV function modules which can be used to embellish the output of the report.
-> Enhances the readability and functionality of report output.
-> Displays columns extending more than 255 characters in length.
-> Efficient tool for dynamically sorting and arranging the columns from a report.
-> Output can contain upto 90 columns in display with wide array of display options


Features
-> Display non-hierarchial lists with modern design
-> Use typical list functions like sorting,filtering dynamically with any programming efforts
-> Program responses to user actions like double-clicking.

As a minimum you need to provide the following details to display data:

1) An Internal table with the data to be displayed.

2) A description of the structure of this data that is declared to ALV Grid Control which is called the fieldcatalog

Generally,Internal Table consists of the data that is previously selected from the Database Tables

Steps to be followed
Step 1:Data Declaration
Declare Internal tables to be used for displaying data.
TYPE-POOLS:SLIS.
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "FIELDCATALOG
GT_EVENTS TYPE SLIS_T_EVENT, "EVENTS

Step 2: Data Retrieval
Retrive the data to be displayed from the various database tables and store it in a n internal table

Step 3: Build Fieldcatalog
The field catalog is a table that contains information on the fields to be displayed.
For example, the ALV uses this table to identify the type of a field.
You can also use special fields of this catalog to determine the number format and column properties of the list to be output.
Eg: row_pos,col_pos,fieldname,table_name,
output_len,key,do_sum,no_sign etc.

Step 4: Build layout/events table
Next step is to build the layout,events and sort table.
Layout table will contain different layout structure like the col width,totals etc.
Events table is used to handle different events like TOP of Page,End of page etc
Sort table will define the sorting sequence.


Step 5:Display ALV List

Use the function module
'REUSE_ALV_GRID_DISPLAY‘ to display the grid.
For list display use
'REUSE_ALV_LIST_DISPLAY







Wednesday, December 24, 2008

Operations on Internal Tables

Operations on Internal Tables

Various operations can be performed on an Internal Table.
Filling Internal Table
->For filling an IT , use the keyword ‘APPEND’
->It appends the contents of the work area at the end of the Internal Table.
Eg: APPEND wa TO itab.

Modifying lines of IT
->To modify individual lines of an IT,use “MODIFY” stmt inside the loop.
->However you must make the required changes in the work area and then assign its contents to the IT.
->MODIFY FROM.

Deleting single table lines
->You can delete single table lines using ‘DELETE’ stmt within the loop.
->DELETE stmt deletes the current line of IT.
->DELETE.

Sorting
->To sort IT will use SORT keyword.
->You can also specify the sorting sequence with SORT and type (ascending/descending).
->SORT BY fieldname.
Ex. SORT BY EID.


LOOP AT stmt..

->IT are processed in loops.in loops all elements of the IT are read starting from the first line.
SYNTAX :LOOP AT itab.
ENDLOOP
For work area,
LOOP AT itab into wa.
ENDLOOP.

Outputting Table contents

->To display the table contents use ‘WRITE’ stmt inside the LOOP AT loop.
Ex: Write:/itab-field1,itab-field2.

Processing control levels

->It allows you to create statement blocks within a LOOP-ENDLOOP loop that are processed only for certain table lines.
->Start with AT and end with ENDAT.
AT.
ENDAT.

->FIRST-first line of IT
->LAST-last line of IT
->NEW-beginning of a group of lines with same contents in the superior fields.
->END OF-end of a group of lines with same contents in the superior fields.



Interactive Report Program Demo

Program for Interavtive Report

The above code is used to accept Customer No and display Customer Details in the Primary List and Sales Order Details and Item Details in the Secondary List.

************************************************************************************
REPORT ZINTERACTIVE_REPORT LINE-SIZE 103 LINE-COUNT 35(5) NO STANDARDPAGEHEADING.
*TABLES DECLARATION
TABLES : KNA1, VBAK, VBAP.
*SELECT OPTIONS
SELECT-OPTIONS: CUST_NO FOR KNA1-KUNNR.
*INITIALIZATION
INITIALIZATION.
CUST_NO-LOW = '01'.CUST_NO-HIGH = '5000'.CUST_NO-SIGN = 'I'.CUST_NO-OPTION = 'BT'.APPEND CUST_NO.
*BASIC LIST SELECTION
START-OF-SELECTION.
SELECT KUNNR NAME1 ORT01 LAND1

INTO (KNA1-KUNNR, KNA1-NAME1,KNA1-ORT01,KNA1-LAND1)
FROM KNA1 WHERE KUNNR IN CUST_NO.
WRITE:/1 SY-VLINE, KNA1-KUNNR UNDER 'CUSTOMER NO.' HOTSPOT ON, 16 SY-VLINE, KNA1-NAME1 UNDER 'NAME', 61 SY-VLINE, KNA1-ORT01 UNDER 'CITY', 86 SY-VLINE, KNA1-LAND1 UNDER 'COUNTRY', 103 SY-VLINE.
HIDE: KNA1-KUNNR.
ENDSELECT.
ULINE.
*SECONDARY LIST ACCESS
AT LINE-SELECTION.
IF SY-LSIND = 1.

PERFORM SALES_ORD.
ENDIF.
IF SY-LSIND = 2.
PERFORM ITEM_DET.
ENDIF.
*TOP OF PAGE
TOP-OF-PAGE.
FORMAT COLOR 1.
WRITE : 'CUSTOMER DETAILS'.
FORMAT COLOR 1 OFF.
ULINE.
FORMAT COLOR 3.
WRITE : 1 SY-VLINE, 3 'CUSTOMER NO.', 16 SY-VLINE, 18 'NAME', 61 SY-VLINE, 63 'CITY',

86 SY-VLINE,
88 'COUNTRY', 103 SY-VLINE.
ULINE.
FORMAT COLOR 3 OFF.
*TOP OF PAGE FOR SECONDARY LISTS
TOP-OF-PAGE DURING LINE-SELECTION.
*TOP OF PAGE FOR 1ST SECONDARY LIST
IF SY-LSIND = 1.
ULINE.
FORMAT COLOR 1.
WRITE : 'SALES ORDER DETAILS'.

ULINE.

WRITE : 1 SY-VLINE, 3 'CUSTOMER NO.', 16 SY-VLINE, 18 'SALES ORDER NO.', 40 SY-VLINE, 42 'DATE',

60 SY-VLINE, 62 'CREATOR', 85 SY-VLINE, 87 'DOC DATE', 103 SY-VLINE. ULINE.
ENDIF.
*TOP OF PAGE FOR 2ND SECONDARY LIST
IF SY-LSIND = 2.
ULINE.

WRITE : 'ITEM DETAILS'.
ULINE.
WRITE : 1 SY-VLINE, 3 'SALES ORDER NO.', 40 SY-VLINE, 42 'SALES ITEM NO.', 60 SY-VLINE,

62 'ORDER QUANTITY', 103 SY-VLINE. ULINE.
ENDIF.
*END OF PAGE
END-OF-PAGE.
ULINE.WRITE :'USER :',SY-UNAME,/,'DATE :', SY-DATUM, 85 'END OF PAGE:',SY-PAGNO. SKIP.
*Form SALES_ORD
FORM SALES_ORD .
SELECT KUNNR VBELN ERDAT ERNAM AUDAT

INTO (VBAK-KUNNR, VBAK-VBELN, VBAK-ERDAT, VBAK-ERNAM, VBAK-AUDAT)
FROM VBAK WHERE KUNNR = KNA1-KUNNR.
WRITE:/1 SY-VLINE, VBAK-KUNNR UNDER 'CUSTOMER NO.' HOTSPOT ON, 16 SY-VLINE, VBAK-VBELN

UNDER 'SALES ORDER NO.' HOTSPOT ON, 40 SY-VLINE, VBAK-ERDAT UNDER 'DATE', 60 SY-VLINE,
VBAK-ERNAM UNDER 'CREATOR', 85 SY-VLINE, VBAK-AUDAT UNDER 'DOC DATE', 103 SY-VLINE.
HIDE : VBAK-VBELN.ENDSELECT.
ULINE.
ENDFORM. " SALES_ORD
*Form ITEM_DET
FORM ITEM_DET .
SELECT VBELN POSNR KWMENG INTO (VBAP-VBELN, VBAP-POSNR, VBAP-KWMENG)

FROM VBAP WHERE VBELN = VBAK-VBELN.
WRITE : /1 SY-VLINE, VBAP-VBELN UNDER 'SALES ORDER NO.', 40 SY-VLINE, VBAP-POSNR UNDER

'SALES ITEM NO.', 60 SY-VLINE, VBAP-KWMENG UNDER 'ORDER QUANTITY', 103 SY-VLINE.
ENDSELECT.
ULINE.

ENDFORM.
****************************************************************************************************************************************
Selection Screen
Accept Customer No range


Primary List:
Customer Details

Secondary List :Item Details






Monday, December 22, 2008

Internal Tables

Internal Tables

-> Tables are the most important data structures in R/3 system.
-> Data with long life are stored in RDBMS.
-> Apart from database tables you can create internal tables that exist only at runtime of the program.
-> ABAP/4 offers several operations for working with internal tables.
-> For e.g. it allows to search for lines or append, insert or delete lines.
-> The no. of lines of an internal table is not fixed. If required, the system expands internal tables at runtime.
-> That means if you want to read a database table into an internal table, you must not know its size in advance. -> This makes it easier to use.

Use of Internal Tables

-> Perform Table calculations
-> Re-organize table contents
-> Create a list

Working with Internal Tables
-> Declare an Internal Table
-> Fill an Internal Table
-> Change/output/delete individual elements
-> Sort tables by any field
-> Understand and use control levels

Declare an Internal Table
Before you can use them you need to declare the structure of an IT.
Eg: DATA:BEGIN of itab occurs 10,
Carrid like spfli-carrid,
Connid like spfli-connid,
END of itab.


Or define a structure
Eg: TYPES:BEGIN of structure,
Carrid like spfli-carrid,
Connid like spfli-connid,
END of structure.
DATA: itab TYPE structure occurs 10.

OCCURS defines an internal table and no defines no of lines the table has after initialization.However, the size is variable ie size can change as per requirements

Work Area
To change or output the contents of an IT, you need a work area.

Types of Internal Tables

The various table types have the following hierarchy:
STANDARD TABLE
->Defines the table as a standard table.
-> Key access to a standard table uses a linear search. This means that the time required for a search is in linear relation to the number of table entries.
-> You should use index operations to access standard tables.
-> For the sake of compatibility, you can use TABLE as a synonym of STANDARD TABLE

SORTED TABLE
-> Defines the table as one that is always saved correctly sorted.
-> Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.
-> You can also access sorted tables by index operations.
-> When you insert using an index, the system checks to ensure that the sort sequence has been correctly maintained.
For this reason, it takes longer than inserting entries in a standard table. -> As a rule, you should only access sorted tables using their key.

HASHED TABLE
-> Defines the table as one that is managed with an internal hash procedure.
-> You can imagine a hashed table as a set, whose elements you can address using their unique key. Unlike standard and sorted tables, you cannot access hash tables using an index.
-> All entries in the table must have a unique key. Access time using the key is constant, regardless of the number of table entries.
-> You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on).
-> Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.

INDEX TABLE
-> Standard and sorted tables belong to the generic class index tables.
-> An index table is one that you can access using an index. You can currently only use the table type INDEX TABLE to specify the type of generic parameters in a FORM or a FUNCTION.
-> Hashed tables are not index tables, and cannot therefore be passed to parameters defined as INDEX TABLE.

Sunday, December 21, 2008

Interactive Reports

Interactive Reports

-> In these type of report user can actively control data retrieval and display during the session.
-> Detailed information appears in secondary lists.
-> Allows user to interact so that a new list is populated based on user selection.
-> Secondary list may either overlay the Basic list completely or you can display them in an extra window or screen.
-> These lists can themselves be interactive again

-> System field that gets affected is: Sy-lsind
-> It contains the list no.
-> The secondary list can go up to 20 levels.

An interactive report generally works in the following fashion:
1. Basic list is displayed.

2. User double clicks on any valid line or User selects a line and presses as button on the tool bar.

3. The corresponding event is triggered

4. Then in the code, the line on which action was done, is read.

5. Depending on the values in that selected line, a secondary list is displayed.

6. Steps from 2-5 are repeated till the end.
The 20th list, will essentially depend on the "selected line" of 19th list.

EVENTS

TOP-OF-PAGE DURING LINE-SELECTION : Displays the Header data for the lists.

AT LINE-SELECTION : When a particular line is clicked ,this event is triggered.

Thursday, December 18, 2008

Classical Reports

Classical Reports

  • Simplest form of reports.
  • Display data from the database on the basis of selection criteria.
  • Level of reporting is only ONE.
  • We will use the “SELECT” statement to retreive data from the tables
The below program displays Material details from MARA(Material Master)
Step1 Write the below code in the ABAP Editor (SE38)


Step2: After Activating and Executing the above program the below Selection Screen is displayed.

Step 3: Output List.
Classical Report giving details of Material Master are displayed.

Retrieving data from more than one table

In order to retrieve data from multiple table we have to use ‘JOINS’
SELECT * FROM tabref1 [INNER] JOIN tabref2 ON cond
In a relational data structure, it is quite normal for data that belongs together to be split up across several tables to help the process of standardization. To regroup this information into a database query, you can link tables using the join command. This formulates conditions for the columns in the tables involved. The inner join contains all combinations of lines from the database table determined by tabref1 with lines from the table determined by tabref2, whose values together meet the logical condition (join condition) specified using ON>cond.

Reports

REPORTS

Report allow the user to display the entries from the tables as per the selection criteria entered by the user.

A Report contains the Selection Screen and the output list.
Types of Reports:
-> Classical Reports
-> Interactive Reports


Report Processing

The steps in reports is as below:

Start
Initialization
Selection
Read entry
Process Entry
List output

SELECT

The SELECT statement ensures that data is read from the database.In order to read from the database table,following information need to be passed to the database:

-> FROM which database table is the data read? (FROM clause)

-> HOW many lines are read? SINGLE addition allows to select only one line.

-> Which line ir read?WHERE clause determines which columns have to be selected

SYNTAX
SELECT select clause [INTO clause] FROM from clause [WHERE cond1] [GROUP BY fields1] [HAVING cond2] [ORDER BY fields2].

SELECT SINGLE

-> Retrieves only a single record from database.
-> If you know the entire primary key of the record you wish to retrieve, this is faster and efficient.
-> No loop required and also no ENDSELECT.
-> Specify all primary keys

PARAMETERS

Parameters are like DATA statements only difference they allow user inputs.

SYNTAX:

PARAMETERS p.

EG:
Parameter:empid(5) type c default '1000'.
Parameter like zemp_num.

Also there are other options like OBLIGATORY,LOWER-CASE,RADIO BUTTONS etc you can use with it.

SELECT-OPTIONS

  • SELECT-OPTIONS sel FOR f.
  • SELECT-OPTIONS PROGRAM FOR SY-REPID.
  • It creates a selection table containing fields: SIGN,OPTION,LOW,HIGH
  • It gives a range for selection.

SIGN: I/E (INCLUDES/EXCLUDES)

OPTION: EQ,NE,CP,NP,GE,LT,LE,GT

LOW :Lower Limit

HIGH: Higher Limit

WRITE :

This is used to write data on the list.

SYNTAX: WRITE word.

EG:WRITE AT / WORD. "new line

WRITE AT 5 WORD. "column 5

WRITE AT (10) WORD. "output length 10

SKIP

Outputs a blank line.
SYNTAX :

SKIP n " Outputs n blank lines.
SKIP TO LINE line.

Wednesday, December 17, 2008

Event blocks in ABAP program

EVENT BLOCKS



An event is a tag that identifies a section of code.
The section of code associated with an event name and ends when a next name is encountered.

The ABAP Runtime system calls the event blocks in sequence designed fot generating and processing lists.

1)First INITIALIZATION event block is called.

2)Then a Selection Screen is sent to the Presentation Server.

3)After the user leaves the selection screen,START-OF-SELECTION is called.

4)If START-OF-SELECTION contains ABAP statements like WRITE,SKIP,ULINE, a list buffer is filled.

5)The list buffer is subsequently sent to the Presentation server as a OUTPUT LIST.

Some of the events are:
1. Initialization.
-> It is an event that you can use if you need to set a large number of default values.

-> This event block allows you to set default values that can only be determined at runtime
-> It takes place before the standard selection screen is displayed
-> Dynamic Allocation

2. At Selection-Screen.
-> This event is fired after the user-input on a selection screen has been processed,but while the selection screen is still active
-> User Input Validations
-> Passes input data from selection screen to ABAP program
-> Change selection screen
-> Process user input.

3. Start-of-Selection.
-> It takes place after the standard selection screen has been processed,before the data is read from logical database
-> After all data is read by the logical database
-> All Subroutine processing takes place here.


4.End-of-Selection.
-> This event is fired after all the selection is done from the database tables.
-> At this event generally all the data fetched is displayed on the list.

5.Top-of-Page.
-> It takes place when it encounters the top of the page.
-> Mostly to print the header data like company name,date,report name etc.

6. End-of-Page.
-> It takes place when it encounters the bottom of the page.
-> Mostly to print the footer data like no. of pages,time etc

7. At line Selection
-> This event is fired when a user clicks or selects a particular line on the list.
-> When the user triggers the predefined function code PICK

8. At PFn.
-> When the user triggers the predefined function code PFnn

9. At User-command.
-> When the user triggers a function code defined in the program

SAP has a inbuilt program called Driver Program which controls another program in the R/3 System.
DRIVER EVENTS:
Initialization.
At Selection-Screen.
Start-of-selection.
End-of Selection.
USER EVENTS:
At line-Selection
At PFn.
At User-Command.
PROGRAM EVENTS:
Top-of-Page.
End-of-Page.


Hello World Program

Hello World Program

STEP1: Goto transaction SE38

Select program name starting with 'Z' and give title.Also give program type and other details.

Step 2:

Write the above code in the editor.
Activate and execute the above program
Step3: Output List



ABAP Program

ABAP Program

-> ABAP programs are made up of individual statements.
-> Each statement ends with a period.
-> The first word in the statement is a keyword.
-> Words must be seperated by atleast one space.
-> Statements can be intented.
-> Statements can take up more than one line.
-> You can have multiple statements in one line.
Programming Convention
-> Consecutive statements with identical keywords can be condensed into one chained statement
-> In chained statements,initial part of the statement containing the keyword must be followed by a colon.
-> Individual elements that come after the colon must be seperated by comma.

Chain Operator ‘:’ is a chain operator.
  • It combines lines of code beginning with same word.
  • Places common part at the beginning
  • Reduces redundancy of code.
Comments
  • ‘*’ in the first column is used to comment an entire line
  • ‘“’ used t command remaining part of the line.

Data Declaration

-> The TABLES keyword refers to a golbal type flat structure that is defined in the ABAP dictionary.

-> The DATA keyword is used to define local data objects.

-> The data object type is defined using TYPES.

-> PARAMETERS not only defines an elementary data object but also allows the user to input a data.

Data Types

C -> Character
N-> Numeric Text
D ->Date(YYYYMMDD)
T ->Time(HHMMSS)
X ->Byte(Hexadecimal)
I ->Integer
P ->Packed Number
F ->Floating Point Number
STRING -> Character String
XSTRING-> String of Bytes

ABAP supports three numeric data types - I, P and F. Type N is a text type, not a numeric data type (although its values are strings of digits), because the strings are not used for calculation purposes. Typical examples of type N fields are account and article numbers (provided they contain only digits), as well as the sub-fields of date and time fields.

Rules for naming data objects:

  • A name can consist of maximum 30 characters.
  • These symbols are not allowed : ( )+:.,
  • SPACE is a predefined field.
  • With data types P,N,C,X you need to enter the length in parentheses.
  • WIth P type you can specify the DECIMALS to determine no. of decimal places.
  • If no type is specified default type is C.

Conditional statements
If .
stmts.
Elseif .
stmts.

Else.
stmts.
Endif.

Case

Case var.
When val1
stmts.
When val2
stmts.

When others
stmts.
Endcase.

Do loop
Do times.
stmts.
Enddo.

While
While .
stmts.
Endwhile.









Tuesday, December 16, 2008

Structures

Structures
->In R/3 a structure is a description of a group of fields.
->It describes the field names, their sequence, and their data types and lengths.
->Each structure has a name that is unique within the entire R/3 system.
->A structure cannot have the same name as a table.
->A structure name can be used in two ways:
* In a program, a structure name can be used to allocate memory for a group of fields.
* In a table, a structure name can be used to describe a set of fields.
Strictly speaking, a structure is something that only exists within the R/3 Data Dictionary. If you see the word structure, you should immediately think "DDIC structure."
In a program ,structure is used to store different type and size variables in the memory in a sequential manner.
DATA: Begin of struct-name ,
field1,
field2,
fieldn,
End of struct-name .

Eg: DATA:BEGIN OF employee,
eid(5) TYPE N,
ename(20) TYPE C,
END OF emp.

Accessing the elements is by 'employee-eid'.
Nesting of structure is also possible.

In a table structure is :
-> Collection of fields.
-> Stores the description of fields
-> Exists only within the R/3 DDIC.
-> It has no associated database table
-> No primary key
-> No technical attributes
-> We use structures if we want to define the same work area in multiple programs.
Eg:If you want to write a record to a sequential file using one prg and read them using another ,both the prgs should know about the layout of the records.

DDIC Definition for table MARA

DDIC Definition for table MARA

The above screen shows the fields,data elements,description of table MARA(Material Master)

ABAP Editor

ABAP Editor

Tcode: SE38 -> ABAP Editor
ABAP - Advanced Business application Programming
4 – 4th Generation Language.

Enter the name of the program you want to create/change/display.
All cutom programs should begin from 'Y' or 'Z'. SAP reserves the letters 'A' through 'X' for their own programs.
You can specify the attributes,variants,program type.
Program types:
-> Executable
-> Module pool
-> Subroutine pool
-> Class
-> Include
-> Function module
-> Interfaces

Features
The Front-End Editor (Plain Text Mode) has the following features:
· Local scrolling
· Cut, copy, and paste for selected text areas
· Drag and drop
· Context menu for accessing editor functions
· Local Find and Replace function
· Navigation to a selected line (using the context menu)
· Access to the buffer and block operations (using the context menu)
· Commenting out text blocks
· Working with blocks and clipboards
· Navigation functions (forward navigation)
· Syntax check, displaying error messages and warnings in a separate window
· Colored highlighting for comment lines
· Automatic line feed when the maximum line width is reached
· Insert Statement function.
· Multiple-step undo and redo functions
· Displays current cursor position
· Pretty Printer for standardizing the layout
· Import and export for local files.
Hello World Program
In the Editor write the following code:
***************************************************
Report 'Zhello_world'.
WRITE 'Hello World'.
***************************************************
On Activating and Executing the above program, the output is:
Hello World

Monday, December 15, 2008

Creating Tables

Creating Tables

Tcode: SE11

Steps in Creating a table:

1.Create domain – technical characteristics-Field type, No. of characters, Value range

2.Create data element – semantic char-Short,Medium,Long labels, Search help

3.Create table

ABAP Dictionary-SE11

Enter the name of the custom table to be created.
The name should begin from 'Z' .

Table Creation

Specify the Delivery Class and Table Maintenance.


Technical Settings

Specify the Data class , Size category ,Buffering parameters.

Adding Fields
Add fields alongwith data elements or directly.
You can also specify the foreign key relationship between linked tables.
Table types:
Client Dependant Tables:
If the first field of the table is 'mandt', it is client dependant table and the data type is 'clnt'.
Client Independant Tables:
If the first field is not 'mandt' it is client independant table.





Tables

Tables

Table is a Collection of rows and columns.
It has an underlying database table associated.
It stores the description of the table


-> Tables can be defined independently of the database in the ABAP Dictionary.
-> The fields of the table are defined with their (database-independent) data types and lengths.
-> When the table is activated, a physical table definition is created in the database for the table
definition stored in the ABAP Dictionary.

-> The table definition is translated from the ABAP Dictionary to a definition of the particular database.

A table definition in the ABAP Dictionary contains the following components:
 Table fields - define the field names and data types of the fields contained in the
table
 Foreign keys - define the relationships between the table and other tables.
 Technical settings - control how the table should be created in the database.
 Indexes - To speed up data selection, secondary indexes can be created for
the table
The customer can modify SAP tables with append structures and customizing includes.
This kind of modification ensures that the customer enhancements are automatically
merged with the new versions of the SAP tables when there is a release upgrade.


Table Fields
You must define the following for a table field in the ABAP Dictionary:
 Field name: The field name can have a maximum of 16 places and may contain letters,
digits and underscores. The field name must begin with a letter.
 Key flag: determines whether the field should belong to the table key.
 Field type: data type of the field in the ABAP Dictionary.
 Field length: number of valid places in the field.
 Decimal places: number of places after the decimal point, specifying numeric data
types.
 Short text: short text describing the meaning of the field.

Types of Tables:

-> Transparent
-> Cluster
-> Pooled

Transparent Table
* 1:1 relationship with the R/3 DDIC and Database table.
* Both have
* same name,
* Same no. of fields,
* Field names is same
* Used for storing application data (Master/Transaction data)
* Ex: Vendor master data

Pooled Tables

* M:1 relationship between R/3 DDIC and database table.
* All have different names
* Different no of fields and different field names
* Used for system data

CLuster Tables

* M:1 relationship between R/3 DDIC and database table.
* All have different names
* Different no of fields and different field names
* But all have at least one common primary key
* All tables read at same time. hence efficiency increases and performance is improved.
* Used for system data(System configuration info/historical data/statistical data)



ABAP Data Dictionary

ABAP Data Dictionary


Tcode: SE11
-> The ABAP Dictionary centrally describes and manages all the data definitions used in the
system.

-> The ABAP Dictionary is completely integrated in the ABAP Development Workbench.
All the other components of the Workbench can actively access the definitions stored in the ABAP
Dictionary.
-> The ABAP Dictionary supports the definition of user-defined types (data elements, structures and
table types). You can also define the structure of database objects (tables, indexes and views) in
the ABAP Dictionary. These objects can then be automatically created in the database with this
definition.

-> The ABAP Dictionary also provides tools for editing screen fields, for example for
assigning a field an input help (F4 help).

The most important object types in ABAP Dictionary are:
-> Tables
-> Views
-> Types (Data Elements,Structures,Table Types)
-> Domains
-> Search Helps
-> Lock Objects

Data definitions (metadata) are created and managed in the ABAP Dictionary. The ABAP
Dictionary permits a central description of all the data used in the system without redundancies.
New or modified information is automatically provided for all the system components. This
ensures data integrity, data consistency and data security.
You can create the corresponding objects (tables or views) in the underlying relational database
using these data definitions. The ABAP Dictionary therefore describes the logical structure of the
objects used in application development and shows how they are mapped to the underlying
relational database in tables or views.
The ABAP Dictionary also provides standard functions for editing fields on the screen, for
example for assigning a screen field an input help.







ABAP Development Workbench(2)

Components of an Interface
The Interface is mainly divided into two main areas
1)Navigation Area
2)Tools Area

Navigation Area
 Object list :- allows to select a particular object like package,class,program etc
 Toolbar for object list display :- to display name of the object.
 Context menu :- To determine the context.


Tool Area
 ABAP Workbench tools
 Tool functions
 Menus
 Standard toolbar
 Application toolbar
 Context menu
Selecting an object from the object list:

Application Hierarchy -> A list of all of the development classes in the SAP System. This list is
arranged hierarchically by application components, component codes,
and the development classes belonging to them

Development class ->A list of all of the objects in the development class

Program -> A list of all of the components in an ABAP program

Function group -> A list of all of the function modules and their components that are
defined within a function group

Class -> A list of all of the components of a global class. It also lists the
superclasses of the class, and all of the inherited and redefined methods
of the current class.

Internet service -> A list of all of the componentse of an Internet service:
Service description, themes, language resources, HTML templates and
MIME objects.

Local objects -> A list of all of the local private objects of a user.
Objects in this list belong to development class $TMP and are not
transported. You can display both your own local private objects and
those of other users. Local objects are used mostly for testing. If you
want to transport a local object, you must assign it to another
development class.




Sunday, December 14, 2008

ABAP Development Workbench(1)

ABAP Development Workbench
Tcode: SE80.

The Object Navigator is a central point of entry into the ABAP Workbench. It is the successor of
the Repository Browser, and you can access it using transaction code SE80.
->You use the Object Navigator to organize your programming in an integrated development
environment.

->It allows you to create, change, and manage objects.
->Development objects are arranged together in object lists. Each object list contains all of the
objects in a certain category, such as development class, program, or global class.
->From the object list, you can select an object by double-clicking it. The system automatically
opens the tool that you use to process that kind of object.


Development WorkBench is made up of the following tools.
1. Object Browser
2. ABAP/4 Language
3. Repository Includes the Active Directoy.
4. Data Modeler
5. The Query
6. WorkBench Organiser
7. Various Test & Analysis Tools

ABAP/4 Repository Repository Conatins all the development objects .
1. Data Models
2. Programs
3. Dictionary Types & Tables Structures
4. System wide Reusable Functions
5. Screens
6. GUI statuses with meny functions and Icons
7. Language dependent texts such as help info, documetation and error messages
8. Report Variants
9. ABAP/4 Queries

Related Transactions:

S001 - ABAP Development WorkBench

SE09 - WorkBench Organiser

SE80 - ABAP/4 Development WorkBench

SAP Help

Field Help
Use F1 for help on fields, menus, functions and messages.
-> F1 help also provides technical information on the relevant field. This includes, for example, the parameter ID, which you can use to assign values to the field for your user.
-> Use F4 for information on what values you can enter. You can also access F4 help for a selected field using the button immediately to the right of that field.
-> If input fields are marked with a small icon with a checkmark, then you can only continue in that application by entering a permitted value.
. You can flag many fields in an application to make them either required entry fields or optional entry fields. You can also hide fields using transaction or screen variants or Customizing.


SAP Online Help


SAP Help

-> The R/3 System provides comprehensive online help. You can display the help from any screen in the system. You can always request help using the Help menu or using the relevant icon.
-> The Help menu contains the following options :
. Application help: Displays comprehensive help on the current application. Selecting this menu option in the initial screen displays help on getting started with R/3.
. SAP Library: This is where all online documentation can be found.
. Glossary: Enables you to search for definitions of terms.
. Release notes: Displays notes which describe functional changes that occur between R/3 releases.
. SAPNet: Enables you to log on to SAPNet.
. Feedback: Enables you to send a message to the SAPNet R/3 Frontend, SAP’s service system.
. Settings: Enables you to select settings for help.

SAP Navigation

SAP Navigation

To select a particular function in SAP

You can select system functions in the following ways:
-> Use the mouse to choose
. Menu options
. Favorites
. Other options in the tree structure (tree control)
-> Use the keyboard (ALT + the underlined letter of the relevant menu option)
-> Enter a transaction code in the command field:
. A transaction code (T-Code) is assigned to each function in R/3 (not each screen).
. You can access the assigned transaction code from any screen in the R/3 System.
. You can find the transaction code for the function you are working in under the Status option of the System menu.

SAP Screen Elements:

The SAP Screen consist of the following elements:


-> Command field: You can use the command field to go to applications directly by entering the transaction code. You can find the transaction code either in the SAP Easy Access menu or in the relevant application under System® Status.
-> Menu bar: The menus shown here depend on which application you are working in. These menus contain cascading menu options.
-> Standard toolbar: The icons in the system function bar are available on all R/3 screens. Any icons that you cannot use on a particular screen are dimmed. If you leave the cursor on an icon for a moment, a small flag will appear with the name (or function) of that icon. You will also see the corresponding function key. The application toolbar shows you which functions are available in the current application.
-> Title bar: The title bar displays your current position and activity in the system.
-> Check boxes: Checkboxes allow you to select several options simultaneously within a group.
-> Radio buttons: Radio buttons allow you to select one option only.
-> Status bar: The status bar displays information on the current system status, for example, warning and error messages.
-> A tab provides a clearer overview of several information screens.
-> Options: You can set your font size, list colors, and so on here.

Saturday, December 13, 2008

SAP Logon

The Logon screen of SAP contains:
The R/3 System is a client system.
The client concept enables the joint operation, in one system, of
several enterprises that are independent of each other in business terms. During each user session you can only access the data of the client selected during the logon.
-> A client is, in organizational terms, an independent unit in the R/3 System. Each client has its own data environment and therefore its own master data and transaction data, assigned user master records and charts of accounts, and specific customizing parameters. -> A user master record linked to the relevant client must be created for users to be able to log on to the system.
-> To protect access, a password is required for logon.
The password is hidden as you type (you only see asterisks).
-> SAP systems are available in several languages. Use the Language input field to select the logon language for each session.
-> Multiple logons are always logged in the system beginning with Release 4.6. This is for security as well as licensing reasons. A warning message appears if the same user attempts to log on twice or more. This message offers three options:
. Continue with current logon and end any other logons in the system
. Continue with current logon without ending any other logons in the system (logged in system)
. Terminate current logon

SAP Main Menu
-> SAP Easy Access is the standard entry screen displayed after logon. Using the menu path Extras->Set start transaction ,you can select a transaction of your choice to be the default entry screen after logon.
-> You navigate through the system using a compact tree structure that you can adapt to your own specific requirements. Use the menu path Extras® Settings to
change your view of the tree structure. You can use this to display technical names (transaction codes).
-> You can also create a Favorites list of the transactions, reports, files and Web sites you use most.
-> You can add items to your favorites list using the Favorites menu option or by simply dragging & dropping them with the mouse.

Application Server Architecture

Application Server Architecture
All the requests that come from the presentation servers are directed first to the dispatcher.
Dispatcher
The dispatcher writes them fist to the dispatcher queue.
The dispatcher pulls the request from the queue on first-in , first-out basis.
Each request is then allocated to the first available work process.
User Context and Roll Area
To perform any processing for a user’s request a work process needs to address two special memory areas i.e. User Context and the program roll area.
The user context is a memory area that contains information about the user and the roll area is a memory area that contains information about the user, and the roll area is a memory area that contains information about the program execution.
User Context is responsible for:-
User’s Current settings
User Authorizations
The name of the program the user currently is running
Roll Area is responsible for:-
The values of the variables
The dynamic memory allocations
The current program pointer
Each time a user starts a program, a roll area is created for that instance of the program. If two users run the same program at the same time, two roll areas will exist-one for each user. The roll area is freed when the program ends.
Roll Area and the user context play an important part in dialog step processing.
Roll-In / Roll-out processing in dialog step process.
An ABAP/4 program only occupies a work process for one dialog step. At the beginning of the dialog step, the roll area and user context are rolled into the work process.
At the end of the dialog step they rolled out.During the roll in pointers to the roll area and user context are populated in the work process. This enables the work process to access the data in those areas and so perform processing for that user and that program.
Processing continues until the program sends a screen to the user. At that time, both areas are rolled out. Roll-out invalidates the pointers and disassociates these areas from the work process. That work process is now free to perform processing for other requests.
The program is now only occupying memory, and not consuming any CPU. The user is looking at the screen that was sent, and will soon send another request.
Work Processes:
Each work process has four components
Each work process is composed of the following:
(1)A task handler
(2)An ABAP/4 interpreter
(3)A screen interpreter
(4)A database interface
All requests pass through the task handler, which then funnels the request to the appropriate part of the work process.The interpreters interpret the ABAP/4 code.
Notice that there are two interpreters:
->ABAP/4 interpreter
->Screen interpreter.
There are actually two dialects of ABAP/4.
One is the full-blown ABAP/4 data processing language and the other is a very specialized screen processing language.
Each is processed by its own interpreter.
The database interface handles the job of communicating with the database.
Understanding the Types of Work Processes
There are seven types of work processes. Each handles a specific type of request.
The type of work processes and the types of requests that they handle .
WP Type:
D(Dialaog) Dialog requests
V(Update) Requests to update data in the database
B(Background) Background jobs
S(Spool) Print spool requests
E(Enqueue) Logical lock requests
M(Message) Routes messages between application servers within an R/3 system
G(Gateway) Funnels messages into and out of the R/3 system .

Thursday, December 11, 2008

SAP Architecture

SAP Architecture

The SAP Architecture consitutes of three main servers:

Presentation Server
The presentation server is actually a program named sapgui.exe. It is usually installed on a user's workstation. To start it, the user double-clicks on an icon on the desktop or chooses a menu path. When started, the presentation server displays the R/3 menus within a window. This window is commonly known as the SAPGUI, or the user interface (or simply, the interface). The interface accepts input from the user in the form of keystrokes, mouse-clicks, and function keys, and sends these requests to the application server to be processed. The application server sends the results back to the SAPGUI which then formats the output for display to the user.

Application Server
An application server is a set of executables that collectively interpret the ABAP/4 programs and manage the input and output for them. When an application server is started, these executables all start at the same time. When an application server is stopped, they all shut down together.
The number of processes that start up when you bring up the application server is defined in a single configuration file called the application server profile.
Each application server has a profile that specifies its characteristics when it starts up and while it is running.
For example, an application sever profile specifies:
->Number of processes and their types
->Amount of memory each process may use
->Length of time a user is inactive before being automatically logged off

The application server exists to interpret ABAP/4 programs, and they only run there-the programs do not run on the presentation server. An ABAP/4 program can start an executable on the presentation server, but an ABAP/4 program cannot execute there. If your ABAP/4 program requests information from the database, the application server will format the request and send it to the database server.

Database Server
The database server is a set of executables that accept database requests from the application server. These requests are passed on to the RDBMS (Relation Database Management System). The RDBMS sends the data back to the database server, which then passes the information back to the application server. The application server in turn passes that information to your ABAP/4 program. There is usually a separate computer dedicated to house the database server, and the RDBMS may run on that computer also, or may be installed on its own computer.

Configuring
1) Presentation Server,Application Server and Database Server all run on separate machines for most of the systems.
2) In Distribution Presentation configuration, Application Server and Database Server are combined on one computer and Presentation Server on separate computer.
3)When all the servers are combined onto single machine we have Central Configuration.

Wednesday, December 10, 2008

SAP Introduction

SAP Introduction
· SAP was founded in 1972 in Walldorf, Germany. It stands for Systems, Applications and Products in Data Processing. Over the years, it has grown and evolved to become the world premier provider of client/server business solutions for which it is so well known today. The SAP R/3 enterprise application suite for open client/server systems has established new standards for providing business information management solutions.
· The main advantage of using SAP as your company ERP system is that SAP have a very high level of integration among its individual applications which guarantee consistency of data throughout the system and the company itself
In a standard SAP project system, it is divided into three environments,

Development, Quality Assurance and Production.
-> The development system is where most of the implementation work takes place.
-> The quality assurance 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.
The main purpose of using a standard business application software like SAP is to reduce the amount of time and money spend on developing and testing all the programs. Therefore, most companies will try to utilize the available tools provided by SAP.

What is Client? What is the difference between Customization and Configuration?
The difference between customizing and configuration is: -

CONFIGURATION: we will configure the system to meet the needs of your business by using the existing data.
CUSTOMIZING: we will customize or adapt the system to your business requirements, which is the process of mapping SAP to your business process.
CLIENT: A client is a unique one in organizational structure, can have one or more company codes. Each company code is its own legal entity in finance.

SAP R/3 Architecture:

"R/3" stands for
R->Real time data processing,
3-> three-tier application architecture
->There are 9000+ tables in SAP. ->Versions of SAP:4.6c, 4.7EE , ECC 5.0 and ECC 6.0
->R/3 is an integrated suite of applications designed to handle data processing for large corporations. ->R/3 is a system in which your ABAP/4 programs will run.

What is the Purpose of R/3?
The sole purpose of an R/3 system is to provide a suite of tightly integrated, large-scale business applications.
The standard set of applications delivered with each R/3 system are the following:
PP (Production Planning)
MM (Materials Management)
SD (Sales and Distribution)
FI (Financial Accounting)
CO (Controlling)
AM (Fixed Assets Management)
PS (Project System)
WF (Workflow)
IS (Industry Solutions)
HR (Human Resources)
PM (Plant Maintenance)
QM (Quality Management)
CRM (Customer Relationship Management)
These applications are called the functional areas, or application areas, or at times the functional modules of R/3. All of these terms are synonymous with each other.

Advantages of SAP R/3
* The software is customizable using SAP's proprietary programming language, ABAP/4. R/3 is scalable and highly suited for many types and sizes of organizations and runs on six different platforms.
* SAP’s R/3 has been designed to be the best ERP system in the four areas of human resources, financial, supply chain management, and marketing. R/3 is also an international product, and meets the local fiscal, language, and tax requirements of most countries.
* SAP’s R/3 is very versatile, as it will operate on six different platforms, including the recently added Microsoft NT.
* The R/3 package includes several very attractive features like it has a three-tier client/server system. Providing three tiers offers scalability and easier adaptation to the specific needs of large companies and fast-growing companies.

* SAP’s R/3 is available in 14 different languages (German, English, Spanish, etc.) and also incorporates multiple currency features that provide essential information processing capabilities for multinational corporations.
* R/3’s modules are organized by the functional areas of financial, human resources, supply chain management, and marketing. While information is entered separately for each specific module, the modules are fully-integrated and provide real-time applications. This means that data entered into one module is immediately and automatically updated and reflected in all oft the functional areas.
* R/3 is composed of a single, virtual file structure with no subsystems.
* As stated previously, R/3 offers multiple currency features and a three-tier system that is capable of meeting very high demands from the accounting system for either transaction processing or financial reporting.
R/3 also provides for a "single data entry point" where the data entered from any location is instantly sent to all other appropriate modules in the ERP system.

->Minimum operating costs: no retention of redundant data in the back office.
->High level of stability and performance: response times are consistently under one second.
->Good user interface available which makes system user friendly and requires no training for the end user.