Pages

Buy

Buy
Showing posts with label Fundamentals. Show all posts
Showing posts with label Fundamentals. Show all posts

Understanding the Components of a Work Process

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: the ABAP/4 interpreter and the 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 TypeRequest 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

Discovering the R/3 User Interface

Every R/3 screen contains these elements:

Title bar: Contains the title of the current screen.

Menu bar: The contents of the menu bar change with each screen. By browsing the menus within it, you can discover all functions that are possible on the current screen. The System and Help menus are present on every screen and the menu items they contain never change.

Command field: Here you enter commands to be executed. For example, you can log off by typing /nex in this field and pressing the Enter key. The section "Using the Command Field" describes this field in more detail.

Standard toolbar: Contains the Command field and a series of buttons. They will never change in appearance, position, or function, and they will be present on every screen. Some might be grayed out if their functionality is currently unavailable.

Application toolbar: Changes with each screen. Displays buttons that give you quick access to menu items for that screen.

Tips : If you position your mouse pointer over any button and let it rest there for a few seconds, R/3 will display a tool tip describing its function. In R/3 it is called quick info. It contains a brief description of the button and the function key assigned to it.

Interface Menu: Enables you to customize the characteristics of the user interface, access the Windows clipboard, and generate graphics. The following section will cover more features of the Interface Menu in depth.

Screen area: This is the big area in the middle of the screen that displays the report data or a screen from a dialog program.

Status bar: Displays messages, the system ID, session number, client number, insert/overtype mode indicator, and the current time.

You can turn most screen elements on and off. If your screen does not look or behave like the one described in this chapter, follow the instructions in the next section to correct it.


Interface Menu: Enables you to customize the characteristics of the user interface, access the Windows clipboard, and generate graphics. The following section will cover more features of the Interface Menu in depth.

Screen area: This is the big area in the middle of the screen that displays the report data or a screen from a dialog program.

Status bar: Displays messages, the system ID, session number, client number, insert/overtype mode indicator, and the current time.

You can turn most screen elements on and off. If your screen does not look or behave like the one described in this chapter, follow the instructions in the next section to correct it.

Basic ABAP Key Words

String operations:
<!--[if !supportLists]-->v <!--[endif]-->Translate
It is a keyword used to change the case of the input string to another case.
Syntax: translate a to lower case
<!--[if !supportLists]-->v <!--[endif]-->concatenate
It is a keyword used to concatenate n no of strings.
Ex: Parameters: a(10),
B(10).
Data c(20).
Concatenate a b into c separated by space.

It is not possible to concatenate numeric value.
<!--[if !supportLists]-->v <!--[endif]-->Split
It is a keyword to split a particular char.
Ex: Parameters: a(20),
Data : b(10),
C(10).
Split a at ‘,’ into b c
Write: /b,
c.
o/p: a = india,usa
b = India , c = usa
<!--[if !supportLists]-->v <!--[endif]-->Replace
It is used to replace particular char with some other char.
EX: Parameters: a(20).
Do.
If a CA ‘,’
Replace ‘,’ with space into a.
Else.
Exit.
Enddo.
Write a.
o/p: a = India,usa,uk
India us auk
<!--[if !supportLists]-->v <!--[endif]-->Offsetting
It is a mechanism to move the control to the particular position of the string.
EX: A = I N DI A
0 1 2 3 4
B = A +2(1)-ào/p : D
B = A +2-à o/p: DIA
B = A+2(2)-ào/p DI
B = A+0--à o/p : INDIA
<!--[if !supportLists]-->v <!--[endif]-->String Length(Strlen)
Used to find out the string length
EX: Parameters: a(20).
Data B type i.
B = strlen( a ).
Write B.
o/p 5.

ABAP Basic Tips

What is use of using HASHED TABLE?

