Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

Tuesday, February 21, 2012

ABAP Useful Tricks

SDN Forum is an ocean for all SAP Users.
Those who use and contribute in it truly know the power of collaboration.
Here is a link to one of the many hidden gems providing handy tips for ABAP Programmers.

ABAP FAQs

 

Tuesday, March 24, 2009

USER EXITS

User exits :

1. Introduction
2. How to find user exits
3. Using Project management of SAP Enhancements

1. Introduction:

User exits (Function module exits) are exits developed by SAP. The exit is implementerd as a call to a functionmodule. The code for the function module is writeen by the developer. You are not writing the code directly in the function module, but in the include that is implemented in the function module.

The naming standard of function modules for functionmodule exits is:
EXIT_<3 digit suffix>

The call to a functionmodule exit is implemented as:
CALL CUSTOMER.-FUNCTION <3 digit suffix>

Example:

The program for transaction VA01 Create salesorder is SAPMV45A

If you search for CALL CUSTOMER-FUNCTION i program
SAPMV45A you will find ( Among other user exits):

CALL CUSTOMER-FUNCTION '003'
exporting
xvbak = vbak
xvbuk = vbuk
xkomk = tkomk
importing
lvf_subrc = lvf_subrc
tables
xvbfa = xvbfa
xvbap = xvbap
xvbup = xvbup.

The exit calls function module EXIT_SAPMV45A_003

2. How to find user exits?

Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT

If you know the Exit name, go to transaction CMOD.

Choose menu Utillities->SAP Enhancements. Enter the exit name and press enter.

You will now come to a screen that shows the function module exits for the exit.

3. Using Project management of SAP Enhancements, we want to create a project to enahance trasnaction VA01 .

- Go to transaction CMOD
- Create a project called ZVA01
- Choose the Enhancement assign radio button and press the Change button

In the first column enter V45A0002 Predefine sold-to party in sales document.

Note that an enhancement can only be used in 1 project. If the enhancement is already in use, and error message will be displayed

Press Save

Press Components. You can now see that enhancement uses user exit EXIT_SAPMV45A_002. Double click on the exit.

Now the function module is displayed. Double click on include ZXVVAU04 in the function module

Insert the following code into the include: E_KUNNR = '2155'.

Activate the include program. Go back to CMOD and activate the project.

Goto transaction VA01 and craete a salesorder.

Note that Sold-to-party now automatically is "2155"
*****************************************************

What is User Exits and Customer Exits?
Difference between user exits & customer exits:

User exit - A user exit is a three character code that instructs the system to access a program during system processing.

SXX: S is for standard exits that are delivered by SAP. XX represents the 2-digit exit number.

UXX: U is for user exits that are defined by the user. XX represents the 2-digit exit number

Customer exit - The R/3 enhancement concept allows you to add your own functionality to SAP’s standard business applications without having to modify the original applications. SAP creates customer exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks. *-- Mani


The following document is about exits in SAP :-

The R/3 enhancement concept allows you to add your own functionality to SAP’s standard business applications without having to modify the original applications.

SAP creates user exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.

Types of Exits
There are several different types of user exits. Each of these exits acts as hooks where you can attach or "hang" your own add-ons.

Menu Exits
Menu exits add items to the pulldown menus in standard SAP applications. You can use these menu items to call up your own screens or to trigger entire add-on applications.

SAP creates menu exits by defining special menu items in the Menu Painter. These special entries have function codes that begin with "+" (a plus sign). You specify the menu item’s text when activating the item in an add-on project.

Screen Exits
Screen exits add fields to screens in R/3 applications. SAP creates screen exits by placing special subscreen areas on a standard R/3 screen and calling a customer subscreen from the standard screen’s flow logic.

Function Module Exits
Function module exits add functions to R/3 applications. Function module exits play a role in both menu and screen exits.

When you add a new menu item to a standard pull down menu, you use a function module exit to define the actions that should take place once your menu is activated.

Function module exits also control the data flow between standard programs and screen exit fields. SAP application developers create function module exits by writing calls to customer functions into the source code of standard R/3 programs.

These calls have the following syntax:

CALL CUSTOMER-FUNCTION ‘001’.

Field Exits
Field exits allow you to create your own programming logic for any data element in the Dictionary. You can use this logic to carry out checks, conversions, or business-related processing for any screen field. Example: The data element BBBNR identifies a company’s international location number. You might want to set up your R/3 System so that all international location numbers are larger than 100.

The field exit concept lets you create a special function module that contains this logic.

You assign the special function module to the data element BBBNR. You then assign the module to any programs and screens in which users can add new international location numbers. When you activate your field exit, the system automatically triggers your special routine whenever a user enters a company location number.

In 4.6c, you can use "RSMODPRF" program to create field exits.

An example of a user exits :-

MODULE user_exit_0001 INPUT
CASE okcode.
WHEN 'BACK OR EXIT'.
CASE sy-dynnr.
WHEN '100'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN '200'.
******************************************************************************
**** Note that you can write any code that satisfy your needs. ****
**** But in this case, this was wrote as a sample code for reference sake. ****
**** And you can test it. ****
******************************************************************************
SET SCREEN 100.
LEAVE SCREEN.
ENDCASE.
ENDCASE.

Monday, February 16, 2009

Example of Function Module in Subroutine

REPORT ZTEST_11.

parameters :name(20) type c.
data:begin of itab occurs 0 ,
value(20),
end of itab,
choise like sy-tabix.
at selection-screen on value-request for name.
perform f4 changing name.

*&---------------------------------------------------------------------*
*& Form F4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_NAME text
*----------------------------------------------------------------------*
FORM F4 CHANGING P_NAME.

itab-value = 'sap'.
append itab.
itab-value = 'sap1'.
append itab.
itab-value = 'sap2'.
append itab.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
ENDPOS_COL = 40
ENDPOS_ROW = 12
STARTPOS_COL = 20
STARTPOS_ROW = 5
TITLETEXT = 'Select an ID'
IMPORTING
CHOISE = choise
TABLES
VALUETAB = itab
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2.
CHECK choise > 0.
clear screen.
READ TABLE itab INDEX choise.
name = itab-value.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.




ENDFORM. " F4

Thursday, January 15, 2009

Enhancements

Enhancements:

It allows us to add our own functionality to SAP’s standard business application without having to modify the original applications.
SAP creates enhancements for specific programs, screens and menus within standard R/3 applications. These enhancements do not contain any functionality.
Instead, the enhancements act as hooks where we can hang our own add-on functionality onto these hooks.

Advantages with Enhancements:
• They do not affect standard SAP source code.
• They do not affect software updates

NOTE: Customer enhancements may not be available for all programs and screens found in the SAP system. You can only use customer exits if they already exist in SAP System.

Enhancement Approaches:
Procedural
- Using Function Modules
- Are called Customer Exits
Object Oriented
- Using Classes and Methods
- Are called BADIs

Procedural, we have two types.
1 – Using Subroutines.
2 – Using Function Modules.

Customer Exits
Types of Exits
Entire SAP Product can be divided in to 3 parts:
- Screens (Front End)
- Programs
- Tables (Back End)

We use:
Screen and Menu Exits to enhance the Front End
Function Exits to enhance the programs
APPEND STRUCTURES/CI Includes to enhance Back End

Menu Exits add items to pull down menus in standard SAP applications. The menu items can be used to call up own screens or to trigger entire add-on applications.
These can be created by defining special menu items in Menu Painter.

Screen Exits add fields to screens in R/3 applications. SAP creates screen exits by placing special subscreen areas on a standard R/3 screen and calling a customer sub-screen from the standard screen’s flow logic.

Function Module Exits add functionality to R/3 applications. They play role in both menu and screen exits.
When new items are added to standard menu, function module exit is used to define the actions that should take place once menu is activated.
Function module ecits also control the data flow between standard programs and screen exit fields.

Note: We can take the advantage of the exits only when SAP provides it in the Standard Transactions.

To locate the exits for any transaction:
Ther are many way for locating the exits, we go through the commonly used ones:
1. Goto SE93 – find the program for the transaction – goto program and find the Package / Development Class bu going to –
GOTO – ATTRIBUTES.
Now, goto SMOD transaction, find out the enhancement for package / development class by pressing F4 on enhancement.
Enter the name of Development Class / Package of the standard program.
Enhancements will be displayed. Select individual enhancement (in case more than one enhancement are there).
Enter enhancement name, select component option and click on display.
Observe the function module exits.
2. Use a piece of code – redundantly available online to pass the transaction and it returns all the enhancements used in the transaction.
3. Open the program in display mode and find the string CALL_CUSTOMER
Double click on CALL CUSTOMER function module exit.

Link to Short Tutorial on User Exits

Tuesday, January 13, 2009

LSMW

Legacy System Migration Workbench (LSMW)

Transaction Code: LSMW

LSMW is majorly used by functional consultants to migrate data between third party systems to SAP system.
We can not directly upload the data to SAP tables; we have to use one of the methods given as an option (by SAP) to transfer data to SAP system. The options available through LSMW are:
• Batch / Direct Input
• BDC
• BAPI
• IDoc
• ALE
The above methods are also available from there own individual transactions to be used explicitly rather than from LSMW.
There are several other options to transfer data which are not available in LSMW.
Depending on various factors
LSMW is mostly used for one time data transfer; it can be used for regular data transfers with some workarounds.
There are some great tutorials of LSMW available at SAP Technical: Tutorials on LSMW. I think there is not much I can add on that, so visit
For Direct Input Method
For Batch Recording
For ALE / IDOC
For BAPI

Thursday, January 8, 2009

Batch Data Communication (BDC)

Creating a BDC program.

Requirement:

Upload vendor master using BDCs.
1. Create the text file (use tab button between values to keep uniform distance)
210 0001 0001 0001 Mr. Dallas dl

Lord Krishna Bank IN 950000



2. Goto Tcode SHDB.
3. Click on new recording
4. enter tcode XK01
5. enter
6. create a dummy record
7. save.
8. back
9. select the recording
10. click on program
11. enter program and enter
12. enter short description
13. click on source code
14. double click on BDCREXX1.
15. click on display
16. copy all
17. Back
18. Change program name to include ZTEXT_BDCREX
19. Double click on that
20. Paste code which was copied earlier
21. Activate
22. come back
23. comment all data set statements
( one has to comment a lot performs and datasets, that depends on type of transaction being recorded)
24. Make record to be an internal table writing occurs 0.
DATA: BEGINF OF RECORD OCCURS 0.
After include, write following:
PARAMETERES: P_FILE TYPE RLGRP-FILENAME.
DATA V_FILE TYPE STRING.

Before Start-of-selection,
AT SELECTION-SCREEN ON VALUE REQUEST FOR P_FILE.

CALL FUNCTION ‘F4_FILENAME’.
EXPORTING
PROGRAM_NAME = SYST_CPROG
DYNPRO_NUMBER = SYST_DYNNR
FIELD_NAME = ‘P_FILE’
IMPORTING
FILENAME = P_FILE
25. After START-OF-SELECTION:
START-OF-SELECTION.
V_FILE = P_FILE.
And call the function ‘gui_upload’.
CALL FUNCTION ‘GUI_UPLOAD.
EXPORTING FILENAME = V_FILE
FILETYPE = ‘ASC’.
HAS_FIELD_SEPERATOR = ‘X’.
TABLE
DATA_TAB = RECORD.

26. comment DO and write LOOP at record.
27. comment ENDDO and write ENDLOOP.
28. Execute the program.
29. select call transaction radio button
30. enter processing mode as A
31. in the file name, enter the file path
32. execute

Running Bdc Program Through Session Method
1. Execute the program
2. select “Generate Session’ radio button
3. enter session name
4. tick mark “Keep Session”
5. Enter the filename
6. execute
7. goto SM35
8. Select the session click on process
9. Select background
10. Enter
11. Analysing the background session
12. SM36
13. Click on own jobs.

Scheduling Background Program
1. SM36
2. enter the jobname
3. click on step
4. enter the program name and variant name
5. check and save and come back
6. click immediate
7. start condition.save.check.

Steps to write a BDC program
1. Identify the fields
Press F1 on field, click on technical info.
2. Fill BDCDATA internal table.
BDC data structure
a. Rogram
b. Dynpro
c. Dynbegin
d. Fname
e. Fval
3. Call the transaction
Processing mode in call transaction:
- A = Display all screens
- E= Display error.
- N = Background processing
4. Update Mode
a. L = Dialog work process will update the data
b. S = Synchronous update (update work processor will update)
If 1-100 records are updated and error is in 50th record, then 1-49 will be updated.In synchronous update the sy-subrc is set to 0 only when the particular transaction is executed and also the changes have done to the database,
c. A = asynchronous update work process will update. Incase error is 50th record, then 1-49 records will be updated and 50th will logged as an error. In asynchronous update the sy-subrc is set to 0 if  the transaction is executed without any fail, not the database changes.