Hashed table is useful when your have to work with very big internal table and to read it with
"READ TABLE WITH KEY ..."
The time access is constant !
Definition of a 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 to INSERT itab within a LOOP) are not allowed."
As long as your records has unique key(s), using hash table will give you a huge performance gain when dealing with large dataset. assuming in your case, 10000 record , and if the key is unique, use hash table. The main use of hash tables is for looking up fixed information from a key. So if you have a report that has personnel number and you want to display their name, you could use a hash table.
Thus:
Code:
types: begin of typ_vbeln,
vbeln like vbak-vbeln,
ernamlike vbak-ernam,
end of typ_vbeln.
data: ls_vbeln type typ_vbeln,
lt_vbeln type hashed table of typ_vbeln with unique key vbeln.
...
select vbeln ernam into table lt_vbeln from vbak.
...
loop at itab.
read table lt_vbeln with table key vbeln = itab-vbeln
into ls_vbeln.
write: ls_vbeln-ernam.
endloop.
…………………………………………………………………………………
Submit ABAP report with SQL traces
You use ST05, Trace Request, to do a SQL trace.
When using SQL trace, it is good to run the program in debugger and just before you execute the SQL, go to ST05 in another session and turn the trace on.
After, or when, the SQL is finished, you can turn the trace off.
Then click on List Trace to see the details.
This is the way to control the traces.
If you just turn the trace on and then execute the program, you will get everything and will be overflooded with unnecessary information.
……………………………………………………………………………………….
Testing and Debugging ABAP Codes, Functions
First test your code with '/h' type in command window which shall take you to debug or by putting break points with F8. You test your program from code and then go to se30 performance analysis transaction and there you can know what are the drawbacks. Then go to SLIN transaction and do extended syntax check or from code in menu options where you have debugging -> extended check and the program id ready without error.
Test for division by zero if it involves calculation or code accordingly.
Test by leaving all parameters in selection screen blank.
Test by entering wrong values in selection screen and display a pop-up if the user enters wrong selection screen values.
You can also do ABAP trace and SQL trace to make sure that your program is efficient.
As mentioned above type /h in command line and try to execute the program. Another way is to set break-point at the function module or the required line and do single step execute or execute. Once you finished debugging, you can select Delete to clear all the break points.
<!--[if !vml]-->Testing and Debugging ABAP<!--[endif]-->

Third option in certain cases is to check for sy-subrc <> 0 and proceed from there by making it 0 by updating the sy-subrc in the debug editor and see how the program behaves if the value is what you enterd in the debug screen. For certain case try to use WATCH POINT feature in debug editor.



Fields of Internal Tables
SY-TABIX
Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.
APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.
COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.
LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
SEARCH FOR sets SY-TABIX to the index of the table line in which the search string is found.
SY-TFILL
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table.
SY-TLENG
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the length of the lines in the relevant internal table.
SY-TOCCU
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the initial amount of memory allocated to the relevant internal table.

………………………………………………………………………
Difference between Work Area and Header Line
While adding or retrieving records to / from internal table we have to keep the record temporarily.
The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
e.g.
data: begin of itab occurs 10,
ab type c,
cd type i,
end of itab. " this table will have the header line.
data: wa_itab like itab. " explicit work area for itab
data: itab1 like itab occurs 10. " table is without header line.
The header line is a field string with the same structure as a row of the body, but it can only hold a single row.
It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table.
……………………………………………………………………………………………
Parallel cursor is the technique to increase the performance of the program, when there are nested loops.
For example if we use nested select in our program instead of For all entries addition, then definitely performance going down. In the same way the if we use nested loops in the program it will also leads to down the performance.
For example:
if the code contains this type of logic:
loop at itab into wa.
loop at itab1 into wa1.
endloop.
endloop.
In the above logic, for one record of the itab, again the table itab1 loops many times. If itab contains many records and also at the same time if itab1 contains double the records, then this would result into performance issue. You can modify it as:
loop at itab into wa.
read table itab1 into wa1 with key field1 = wa-field1.
v_tabix = sy-tabix.
if sy-subrc eq 0.
loop at itab1 into wa1 from v_tabix. "It will loop from that index
endloop.
endif.
endloop.
---------
Parallel Cursor helps in performance tuning.
Reasons for using Parallel Cursor:
Nested Loops is one of the fear factors for all the ABAP developers as this consumes lot of program execution time. If the number of entries in the internal tables is huge, then the situation would be too worse. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop.
Program (Nested Loop using Parallel Cursor):
REPORT zparallel_cursor2.
TABLES:
likp,
lips.
DATA:
t_likp TYPE TABLE OF likp,
t_lips TYPE TABLE OF lips.
DATA:
w_runtime1 TYPE i,
w_runtime2 TYPE i,
w_index LIKE sy-index.
START-OF-SELECTION.
SELECT *
FROM likp
INTO TABLE t_likp.
SELECT *
FROM lips
INTO TABLE t_lips.
GET RUN TIME FIELD w_runtime1.
SORT t_likp BY vbeln.
SORT t_lips BY vbeln.
LOOP AT t_likp INTO likp.
LOOP AT t_lips INTO lips FROM w_index.
IF likp-vbeln NE lips-vbeln.
w_index = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
GET RUN TIME FIELD w_runtime2.
w_runtime2 = w_runtime2 - w_runtime1.
WRITE w_runtime2.
………………………………………………………………………….
Explain about secondary index for queries.
An index in SAP is like an index for a book. If you want to look up something from the book you refer the book's index page. Right?
In the same way in SAP, when you fire a query it makes it easy for the system to search a particular record in the db table if the field that you have in the SELECT statement is an index.

So in that sense, there is no difference between the query based on a primary index or a secondary index.
They are fired exactly the same way.

eg: SELECT MATNR FROM MARA.
Here matnr could be a primary or a secondary index.
Primary Index
The Primary Index is the one that is created on declared Primary Keys of the table.

It is not always possible to stick on to primary index for querying a particular table for your report.

For example, at our company, we are using Special Stock Indicators "E" and "O" for the stocks. Almost 95% of the Finished & Semifinished products move within SAP with tag "E".

If I want to develop Z report to process material documents with "E" stock, I have to query mseg table on Sale Order Number (MAT_KDAUF) and Item Number (MAT_KDPOS).

But Primary Index of mseg does not include sale order number and item. Then to improve performance of my query I have to create another index on mseg with MAT_KDAUF and MAT_KDPOS fields.

Then my query will be something like this,

select * into table i_mseg from mseg where matnr = p_matl and mat_kdauf = p_so and mat_pos = p_item.

But there are many things to be taken care while creating secondary indexes.

1. More number of indexes on single table will result in database swelling and also reduce the performance of the database. Indexes are nothing but a copy index key columns of the main table and associated record pointer sorted on index keys. Hence as we create more more sets, database will keep on searching the suitable index for your query.
2. An index with more number of fields, is literally an useless index. Because as you keep adding fields to your index, it is just like you are searching your entrie table for the filter criteria.
3. Essentially, maximum three fields per index, and maximum 6 indexes per table will produce the desired results.
4. If the table size is small and growth rate is less, more number of fields or indexes can be added.
5. Very important point is, create index with a field set only if you have the requirement of certain querying criteria in many programs or reports. In the above example, whatever material doc related report I develop I'll use sale order number and item number in the query. Hence the requirement is generic. Don't create an index for one time use.
6. Maintain the field sequence in where clause when you are trying to point to an index of the table. It will improve the performance considerably.
………………………………………………………………………………………………
Quick Note on Design of secondary database indexes and logical databases
Secondary Database
First it must be stated that table design is a more logical work while index design is rather technical. In table design it might make sense to place certain fields (client, company code, ...) in the beginning. In index design, this is not advisable. Very important for an index is that it contains very selective fields in the beginning. Those are fields like object numbers. Not selective are client, company code, ...
Indexes should be small (few fields). The Database optimizer can combine two or more indexes to execute a query.
Indexes of one table should be disjoint (have few common fields), in order not to confuse the optimizer which index to use.
Note that each index slows the inserts into the table down. Updates are only slowed down if indexed fields are updated. In general, heavy inserted tables should have only few indexes while heavy selected tables might have more.
Logical Database
Using logical databases is a good method to write reports. Logical databases can be optimized centrally. But ensure that the structure of the logical database fits well to your report. Otherwise the effect can be the opposite.