Difference between Call Transaction and session method.
Call Transaction Session Method
i. Synchronous Asynchronous

ii. Error needs to be handled Automatically
Manually

iii. Used for relatively less records More records

iv. No function modules are called Multiple transactions called
and used to update one transaction.

v. No session is created. Session is created.
The function modules called are:
• BDC_OPEN_GROU
• BDC_INSERT
• BDC_CLOSE_GROUP.

Dialog Prorgramming

Module Pool Programming
(Also called Screen or Dialog Programming)

Events in module pool programming:
Process Before Output (PBO)
Process After Input (PAI)
Process on Help-request (POH) – F1
Process on Value Request (POV) – F4

PBO: In this event, we write the logic to display the screen layout. Data will transfer from program fields to screen fields with identical names.

PAI: Whenever we do any operation in the screen which is associated with function code, this event will be triggered. Data will pass from screen fields to program fields.
SY-UCOMM is the only we can use PAI.

SE80 : Select PROGRAM from dropdown – enter program name – press enter
– asks for creation – press YES – make sure TOP INCLUDE check is enabled.
Delete * and enter prog name TOP.

IN SE80:
- double click on program – goto change mode – uncomment 001 and I01 include programs.
- Double click on the include programs, create and back.
- Right click on program name – create screen.
- Enter the short description
- Click on element list
- Enter ok_code - we can give any variable name but ok_code is standard.
- Click on layout.
- Click on Textbox – drag it on screen – double click textbox.
- Enter the name and text – give quick info an icon name.
- Similarly make 2 more text boxes. One for second number and one for result.
- Click on input , output box and drag it on screen.
Enter name and format.
- Click on push button, drag it on screen.
Enter name
Enter text.
- enter function code – eg- ADD
- another button for EXIT.
-Design screen. Goto flow logic.
- Uncomment the module after PAI.
Double click on the module - asks for creation - click YES.
- Select I-1 include program.

Module USER_COMMENT_I011 input
Case ok_code.
WHEN ‘ADD’.
R = A + B.
WHEN ‘EXIT’.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.

-Double click on main program.
Two types of fields:
- Screen Fields
- Program Fields
Double click on program, double click on TOP INCLUDE.

NOTE: generally in TOP INCLUDE, we declare all the global variables.
TOP INCLUDE is include at the top.
In TOP INCLUDE write:

DATA: a type I,
B TYPE I,
R TYPE I,
OK_CODE TYPE SY-UCOMM.

- Right click on main program.
- Executing module pool type of program.
- Except report programs, we cant execute any program directly by F8.
- For module pool programs, we execute by creating a TCODE: SE93.
Or
Right click on program – create – transaction.
- Enter transaction code name and short description.
- Select program and screen.
- Enter program name and screen number.
- Click on all the GUI options and SAVE.
- Click on cursor position under attributes.
- Hitting Enter will pass empty function code.
- to avoid this problem: goto screen – goto flow logic, after process before output, create a module.
MODULE CLEAR_OK_CODE.
- Double click on module, it will ask for creation.
- Select 001 include.
- In module we will write:
CLEAR OK_CODE.

Static Screen Changes.
Requirement: Make the result field as display only and the field number as mandatory.

- Double click on the screem – click on layout.
- Goto change mode.
- Double click on the first field.
- Select program tab in attributes under input dropdon – select required.
- Double click on result field, goto program tab – select output only.

OR
- Click on element list tab and change the attributes.

To create a cancel button.
- Double click on screen – click on layout.
- Click on pushbutton – drag it on screen.
- Enter the name, text and function code.
- Select function type as E.
- Click on flowlogic.
- In PAI, create a module of type:
‘at exit_command’.
- MODULE LEAVE AT EXIT_COMMAND.
Double click on module
Select I01(PAI)
-IF OK_CODE = ‘CANCEL’.
LEAVE TO SCREEN 0.
ENDIF.
- SCREEN 0 breaks the screen sequence.

In AT EXIT-COMMAND, field validation is not triggered, so it doesn’t check for fields and comes out.
In report, we do validation in ‘at selection screen’.
Display error message if user enter value A > 10.
- Double click on screen.
In PAI:
FIELD A MODULE VALIDATE_A.
Inside the module write:
MODULE VALIDATE_A INPUT.
IF A .= 10.
MESSAGE “ENTER VALUE LESS THAN 10” TYPE ‘E’.

Field statement:
We use it for single field validation, i.e. if any error occurs in the module, then the field will be enabled, other fields will be disabled

To validate a group of fields:
In this case, double click on screen.

CHAIN.
FIELD A.
FIELD B.
MODULE VALIDATE_A.
ENDCHAIN.

- DYNAMIC SCREEN MODIFICATIONS:
When user click on add, display only result field.
Double click on screen.
Uncomment module after PBO or write a module,
Double click on module.
Select o01.

CASE ‘OK_CODE’.
WHEN : ‘ADD’.
LOOP AT SCREEN.
IF SCREEN-NAME = ‘A’.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDCASE.
ENDMODULE.

SCREEN is an internal table defined by the system which contains the field attributes or the screen attributes.

To disable a group of fields, double click on screen, goto layout – double click on fields whose attributes we want to change.
Enter a group name in first input box of groups.
Eg – GR1.
In LOOP AT SCREEN.
Instead of screen-name , can write screen-group1 – ‘GR1’.

TABSTRIP Control.
- Create a module pool type of program.
2 includes will be added automatically PBO and PAI.
- Create a screen.
Enter screen number, short secription.
Goto element list – enter OK_CODE.
- Click on layout
- Click on Tabstrip control – drag it on screen.
- Double click on tabstrip control.
- Enter the name.
- If more than two tabs are required, change the tabtitle
( by default two is the value)
- Double click on tab1.
Enter the name, text and function code.
Color is red for fields i.e. the information is mandatory to be filled.
- Click on Subscreen Area – Drag it on screen.
- Double click on other tab and do the same.
- Click on flow logic:
- Now we need to design subscreens ( that are assigned to tabs).
- Right click on program – Create screen
OR
Goto screen – other object – enter screen number and enter create.
- Short description , Add subscreen.
- Select Subscreen radio button
We will see OK_CODE is not enabled. By default for subscreen.