1. What is meant by secondary index?
2. What is the purpose of cursor?
If you cannot use the primary index to determine the result set because, for example, none of the fields primary index occur in the WHERE or HAVING clause, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
You should only create secondary indexes, for database tables from which you mainly read, since indexes have to be updated each time the database table is changed. secondary indexes should contain columns that you use frequently in a selection, and that are as highly selective as possible to improve performance..
Cursor is used to read the data:-----
When you use a cursor to read data, you decouple the process from the SELECT statement. To do this, you must open a cursor for a SELECT statement. Afterwards, you can place the lines from the selection into a flat target area. An open cursor points to an internal handler, similarly to a reference variable pointing to an object.
Cursor is used for one more purpose that is ,You can set the cursor on the current list dynamically from within your program. You can do this to support the user with entering values into input fields or selecting fields or lines. To set the cursor we use SET CURSOR command.
SET cursor .
This statement sets the cursor to column of line of the output window.
…………………………………………………………………………….
Create a table maintance program for a z table
In transaction SE11, in the attribute tab of your z table check table maintenance check box. Go to SM30 transaction, enter the ztable name and click on maintain button. Here you can enter new entries into the ztable .
Or
You can create a PARAMETER TRANSACTION for the transaction for SM30 .
Follow these steps :
1. go to transaction SE93 , give your own transaction code say ztran_tab, for maintaining your ztable.
2. Click on create button and check the radio button Transaction with parameters (PARAMETER TRANSACTION) and click on the tick button.
3. In the next screen enter default values:
transaction : SM30
check the check box skip initial screen
4. Scroll down you will find a table control for default values
--------------------------------------------------------------------------------
Name of the screen field | value
--------------------------------------------------------------------------------
VIEWNAME | your ztable name
SHOW | X
Save your work.
Now as you have created a custom transaction for maintaining your ztable this transaction can be called from any program with CALL transaction 'XXX'.

Introduction (Lesson -1)

ABAP stands for – Advanced Business Application Programming.It is  a programming language for developing applications for the SAP R/3 system.
The latest version of ABAP is  called  ABAP Objects and supports object-oriented programming. SAP will run applications written using ABAP/4, the earlier ABAP version, as well as applications using ABAP Objects.
Without further adieu , lets dive into ABAP.
Note, this tutorial will not go into extensive details on ABAP language constructs (which become very boring to read ) but quickly introduce key concepts to get you started so you can focus your attention on more important topics.

Data Types

Syntax to declare a variable in ABAP -
DATA Variable_Name Type Variable_Type.
Example:
DATA employee_number Type I.
The following is a list of Data Types supported by ABAP
Data Type Initial field length Valid field length Initial value Meaning
Numeric types
I 4 4 0 Integer (whole number)
F 8 8 0 Floating point number
P 8 1 – 16 0 Packed number
Character types
C 1 1 – 65535 ‘ … ‘ Text field(alphanumeric characters)
D 8 8 ’00000000′ Date field(Format: YYYYMMDD)
N 1 1 – 65535 ’0 … 0′ Numeric text field(numeric characters)
T 6 6 ’000000′ Time field(format: HHMMSS)
Hexadecimal type
X 1 1 – 65535 X’0 … 0′ Hexadecimal field
Processing Data
- Assigning Values
a=16.
move 16 to a.
write a to b.
- Arithmetic Operations
compute a = a*100.

Control Statements

Following control statements can be used -
- If … EndIf Loop
if [not] exp [ and / or [not] exp ].
……..
[elseif exp.
.......] [else.
.......] Endif.
- Case statement
Case variable.
when value1.
………
when value2.
………
[ when others.
.........] Endcase.
Do.
-While loop
While <logical expression>.
…..
…..
Endwhile.
- Do loop
Do <n> times.
…..
…..
Enddo.

Logical Operator

A list of logical operators
  • GE or >=
  • GT or >
  • LE or <=
  • LT or <
  • EQ or =
  • NE or <>

ABAP/4 Editor

Finally , here is where you will spent most of your time as a developer creating / modifying programs. Transaction SE38
abap

SAP ABAP Technology

Development using ABAP and JAVA

ABAP stands for Advanced Business Application Programming language. It is an interpreted programming language that runs in the SAP ABAP Runtime environment. ABAP is the main language used for building solid-state business application solutions in the SAP Runtime environment. It has evolved over the years to include Object Oriented language extensions as well.

With the introduction of the Netweaver release, certain applications such as Portal technology were best run on a JAVA based solution, such as J2EE. SAP Netweaver also has a JAVA based runtime environment. This runtime environment runs JAVA based solutions that have been deployed to the SAP JAVA server.

SAP has balanced its SAP software to leverage the best of either language for supporting the various applications.
  • SAP Applications are installed on two different database schemas, depending on the specific application and each are accessed by the respective runtime environment.
          - one for the JAVA instance (JAVA Stack)
          - one for the ABAP Instance (ABAP Stack)

  • ABAP is used for all applications based on the ABAP stack.
          - This includes all versions of SAP prior to SAP Netweaver, including the SAP Enterprise release.
          - The ABAP Stack can still handle web based activities, however this is realized via ABAP based Web Applications such as ABAP WebDynpro or Business Server Pages for UI solutions, and ABAP web services for SOAP/XML based solutions.

  • JAVA is used based on an integrated J2EE Engine that presents the foundation for fully web based technologies.
          - Portal framework, Business Intelligence, IPC (Internet Pricing and Configuration) use the JAVA stack as its foundation, running a J2EE engine.
Note: Some applications, such as the process integration solution (PI or XI) requires both an ABAP and JAVA stack, as it uses the best of both from an integration point of view.
SAP Development objects are part of the SAP Software repository. This repository consists of the following types of development objects:
  • Data Dictionary Objects
  • Domain Definitions
  • Data Element Definitions
  • Table/ View/ Structures
  • All remaining Global Type Definitions
  • Programs Objects
  • Programs
  • Function Groups and Function Modules
  • Web Dynpro controllers
  • BSP Applications
  • Web Applications
  • Includes
  • XSLT transformations
  • All remaining program related objects
There are several other repositories that contain various constructs and objects that are used by developers, such as the MIME repository containing multimedia objects.

Modularity in ABAP (Lesson - 3)

Macro, Include, Subroutines, Function Modules & Groups


When you modularize source code, you place a sequence of ABAP statements in a module. Then, instead of placing all of the statements in your main program, you just call the module.When the program is generated, the source code in the modularization unit is treated as though it were actually physically present in the main program.
Need of Modularization
  • Improve the structure of the program.
  • Easy to read the code
  • Easy to maintain the code
  • Avoid redundancy and promotes code reuse
Various Modularization Techniques
  • Use of Macros
  • Use of include files
  • Subroutines
  • Function Modules
Lets look into each of them in detail :

SAP- ABAP Macro

If you want to reuse the same set of statements more than once in a program, you can include them in a macro.
You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.
Macros  can be useful for long calculations or complex WRITE statements.
Syntax
DEFINE <macro_name>
‘Macro Statements
END-OF-DEFINITION
Macros can use Parameters &N where N = 1,2,3…
Example:-
DATA: number1 TYPE I VALUE 1.
DEFINE increment.
ADD 1 to &1.
WRITE &1.
END-OF-DEFINITION.
Increment number1.
WRITE number1.
Output: 2