- After designing the subscreen layouyt, goto flow logic. Uncomment module of PAI.
- Double click on TOP INCLUDE and write following in TOP INCLUDE.
DATA : A TYPE I,
B TYPE I,
R TYPE I.
CONTROLS TAB TYPE TABSTRIP.

Double click on main screen.
Flowlogic:
PBO: Process Before Output.
CALL SUBSCREEN ADD_REF1 INCLUDING ‘ZTABSTRIP’ ‘1011’.
CALL SUBSCREEN MUL_REF1 INCLUDING ‘ZTABSTRIP’ ‘1012’.

PAI : Process After Input.
CALL SUBSCREEN ADD_REF1.
CALL SUBSCREEN MUL_REF1.

Double click on module command.
In main program:
MODULE USER_COMMAND_1010 INPUT.
CASE OK_CODE.
WHEN ‘ADD’.
TAB-ACTIVE TAB = ‘ADD’.
WHEN ‘MUL’.
TBA-ACTIVE TAB – ‘MUL’.
EBDCASE.
ENDMODULE.


TABLE CONTROL:
Create a module pool program.
We will try including screen in report program.
So create a report program:
REPORT ZTEST_TABLECONTROL.
START-OF-SELECTION.
CALL SUBSCREN 1010.
- double click on screen.
- click on element list – enter OK_CODE.
- goto layout – click and drop table control.
- double click on table control.
- check vertical and horizontal separators.
- click on dictionary / program fields ( red button at top) or press F6.
- Enter the table name – select fields and click OK.
- Again F6. Select fields that we want.
- Put it on fields.(drag n drop at the header area of table control.
- Click and drag Push button : make two of them – DISPLAY and EXIT.
- Click on Flow Logic. Write following:
PROCESS BEFORE OUTPUT.
LOOP AT IT_VBAP WITH CONTROL TABLE.
MODULE TRANSPORT.
ENDLOOP.

PROCESS AFTER INPUT.
LOOP AT IT_VBAP.
….
ENDLOOP.

MODULE USER_COMMAND 1010.
CASE ….

ENDCASE.

- Double click on MODULE TRANSPORT – include main program.
Main program:
REPORT ZTEST_TABLECONTROL.
TABLES VBAP.
DATA: OK_CODE TYPE SY-UCOMM.
CONTROLS TABLE TYPE TABLEVIEW USING SCREEN 1010.
TYPES: BEGIN OF TY_VBAP,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
ARKTX TYPE VBAP-ARKTCX,
NETWR TPE VBAP-NETWR,
KWMENG TYPE VBAP-KWMENG,
END OF TY_VBAP,
TY_T_VBAP TYPE TABLE OF TY_VBAP.
DATA: IT_VBAP TYPE TY_T_VBAP,
X_VBAP TYPE TY_VBAP.
START-OF-SELECTION.
CALL SCREEN 1010.
PROCESS BEFORE OUTPUT.
LOOP AT IT_VBAP INTO X_VBAP WITH CONTROL TABLE.
MODULE TRANSPORT.
ENDLOOP.

PROCESS AFTER INPUT.
LOOP AT IT_VBAP.
ENDLOOP.
MODULE USER_COMMAND_1010.
MODULE TRANSPORT OUTPUT.
MOVE-CORRESPONDING X_VBAP TO VBAP.
ENDMODULE.

MODULE SELECT_DATA OUTPUT.
IF VBAK-SEL = ‘X’. “We can add desired logic
ENDMODULE.

MODULE USER_COMMAND_1010_INPUT.
CASE OK_CODE.
WHEN ‘DISPLAY’/
DATA FILL TYPE SY-TABIX.
SELECT POSNR MATNR ARKTX NETWR KWMENG
INTO TABLE IT_VBAP FROM IT_VBAP
WHERE VBELN = VBAP-VBELN.
DESCBRIBE TABLE IT_VBAP LINES FILL.
TABLE-LINES = FILL “ to make table control scrollable.
WHEN ‘EXIT’.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.

Wednesday, January 7, 2009

Function Modules

FUNCTION MODULES

Repeatedly done piece of codes doing specific tasks can be put into global place.
Stored in R/3 repository.

Creating Function Module:
Requirement: Pass A, B values, get results.

For function modules, we must have function groups.

Creating Function groups
Goto SE 80

Function group contains function module(s) as wel as global data which is used by the function modules.
Global data is stored in TOP INCLUDE of function group.

Goto SE80
Open function group – double clock on it
Click on main program.
Double click on TOP INCLUDE.
Declare variables.
Goto SE37. Enter module name, click on create.
Enter function group name and short description.

Click on Attributes
NOTE: There are 3 types of function modules:
1. Normal – Used for modularization purpose.
2. Remote Enabled – Used to call function module from another server.
3. Update modules. Used to update the database by using the update work processes.
We should use update more often.

Click on IMPORT.
Enter the cariables which are used by the function modules and for which values will come from main program.
NOTE: We can not change input parameter value.

Click on EXPORT
Enter variables which will be passed to main program.

Click on changing
Changing parameters’ value can be changed.

Click on Tables
Here we pass the internal tables.
If more than one table is updating internal table, we can create a structure and define internal table of type structure.
Structure can be defined in source code or TOP INCLUDE.

Click on Source Code
Write the logic.

Callin function modules in the main program.

Create an executable program.

To call the function module: Place cursor where we want to call the function module, click on Pattern ( ctrl + F6)
Enter function module name.

Exception handling in function modules
Open function module in change mode, click on exceptions tab.
Enter exception name. ( eg – RAISE_EX 0)
Goto source code
IF b =0.
RAISE RAISE_EX 0.

Whenever we call the function module for the first time, the total function group will be loaded into the runtime environment along with the global variables.
Function module called twice will be loaded once and used again.
Above is the major difference between function modules and object oriented programming.
Otherwise, function module , like OOPs, also do encapsulation.


Analyzing Short Dump
GOTO tcode: ST22
Click on today or whatever time the error occurred.

Double click on source code extract and system will take us to the line where error has occurred.

Reporting events

REPORTS

In a report we can have any number of initialization of in that case – any event any number of times.
It will collect all same types of events together and execute them together.



Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAM TITLE TEXT-001.
PARAMETERS : A TYPE I,
B TYPE I.
SELECTON-SCREEN END OF BLOCK BLK.
SELECTION-SCREEN BEGIN OF SCREEN 1010.
PARAMETER R TYPE I.
SELECTION SCREEN END OF SCREEN.

INTERACTIVE REPORT
Interactive events
1. AT USER-COMMAND
2. AT LINE-SELECTION
3. AT PFn (obsolete)

Creating Menu Painter
Event for menu painter:
AT USER-COMMAND.
System field is sy-ucomm.
SY-UCOMM is a system field which contains the function code.

CREATING MENU PAINTER

1. Create an executable type of program.
2. PARAMETERS : A TYPE I,
B TYPE I.
DATA: R TYPE I.
AT SELECTION-SCREEN ON A.
IF A < B.
MESSAGE ‘ENTER A VALUE GREATER THAN B’ TYPE e.
ENDIF.
START-OF-SELECTION.
WRITE: /A,B.
WRITE: / ‘CHOOSE THE OPERATION FROM THE MENU’.
SET PF-STATUS ‘STATUS’
Now double click on STATUS. Will ask for creation- continue
Click on + sign in menu bar.
Enter TEXT – CALCULATOR’ and double click.
Enter the code and text
Add Addition
Sub Substraction
Activate
Come back to the main program

AT USER-COMMAND.
CASE: SY-UCOMM.
WHEN ‘ADD’.
R = A+B.
WHEN ‘SUB’.
R = A-B.
ENDCASE.
WRITE: /R.

Creating sub-menu
For sub-menus, we will not have the function codes in the main menu.
Double click on PF-STATUS.
For sub-menus – Enter TEXT only and double click on text.
Enter Fn code and text. MUL MULTIPLY
DIV DIVISION.
We can nest upto 3 levels.
To add separator – Edit – Insert – Separator
Right click – Insert – Separator.

Creating Standard toolbar.
The available ones can be disabled or enabled.
Click on plus sign nearby function keys.

Creating Application toolbar
for often used applications.

Enter the function code, double click on function code, assign function keys.

Disabling Menu Option.
DATA: IT_COMM type table of sy-ucomm.

At USER-COMMAND
CASE : SY-UCOMM.
When ‘ADD’.
REFRESH IT_UCOMM.
APPEND ‘ADD’ TO IT_UCOMM.
R = A + B.
..
..
..
WRITE: /R.
SET PF-STATUS ‘STATUS’ EXCLUDING IT_UCOMM.

For user defined title:
SET TITLE BAR ‘TITLE BAR NAME’.
DOUBLE CLICK ON TITLE BAR NAME.
Enter title bar description.
In pop-up box enter text
Click on ALL TITLE.
ACTIVATE.

INTERACTIVE REPORT
AT LINE-SELECTION.
Requirement: Display the sales order details when user double clicks on particular sales order display VA03 transaction code

DATA: IT_VBAK TYPE TABLE OF VBAK WITH HEADER LINE.
DATA: V_VBELN TYPE VBAK-VBELN, V_FIEL TYPE STRING.
SELECT-OPTIONS: S_VEBELN FOR VBAK-VBELN.
SELECT * FROM VBAK
INTO TABLE IT_VBAK
WHERE VBELN IN S_VBELN.

LOOP AT IT_VBAK.
WRITE: /IT_VBAK-VBELN , IT_VBAK-AUART, IT_VBAK-AUDAT.
ENDLOOP.

AT LINE-SELECTION.
GET CURSOR FIELD V_NAME VALUE V_VBELN,
IF V_FIELD = ‘IT_VBAK-VBELN’.
SET PARAMETER IF ‘AUN’ FIELD V_VBELN.
ENDIF.

To find out the Prrama-ID for order number – press F1 m then click on Technical Info.

HIDE statement:
When we use the HIDE statement, system will store the values of the field which is written in hide in HIDE area.
HIDE can hold any number of values.

Internal Table and its operations, Control Statements, Selection Query

Dataobject declaration in program:

DATA: str_NAME TYPE/LIKE DDIC STRUCTURE / PREDEFINED.
example:
DATA X_MARA TYPE MARA. “MARA is a DDIC table
DATA X_NAME LIKE NAME.
“NAME is a dataobject declared in the current “program.

INTERNAL TABLES:

They are temporary memory buffers in the application server which can hold multiple records.
Internal tables are active till the program is running. Once the program ends, memory will be released / internal tables are erased.


Internal Tables are of two types:
1. Index
- Standard
- Sorted
2. Hashed (One which follows the hash algo)

In order to work with individual records of the internal table, we need to have a structure of same size and type as internal table and that structure is called as field string or work are of header line.

DATA: BEGIN OF IT_SO OCCURS 0,
SONO TYPE VBAP_VBELN,
ITM TYPE VBAP-POSNR,
MATERIAL TYPE VBAP-MATNR,
QTY TYPE VBAP-KWMENG,
END OF IT_SO.

The above code will create:
1. a work area having four fields: SONO, ITM, MATERIAL, QTY
2. an internal table similar to work area.

At any point IT_SO will point to work are and not internal table because we can not point to internal table.

IT_SO-SONO = ‘5000’.
IT_SO-ITM = ‘10’.
IT_SO-MATERIAL = ‘M-09’.
IT_SO-QTY = ‘7’.
APPEND IT_SO.

IT_SO-ITM = ‘20’.
IT_SO-MATERIAL = ‘M-02’.
IT_SO-QTY = ‘11’.
APPEND IT_SO.
WRITE: IT_SO-SONO,
IT_SO-ITM,
IT_SO-MATERIAL,
IT_SO-QTY.
ENDLOOP.

Filling the Internal Table

Syntax: APPEND WA TO ITAB.
In earlier example :
APPEND IT_SO TO IT_SO.
OR
APPEND IT_SO.

Looping through internal table.
LOOP AT IT_SO INTO WA [where condition].
….

….
ENDLOOP.

In place of above, we can write:
LOOP AT IT_SO.
….


ENDLOOP.
“Above can be done provided the internal table has OCCURS 0 (or any other number in place of 0) as addition while declaration.

OCCURS 0. This addition allots 8KB of memory
OCCURS 10. Memory for 10 records is allocated.
OCCURS 5. Memory for 5 records is allocated.
SAP says in ECC 6.0 occurs has become obsolete as SAP system needs to take overhead of memory allocation.

DATA: ITAB type/like table of x [WITH HEADER LINE].


TYPES: BEGIN OF TY_SO, “User defined structure type
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
KWMENG TYPE VBAP-KWMENG,
END OF TY_SO,
TY_T_SO TYPE TABLE OF TY_SO. “User defined table type
DATA: IT_SO TYPE TY_T_SO,
X_SO TYPE TY_SO.

Fetching data from database.

SELECT *
INTO TABLE ITAB
FROM DATABASE_TABLE
WHERE CONDITION.

Structure of the internal table should be same or higher than that of fields specified in the select statement.
The sequence of fields should be same otherwise use:
1. SELECT * INTO…
2. SELECT F1 F2 INTO CORRESPONDING FIELDS OF TABLE ITAB…
But both of the above options should be avoided due to performance reasons.

SELECT A~F1 A~F2 A~F3
B~C1 B~C2 B~C3
INTO TABLE ITAB
FROM DBTAB1
AS A INNER JOIN DBTAB2 AS B
ON A ~ CF = B ~ CF
WHERE CONDITION…
*DBTAB1 and DBTAB2 are database tables
*A is alias name for DBTAB1
*B is alias name for DBTAB2
*F1, F2, F3 are fields of DBTAB1
*C1, C2, C3 are fields of DBTAB2
* CF is the common field in DBTAB1 and DBTAB2

One can bring all fields of structure together through PATTERN button.

Selection Table: Its an internal table with the fields:
SIGN – Include / Exclude
OPTION – BT NB GT LT GE
LOW – Low Value
HIGH -- High Value

Declaring selection fields table:

SELECT-OPTIONS: S_VBAK FOR VBAK-VBELN.
Syntax: SELECT-OPTIONS VAR FOR X_VAR
[OBLIGATORY] [LOWER_CASE]
[DEFAULT ‘’ TO ‘’]
[NO-EXTENSION]
[NO-INTERVALS]

We need to add TABLES: VBAL only for the tables used in SELECTOPTIONS
(in earlier versions, it used to be for all the tables used in the program).

Operations with internal table:
Reading single Records:
READ TABLE ITAB INTO WA
[INDEX|WITH KEY CONDITION]

READ TABLE IT_VBAKVBAP INTO X_VBAKVBAP INDEX 7.
IF SY-SUBRC = 0.
….
..

ENDIF.
SY-SUBRC is a system field which contains return code of previously executed statement.
If 0, it means atleast one record was read for the selection query.

READ TABLE IT_VBAKVBAP INTO X_VBAKVBAP
WITH KEY VBELN = ‘5006’
POSNR = ‘10’.

MODIFY TABLE
MODIFY ITAB FROM WA
[INDEX I | WHERE CONDITION]

READ TABLE IT_VBAKVBAP INTO X_VBAKVBAP INDEX 4.
IF SY-SUBRC = 0.
X_VBAKVBAP-KWMENG = X_VBAKVBAP-KWMENG + 8.
MODIFY IT_VBAKVBAP FORM X_VBAKVBAP INDEX Y
TRANSPORTING KWMENG.
Sorting Internal Table
SORT ITAB BY F1 [ASCENDING / DESCENDING]
F2 [ASCENDING / DESCENDING]
….


[AS TEXT]

By default it is ASCII , AS TEXT addition makes it otherwise.

DELETING INTERNAL TABLE
1. FREE - FREE ITAB. “deletes contents of internal table and releases memory
2. REFRESH – REFRESH INTERNAL TABLE. “Deletes content only, memory remains as it is.
In both above cases, work area will not be affected( in case there is a header line).
3. CLEAR – CLEAR ITAB. “Clears only work area
-- CLEAR ITAB[]. “ clears only the internal table

CONTROL BREAKS

1. AT FIRST….ENDAT
LOOP AT ITAB.
AT FIRST.

….
..
ENDAT.
ENDLOOP.
This will be triggered for the very first loop pass.
We can use for table headers.
Inside AT FIRST, ENDAT – character values will be changed to **, rather numeric values will be changed to 0.
2. AT LAST….ENDAT.
LOOP AT ITAB.
AT LAST.

….
..
ENDAT.
ENDLOOP.

Used for last loop pass. Used for table footers.
3. AT NEW…ENDAT.
LOOP AT ITAB.
AT NEW.

….
..
ENDAT.
ENDLOOP.

AT NEW will be triggered:
- for very first loop pass.
- when the content of control label changes.
- when left side fields of control label changes.
- inside AT NEW and ENDAT, the contents of work area will be changed as follows:
Left side fields and control labels remain as it is rather the right side field will be change to * and 0s based on character and numeric.
4. AT END OF ..ENDAT.
- This will trigger when the control label value changes.
- For the last loop pass.
- When the left side field of control label changes.
Values of work area will be changed same as AT NEW.
5. SUM.
The statement will sum the quantity field value for the corresponding control label and the summed value will be stored in the work area’s quantity fields only.
6. ON CHANGE OF... ENDON.
Triggers on change of the particular control label.

Tuesday, January 6, 2009

Debugging

Wherever we want to stop the execution and shift to debugger.
Write statement:
BREAK-POINT.

In fields, enter the variable name.
For single line execution , press F5.
For executing the program or to reach the next breakpoint, press F8.

To cancel debugging – Goto Menu – Debugger – Debugging Off.
In order to change the value in debugging mode, change values and click on change field contents (pencil icon).

F5 – next line
F6 – To skip the analysis of execution of perform rather than execution of perform.
F7 – If the current pointer is inside the function or perform, to come back to main program.

To set a user specific breakpoint, we use : BREAK USER.
BREAK USER is a hard breakpoint.
For soft breakpoint, click on STOP.

Ways to start debugger:
- Hard Breakpoint.
- Enter TCODE ‘/h ‘ before F8.
- Adding soft breakpoint.
- Adding watchpoint.

String Operations

STRING OPERATIONS:

In case of string operations, no space between operators.

Split and concatenate
Data: V

DATA : V_D1(10) type c,
V_D2 LIKE V_D1,
D_DD(2) TYPE N,
V_MM(2) TYPE N,
V_YR(4) TYPE N.
V_D1 = ‘27/07/2008’.
SPLIT at ‘/’ V_D1 into V_DD V_MM V_YR.

CONCATENATE V_YR V_MM V_DD INTO V_D2 SEPARATE BY ‘.’.

Programming basics

Write Statement:

Write ‘SAP’.

Write ‘Bangalore

Write ‘India

Output: SAPBangaloreIndia

/ or Skip is used to go to next line for printing

WRITE / ‘Bangalore’.

Semicolon is chain operator.

One is saved from the hassle of writing same command again and again by using chain operator.

Write : ‘SAP’,

/ ‘Bangalore’,

/’India’.

Write ‘SAP Labs’ color 7.

Makes the background will be colored.

Write ‘SAP Labs’ color 7 inverse on.

Only the letters will be colored.

Dataobjects:

  1. Modifiable

- Character:

C Character

N Numeric

D Date

T Time

X Hexadecimal

S String

- Numeric:

I Integer

F Float

P Packed decimal

  1. Non Modifiabale

- Constants

- Literals

For character, numeric and packed, it is mandatory to define the size, for others it is optional.

Declaring Variables:

Data Var(size) type t [decimals d][value 11]

Eg:

Data name (10) type c.

Data roll(3) type n.

Data doj type D value ‘20081007’.

Data per(3) type P decimals 2.

Parameter Var(size) type t

[decimals d]

[obligatory]

[lower case]

[default]

Parameters P_name(10) type C obligatory lower case.

Write: / P_name.

Syntax :

Write : / P(n) ‘ ‘ color n Inverse on.

Where P is the offset position and n is no. of characters.

Write: / 7(3) ‘SAP’.

In data we have value and in parameters we have default as an optional addition to provide initial default values.

Creating a Program:

SE38 – Enter a program name – Create (F5) – Enter Title

Type is executable type.

Single line comments should start with * in the first column.

In ABAP editor, after Report Statement – write the code.

Save Check and Activate after writing the code.

F8 to execute.

By default standard page header contains:

Program name, page number and under line.

In order to suppress default page header:

After report name: write following

NO STANDARD PAGE HEADING.

To comment from middle of line use “.

Write: v_name centered,

/ v_turn centered,

/ sy-datum left-justified,

Uline.

To underline sy-uline

Sy-vline- for vertical line.

Standard selection screen number is 1000.

Search Help

SEARCH HELP:

-SE11 -Search Help –Names –Create – Elementary Search Help- Short Description.

In Selection methods, enter a table or view.
We cant enter here maintenance view.

In Search Help parameter, enter the field names.
Select check box – importing and exporting.
First Line LPOs = 1, SPOs = 1
Second Line LPOs = 2, SPOs = 2
…and so on…
-Save Check and Activate.

ATTACHING SEARCH HELP TO THE TABLE:

Open the Table in change mode
Place cursor where you want to create F4 help.
Click on search help button.
Enter the search help name and press enter (copy).
Save Check and Activate.


Dialog Type:
1. Display values immediately: As soon as F4 is pressed, values will be displayed.
2. Display values with restrictions: As soon as F4 is pressed, restriction box is displayed.
3. Dialogue depending on set of values: In this option, if number of values is less than 100, it behaves as display values immediately, if more than 100, behaves as dialogue with value restrictions.

Importing – Values are copied from screen to search help
Exporting – Values are copied from hit list to screen fields.

If we have two fields in F4 Plant and Material:
For locking we can see: Plant is not copied, rather material is copied, but user can choose material based on plant.
SPOs – Position of field in hitlist
LPOs – Position of field in restriction box.

Activation – When we activate any object, a series of SQL statements will be generated which will trigger database to create object in database.

Lock Objects

Lock Objects: Are used for synchronizing the access by multiple users for a single object.

Lock Objects start with ‘e’
Whenever we activate lock objects ( eg : EMARA), automatically two function modules will be created:
1. Enqueue_EMARA to lock the object
2. Dequeue_EMARA to release the lock.

SM12 is the transaction code to analyze the locks.

Creating Lock Objects:

- SE11 - Select lock object radio button – Enter lock object name (eg – emara)
- Enter short description – Enter Primary table name – enter lock mode
– enter secondary tables.

example - While creating Sales Order, MM02 should not change the material attributes.

Whenever we do changes to an object, there are other dependent objects which should not changed by any other objects.

Click on Lock Parameter – all key fields will appear, we can change it.
Save Check and Activate.
Automatically system gives two function modules.

Order of a lock mechanism:
Lock
Read
Change
Release

Structures

STRUCTURES: It is a group of logically related fields.

Difference between Structure and tables
- Table contains data, structure doesn’t contain data.
- Table must have key fields, structure doesn’t require key fields
There are two types of Structures:
- Include Structure
- Append Structure

Creating Structures:
1. SE11
2. Select Datatype radio button
3. Enter Structure name
4. Click on create
5. Select structure radio button
6. Enter short description
7. Components tab – enter field names, component type enter data element
8. Save Check and Activate

Including a structure: Can be included in any number of tables.
Appending Structure:
- Open a table in change mode
- Click on append structure button
- System proposes a name which we can modify.
But the name should start with Y or Z.

Append structure is always done at the end of structure.

Generally naming convention for fields of append structure are starting with ZZ.

If we have a table with Lchar (long character) as a field datatype, it append at last of the table, we can not have append in that case.

• Include Structure are pre-planned.
• Append Structures are not pre-planned.
• Both are part of enhancements.

Views

Views: They are virtual tables.

  1. Projection View (can make changes if the view contains a single table).
  2. Database View (one or more than one table) using inner join

When we create a database view on more than one table, we can not change the underlying table values by using the view.

  1. Maintenance View

- Uses outer join

- It allows changing values in the underlying tables.

  1. Help View

- Uses Outer Join

- Uses for F4 help

Creating Projection View:

  1. Go to TCODE SE11
  2. Select Radio Button
  3. Enter View Name
  4. Click Create
  5. Select Project View Radio Button
  6. Enter Short Description
  7. Enter Basis Table (Database Table)
  8. Click on Table Fields
  9. Select the required Fields
  10. Select Maintain Status Tab.
  11. Read and Change.

Creating Database View:

  1. Go to TCODE SE11
  2. Select Radio Button
  3. Enter View Name
  4. Click Create
  5. Select Database View Radio Button
  6. Enter Short Description
  7. Enter Basis Table (Database Table)
  8. Enter Table Name in tables column
  9. Click on relationship
  10. Select relationships and click on copy.

Between 2 tables can select only one relationship.

  1. Click on View fields
  2. Click on table fields
  3. Select a table and click choose
  4. Select fields of table and enter.
  5. Do same for other table.
  6. In select conditions tab: Enter condition based on which need to be displayed.
  7. Save, Check and Activate.

NOTE: Check Table is Foreign Key Table.

Maintenance View: Create same a database view. But after activating, we need to create table maintenance generator.

We can write selection query using common fields also ( foreign key fields are never mandatory).

HELP VIEW: Similar to database view.

Wednesday, December 10, 2008

Data Dictionary - Introduction

Data Dictionary

The ABAP/4dictionary is central workbench repository utility providing the data definition and the information relationship that are later used in all the business application within R/3

The ABAP/4 dictionary can be seen as a logical representation or a superior layer over the physical underlying database. This database must support the relational data model. This model is strictly followed by data dictionary.

About Data Dictionary
A Data dictionary in computing terms is the source of information in which system data is defined. The data dictionary is the centralized and structured source of information for business applications. You can say that it is core of a well-structured development environment.

The elements that make up a dictionary are known as metadata. Metadata is the term for the data whose function is to describe other data. Data in dictionary is not the actual data like emp. name or emp. address but rather a type of data whose function is to define the properties of the data such as type, length, and relationship.

Advantages
Advantage of using data dictionary is avoiding inconsistencies when defining data type that will later be used in different applications. This avoids redundancies.

When a type is defined in the dictionary, it is available to any program in the application. A change in the definition of a type of data in the dictionary automatically affects any other data or program, which has this data.

Again, data dictionary is a fast and efficient way to answer questions such as which entries exist in a table of the database, what the structure of table is.


Activation of dictionary objects

For a dictionary object to be effective at runtime, that is, for a dictionary object to be available for use within a program, transaction, and so on, it must be in active status. For objects to become active, R/3 includes the ACTIVATION function.

When a table or aggregated object is activated, it is placed at the disposal of the system as a runtime object in a way that makes it available quickly for the application program to access relevant information of new activated objects.

When a dictionary object is modified, that means that the object previously existed and activated. You need to reactivate the object after modification.

When mass activation is performed massively, it might take a quite a long time. Then it should be in the background system. This type of activation is known as background activation.

The ABAP/4 Data dictionary is the central component of ABAP/4 repository. A Data dictionary is centralized and structured source of information for business application. The ABAP/4 dictionary is the core of the R/3 development system. It is the source of every definition, within R/3, from the very basic domain to the company data model. It is totally integrated with other tools of the development environment like screen painter, menu painter, and editor.

Some of the main available functions in the ABAP/4 dictionary are as follows:

• Add, delete, modify, and manage the definition of the dictionary data.
• Preserve the data integrity.
• Be the central source of information e.g. from the dictionary you get the information about the defined relationship between two tables or even the directory tells whether table is active or empty.
• It also permits documentation of system data.

In the R/3 system instead of working with original objects, you work with internal representation of objects. With this type of operation the system performance is enhanced and has the advantage that the development tools, screen interpreters always access current data.

When any of the data dictionary objects are used in other parts of the development workbench for example, in program, programmer only has to enter a table name or field name. The system automatically knows all the properties and information of the field.



To call ABAP/4 dictionary, from the main menu, Tools  ABAP/4 workbench  data dictionary or enter transaction SE11.


Data dictionary objects:

• Table: is a 2D data matrix containing rows and columns. Rows contain data while column indicates fields. Table can contain 0 or multiple rows.
• Structure: is a skeletal view of a table. It contains the definition of columns and don’t have any contents. Structure is generally a template based on which a table is created. The basic difference between structure and table is that the structure does not exist at the underlying database system level. Structure exists as definition in the dictionary.
• Views: A view is an imaginary table. It contains data, which is really stored in other tables. The contents for the view are dynamically generated when called from program.
• Data element: is definition of the properties and type for a table field. It is an intermediate object between the object type domain and the table field. A field in R/3 system is always associated with a data element, which at the same time is related to domain.
• Domain: is formal definition of the data type from a technical point of view. It sets the attributes such as data type, length, possible value range and so on.
• Lock objects: These types of objects are used for locking the access to database records in table. This mechanism is used to enforce data integrity that is two users cannot update the same data at the same time. With lock objects you can lock table-field or whole table.
• Search Help Objects: , which gives list of possible values for either primary keys or non-primary keys.


Tables in ABAP/4 dictionary

Tables are the basic objects in R/3 application. There are almost 8000 tables in R/3 system. Following types of tables are available

• Transparent tables
• Pool tables
• Cluster tables

From user point of view, all tables are used to store data whatever be the type of table. There is no difference in the behavior or operation of these tables. All of them can be managed by using standard OPEN SQL. However from an administrator point of view transparent table do exists with the same structure both in the dictionary as well as in the database, exactly with the same data and fields. While other two are not transparent in the sense that they are not manageable directly using database system tools. You can access these tables in R/3 environment from the ABAP/4 dictionary. You cannot use native SQL on these tables. Pool or cluster tables are logical tables, which are arranged as records of transparent table.

A table is made up of rows and columns. When the table is created, its columns are named; data type is supplied for each column. There can be only one data value in each column of each row in a table. Record or as it is called in different RDBMS is nothing but group of fields. While a column is a field of a table, a table is an indexed file. The main index is called as primary key, which can be a single field or combination of keys or fields. A primary key can be defined as a field, which indefinites a single unique record of the table. A table cannot have record with duplicate primary key.

In any RDBMS, tables are related to each other. But to relate table to each other it is necessary that one of the tables contain some information of other table. Mostly tables are related to each other through primary keys. The primary key of one table, if it exists in other table then it is called foreign key. This type of database management system means that there is some redundancy of data. But using normalization procedures available can minimize it. One of the most important functions of foreign key is to ensure data integrity. For example say you have EMP table, which has fields: emp. no., emp.name, dept.code, salary and you have DEPT tables, which has dept.code and dept.desc. Then in DEPT table dept.code is primary key while dept.code in EMP table is foreign key. If you enter dept.code for particular employee in EMP table the dept.code should exist in DEPT table. System will check the value for dept.code in DEPT table, and if does not exist then will flash error. In this case DEPT is called check table while EMP is foreign key table.