Include Programs

Include Programs are solely for modularizing source code, and have no parameter interface.
Include programs allow you to use the same source code in different programs. They  can be useful if you have lengthy data declarations that you want to use in different programs.
Syntax
Include <include program Name>
Points to Note
  • Include programs cannot call themselves.
  • Include programs must contain complete statements.
Example:
INCLUDE ZILX0004.
WRITE: / ‘User’, SY-UNAME,/ ‘Date’, SY-DATUM.
================================
PROGRAM ZRPM0001.
INCLUDE ZILX0004.

Subroutines

Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module.
Syntax-
FORM <Subroutine> [<pass>].
<Statement block>.
ENDFORM.
<Subroutine> = Name of the subroutine
<pass> = Parameters being passed
Types of Subroutines
  1. Internal
    • Subroutine defined in same program being called.
    • Can access all the data objects declared in the main ABAP/4 program.
  2. External
    • Subroutine defined outside the program being called.
    • Need to use the <pass> option or declare data objects in common parts of memory.
Calling a Subroutine

Internal Subroutines
PERFORM <subroutine> [<pass>]
<subroutine> = Name of the subroutine
<pass> = Parameters being passed
Data declared in main program is automatically available.
External Subroutines
PERFORM <subroutine>(<Program>) [<pass>].
PERFORM <subroutine> (<Program>) [<pass>] [IF FOUND].
PERFORM (<subroutine>) IN PROGRAM (<Program>) [<pass>] [IF FOUND].
PERFORM <index> OF <subroutine1> <subroutine2> <subroutine3> [<pass>].
Points to Note
  • Nested calls are allowed in subroutines (i.e. PERFORM within a FORM … ENDFORM ).
  • Recursive calls are also possible.
  • To define local data, use the DATA statement after FORM . Each time you enter the subroutine, the data is recreated (with an initial value) and released at the end (from the stack).
  • To define global data used within a subroutine, use the LOCAL statement after FORM . The values are saved when you enter the subroutine and then released at the end (from the stack)

Function Modules

Function Modules are general purpose ABAP/4 routines that anyone can use. Infact , there are a large number of standard function Modules available.
Function Modules are organized into Function Groups: Collections of logically related functions. A Function module always belongs to a Function Group.
Syntax-
FUNCTION <function module>
<Statements>
ENDFUNCTION.
Important information Associated with Function Module
  • Administration
  • Import/Changing/Export parameters.
  • Table Parameters/Exceptions.
  • Documentation
  • Source code – L<fgrp>U01 . <fgrp> is the Function Group
  • Global Data – L<fgrp>TOP .Global data for the function group- Accessible across function modules in the function group.
  • Main Program – SAPL<fgrp> . Contains the list of all the include files for that function group
Call a Function Module
To call a function module, use the CALL FUNCTION statement:
CALL FUNCTION <module>
[EXPORTING  f1 = a 1.... f n = a n] [IMPORTING  f1 = a 1.... f n = a n] [CHANGING   f1 = a 1.... f n = a n] [TABLES     f1 = a 1.... f n = a n] [EXCEPTIONS e1 = r 1.... e n = r n [ERROR_MESSAGE = r E]                                      [OTHERS = ro]].

Function Groups

Function groups are containers for function modules. Infact, there are a large number of standard Function Groups.
All of the function modules in a function group can access the global data of the group.
Like executable programs (type 1) and module pools (type M), function groups can contain screens, selection screens, and lists.
Points to Note
  • Function Groups cannot be executed.
  • The name of a function group can be up to 26 characters long.
  • When you create a function group or function module, the main program and include programs are generated automatically.
  • Function groups encapsulate data.
How to create a Function Group
  1. Goto Transaction SE80.
  2. Select Program in the DropDown.
  3. Write the name of the Function Group That you want to create. Generally User made Function groups start with “Z”. e.g. – <Z_FUNCTION_GROUP_NAME> . Hit Enter Key.
  4. Note that The TOP Include is create by default if the user checks the option of creating a TOP include.
How to create a Function Module
  1. Create a function Group (say “ZCAL“).
  2. Create a function module, set the attributes like  (Function group, Application, Short Text and Process Type) and Save.
  3. Include file “LZCALU01” will have source code of first function module.
  4. Include file “LZCALTOP” will have global data.
  5. Main program “SAPLZCAL” contains
    • Global data Include file “LZCALTOP“
    • Function modules include file “LZCALUXX“
    • User defined Include files “LZCALF..”, “LZCALO..” and “LZCALI..”
  6. Define interface parameters and Exceptions
  7. Write the source code
  8. Activate Function Module
  9. Testing the Function Module – Single Test & Debugging
  10. Documenting and Releasing a Function Module
That’s all to Modularity in ABAP.

Data Dictionary Tutorial (Lesson -2)

A data dictionary is a central source of information for the data in a information management system. Its main function is to support the creation and management of data definitions (or “metadata”).
What is Data dictionary used for ?

  • Management of data definitions
  • Provision of information for evaluations
  • Support for software development
  • Support for documentation
  • Ensuring that data definitions are flexible and up-to-date
abap-data-dictionary
Objects in the ABAP Dictionary resided on three levels that support their re-usability. These levels are:
  1. Tables and structures
  2. Data elements
  3. Domains
Lets look into them in detail -

Domains

  • Describes the technical characteristics of a table field
  • Specifies a value range which describes allowed data values for the fields
  • Fields referring to the same domain (via the data elements assigned to them) are changed when a change is made to the domain
  • Ensures consistency
Ex. Purchasing document number (EBELN)

Data Elements

  • Describes the role played by a field in a technical context
  • Fields of same semantic meaning can refer to the same data element
  • Contains the field information
Ex. Purchasing document number (EBELN)

Tables

  • Represent the Database Tables where data actually resides.
  • Tables can be defined independently of the database in the ABAP Dictionary.
  • The fields of the table are defined with their (database-independent) SAP ABAP data types and lengths.

Structures

  • Are record declarations that do NOT correspond to a Database Table.
  • Just like user-defined data type.
  • Defined like a table and can then be addressed from ABAP programs.
  • Structures contain data only during the runtime of a program.

Aggregated Objects of ABAP Dictionary

Aggregated means consisting of several components. In the ABAP Dictionary, aggregated objects are objects which come from several different transparent tables.
  1. Views
  2. Search Help
  3. Lock Objects
Lets look into them in detail

Views

  • Views in SAP _ ABAP are used to summarize data which is distributed among several tables
  • The data of a view is not actually physically stored. The data of a view is instead derived from one or more other tables
  • It is tailored to the needs of a specific application

Search Help

  • A Search help is a tool to help you search for data records in the system
  • An efficient and user-friendly search assists users where the key of a record is unknown

Lock Objects

  • Simultaneous accessing of the same data record by two users in the SAP system is synchronized by a lock mechanism.
  • Locks are set and released by calling certain function modules. These function modules are generated automatically from the definition of so-called lock objects in the ABAP/4 Dictionary
Function modules :
Enqueue_<obj name> – to lock the table
dequeue_<obj name> – to release the lock

Important Transactions
  • SE11 : Data Dictionary Initial Screen (SE12 Display only)
  • SE13 : ABAP Dictionary : Technical Settings
  • SE14 : Database Utility
  • SE15 : Repository Information System
  • SE16 : Data Browser
  • SE17 : General table Display
  • SE55 : Table View Maintenance
  • SM30 : Table Maintenance