Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Abap Steps

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Author: Sumeet .B.

Patil
mr.patilsumeet@gmail.com
odigotech

1) Steps to create Domain.

SE11 -> Select Domain radiobutton -> Specify name of the domain starting
with Z or Y -> Create -> Enter short description -> Select data type ->
Enter length -> Save -> Activate.

2) Steps to creating a data element:

SE11 -> Select Data Type radiobutton -> Specify name of the data elementstarting with Z or Y -> Create -
> Enter short description -> Select 'Domain'radiobutton -> Specify name of the domain you created
previously -> PressEnter -> Save -> Activate -> Come back.
Create a table with the same navigations. Select 'DATA ELEMENT'
PUSHBUTTON from the Fields tab button.
Enter field name -> Select the checkbox of initial field to declare it as a
primary key -> Specify data element name -> Press Enter.

3) Steps to create a database table(ztable in SE11)


table creation:

Enter t-code se11

Database table

Type table name

Create

Type short description

Delivery class (there r seven delivery classes) – click

Select A (application table, master transaction data)

Select check box

Click on fields tab

You can write fields names


st
Select key & int checkboxes (1 filed must,
should be primary key)

Click on the data element/direct type

Then data type will be enabled


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Enter data & length


Place at cursor at sal (if ur write Sal then ) & click
on currency/quant fields

(Sal asks reference table i.e. same table name & ref field is Sal type.)
Click on fields

Save(ctr+s)

local object

click on technical settings

type data class(APPLO)

click (bcoz A is master data so data class is APPLO)

size category 0

save

back(F3)

activate ( ctr F#)

to add records utilities – table contents – create entries

then you can type records

save

reset & store another records

back

to display the records utilities – tale contents – display

********************************************************
st
[*] (1 data should be NUMC,if we gve another
like INT then buffering is not possible)[*]
(if activation log error comes then goto
utilities—database utility—click on activate—adjust database—click on yes—back)[*]
after display the records select the record—goto table
entry—change (here allows the changes the contents,save & back)[*]
(delete all ,it delets all slected records)[*]
(delete,it deletes one record)[*]
(transport entries,it sends to other person internet or
intranet or within R/3 to other user)[*]
to add 1 more field then click on rows then it allows
to rite another field[/list]
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

4) Steps to create a Append structure.

Below are step by step how to create append structure in SAP tables.
In this blog, I use my case where three new fields will be added into SAP table LIKP (Delivery Header
Data).

1. Using Abap Table Maintenance (transaction code SE11), display table LIKP. No need to change the
table. Just display!

2. In the table contain screen, click “Append Pushbutton” to add append structure.

3. It will rise pop up window contains created append structure object that ready to be assigned. On the
pop up window, click “Create Append” button.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

4. Input the append structure name and choose Enter. The name must lie in the customer namespace
(should begin with ZZ or YY).

5. On the Structure/Table maintenance screen, define the fields or component the build the structure. In
this screen, what we do here is same as like we create normal structure or tables. We can create foreign
key or search help attachment.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

6. Last action, save and activate it.

The table will also be activated when the append structure is activated. The fields of the append structure
are appended to the SAP table in the database.

5) To create a main package:

(Go To se21--> Enter name--->click CREAT--->Fill the attributes ---->Save---> Give the Transport
request.)
1. Open the Package Builder initial screen (SE21 or SPACKAGE).
2. In the Package field, enter a name for the package that complies with the tool’s Naming
Conventions
Within SAP itself, the name must begin with a letter from A to S, or from U to X.
3. Choose Create.
The system displays the Create Package dialog box.
4. Enter the following package attributes:
Short Text
Application Component
From the component hierarchy of the SAP system, choose the abbreviation for the application
component to which you want to assign the new package.
Software component
Select an entry. The software component describes a set of development objects that can only be
delivered in a single unit. You should assign all the sub-packages of the main package to this
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

software component.
Exception: Sub-packages that will not be delivered to customers must be assigned to
the HOMEsoftware component.
Main Package
This checkbox appears only if you have the appropriate authorization (see Prerequisites).
To indicate that the package is a main package, check this box.

5. Choose Save.
6. In the dialog box that appears, assign a transport request.

OR

2) Go to SE80 -> Edit Object (button) -> Development Coordination Tab -> Enter Package name and
then press the create button

6) Steps to create subpackages

You can add packages to a parent package in two ways. You can
● create new sub-packages from within a parent package
Or
● add existing packages to a parent package.
To create new sub-packages to the parent package:
...
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

1. Choose the Subpackages tab in the package builder OR right click on the parent package
name in the SE80 object list.
2. To create new sub-packages, choose the Create button in the Package Builder or choose
Create->Development Coordination->Package from the SE80 tree.
The system displays the Create Package dialog box.
3. Enter attributes for this package.
Enter a name for the package that complies with the Naming Conventions for Packages. Within
SAP itself, Basis package names must begin with S; other packages must begin with a letter
from A to R, or from U to X
4. Confirm your entries.
5. Repeat steps 1-4 for any other sub-packages you want to create.
6. Choose Save.
To add existing packages to a parent package, choose the Add button from within the Subpackages tab
and enter the name of the package.

7) How to create a Foreign Key in SAP table?

=> The purpose of the foreign key is to validate the data that is being entered into a
table by checking entries in a check table. Foreign keys are checked by the front end user
interface only and it is not checked if you issue a direct a SQL statement to update the
database.

Follow the steps given below to create a foreign key in SAP table.
Step 1: Open the table in Data Dictionary (SE11) for which you want to create a foreign
key. Select the field for which you want to create the foreign key and press Foreign Keys
button.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Step 2: In the popup window enter the check table name and press Generate proposal
button.

Step 3: The system proposes the foreign key relation based on the domain. Check that the
foreign key relationship proposed by the system is correct and press copy.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Foreign key is created, now save and activate the table. To check the foreign key go to
menu path Utilities->Table Contents->Create Entries.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Try to create an entry in “Zemployee” table with “Department ID” that is not there in the
“Department” table. Enter the values and try to save the entry.

Observe the error message in the status bar. The user interface does the foreign key
validation before creating the entries.

7) Creating a Structure in ABAP Dictionary

Go to transaction SE11 and select the radio button “Data type”. Enter a structure name starting with Y or
Z.

Press create button.

A pop-up screen appears with 3 different options. Select the radio button structure.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

The screen will be displayed like this.

Provide the description and also components.

Then press SAVE, CHECK and ACTIVATE.


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Structure Created Successfully.

8) Steps for creating an elementary search help :

Here are the steps for creating an elementary search help :

Creation of Elementary Search Help:

The creation of an elementary search help is described below with example.

1. Open TCode – SE11 for DDIC objects -> select the radio button for Search helps -> give the name of
the search help you want to create, ex – ZSH004.Click on Create .
2. In the next screen select the option “ Elementary search help “ .

3. Now you need to provide the short text for your search help.

4. In the selection method provide the table or view name you want to use for data retrieval. Ex.
ZMARA_01.

5. Select the dialog type according to your scope, ex. “ display values immediately’.
6. Then provide the search help parameters i.e. the interface parameters for the search help .

7. The ZMARA_01 table fields MATNR, ERSDA,MHDHB,MHDHT,MHDRZ are provided by selecting the
table fields , by doing this the data elements for these fields are automatically copied to the interface from
the selection method.

8. Now define the type of parameter ( import or export ) here for the selection and return of values in
runtime.

9. Provide the positions to these parameters to specify how they will be arranged in the hit list display.

10. Now save the object in the respective development class and check the same for errors and then
activate .Finally the creation of a ESH ( ex: ZSH004 ) is complete and can be used for providing the input
help.

You can test the operation of your search help by clicking F8.
The appearance of your search help will be like the fig. provided below.

9) Elementary Search Help

1) Goto SE11
Enter the search help name and click on create.

2) Choose elementary search help radio button option as the search help type.

3) Enter the search help parameters, the selection method and activate the search help.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Steps to create Collective Search Help .

1) Enter the search help name and click on create.

2) Choose Collective search help radio button option as the search help type.

3) Enter the search help parameters.

Note that there is no selection method to be entered for a collective search help.

4) Instead of the selection method, we enter the included search helps for the collective search help.

5)We need to assign parameters for each of the included search helps.

6) Complete the parameter assignment by clicking on the push button.

7) Collective search help offers the user to obtain F4 help using any of the included search helps.

10) How can we create TCODE for Table Maintenance Generator(TMG)?

Check following steps,

1. Transaction: SE93
2. Enter Short Text
3. Select Radio button "Transaction with Parameters (Parameter Transaction)"
4. Next screen, give transaction as SM30
5. Check "Skip Initial Screen"
6. Under Default Values tab give two rows
a. VIEWNAME for screen field and <your table name> for value
b. UPDATE for screen and 'X' as value
7. Save and Execute.

11) ALV using Oops :


Steps :
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

ü Create container ( this is the area where u can view ur output ) by calling a screen.

Create reference variable for the container and create instance for container of class .Eg: r_container
TYPE REF TO cl_gui_custom_container

ü Create a grid which is laid on the container .


Create reference variable for the grid and create instance for grid.Eg : r_alv_grid TYPE REF TO
cl_gui_alv_grid

ü Create internal table to hold the records of specific structure.


ü Write select query to extract records into the internal table .
ü Call method set_table_for_first_display of grid to display the ALV list.

Pass the internal table and structure to the method.

Procedure for call screen :

In SE38 ,create a program after writing select query,call screen .

Then follow the below procedure.


Call screen 200.( U can give any number )

Double click on screen number,i.e 200,which gives a pop asking u if u want to create it.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

There u give a description for the screen and goto layout.


This takes u to Graphical screen painter.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

A icon with 'c' appears on the left side, click on it, this will come on right frame where u can drag it (this
will be your container).Give a name for the container.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Save and activate.

Goto flow logic,there u can find PBO(PROCESS BEFORE OUTPUT ),PAI(PROCESS AFTER INPUT ) events
with commented modules.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Uncomment them and double click ,this will come to ur program.

For Module status_screennumber

Uncomment status_screennumber under PBO event and double click

It gives a popup if you want to create it.

Click on yes,then a popup comes to include,select main program,click yes.

Then below popup comes .

Here click yes to save.

U will get set pf-status and set title bar in the program .

With these create pf-status and give title for the ALV list.

For Module user_command_screennumber.


Uncomment user_command_screennumber under PAI event and double click.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Click on yes and include main program and click yes.

Save it.

Through this u can handle user commands.

Create module under this event and double click this which will come to your program

Do as above and save it.

Here u need to create objects for container and grid and call method of grid for displaying
ALV list.

From SE38 ,in the above module select pattern tab.

In this screen select pattern for creating objects of container and grid
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

.
Create object of container and give the container name which u have assigned through
Graphical Screen painter.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Now create object for the grid by selecting pattern and assign container as parent class.

Select ABAP objects pattern.

Now call method of grid for ALV list display by selecting pattern
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Pass the structure name and internal table name to this method.

Program : This is a simple ALV output which displays spfli records with ALV list.

DATA : r_container TYPE REF TO cl_gui_custom_container,


r_alv_grid TYPE REF TO cl_gui_alv_grid.
DATA :
S_tab LIKE STANDARD TABLE OF Spfli.
START-OF-SELECTION.
SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.
CALL SCREEN 2000.
*&---------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*

MODULE status_2000 OUTPUT.


SET PF-STATUS 'ALV'.
SET TITLEBAR 'Program to display spfli details'.
ENDMODULE. " STATUS_2000 OUTPUT
*----------------------------------------------------------------------*
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

* MODULE alv_output OUTPUT


*----------------------------------------------------------------------
MODULE alv_output OUTPUT.
CREATE OBJECT r_container
EXPORTING
* parent =
container_name = 'CCCONTAINER'------->( container name )
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT r_alv_grid
EXPORTING
* i_shellstyle =0
* i_lifetime =
i_parent = r_container -------> (reference variable of container)
* i_appl_events = space
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*
CALL METHOD r_alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SPFLI' -------> ( Pass the structure )
* is_layout = w_lay
CHANGING
it_outtab = s_tab -----> (Give internal table name )
* it_fieldcatalog =

* it_sort =

* it_filter = .
IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO


* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_2000 INPUT
*----------------------------------------------------------------------
MODULE user_command_2000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'RETURN'.
SET SCREEN '0'.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

WHEN 'DISPLAY'.
LEAVE TO SCREEN 200.
ENDCASE.
ENDMODULE. " USER_COMMAND_2000 INPUT

The output of the above program is


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

12) VIEWS:

 View is a data dictionary object.


 It exists logically inside the data dictionary.
 It is used to fetch datas from more than one database table.
 In views, we specify the tables and SAP will automatically generate a
join condition code in the background.

Navigations to create a view:


SE11 -> Select 'VIEW' radiobutton -> Specify view name starting with Z or Y
-> Create -> Select as 'DATABASE VIEW' -> Click on Copy -> Enter short
description -> Specify name of the tables from which you want to fetch
records -> Click on Relationships pushbutton -> Opens an interface ->
Select the condition based on primary key relationship -> Click on Copy -> A
join condition is created -> Click on 'View Fields' tab button -> Click on Table
fields pushbutton -> Opens an interface with specified table names -> Click
on first table -> Click on Choose -> Select required fields -> Click on Copy
-> Do the same thing for choosing fields from second table -> Save ->
Activate -> Discard the warning message.

To implement the view created, use SE38 editor and write the following
code:

TABLES ZMYVIEW1.
SELECT * FROM ZMYVIEW1.
WRITE :/ ZMYVIEW1-MATNR, ZMYVIEW1-MTART, ZMYVIEW1-MBRSH,
ZMYVIEW1-MEINS,
ZMYVIEW1-WERKS, ZMYVIEW1-LVORM, ZMYVIEW1-MMSTA.
ENDSELECT.
Save -> Activate -> Execute.
In the above code, TABLES statement is used to create a temporary table
space area to hold the records of view.

12) ADDING SEARCH HELP FUNCTIONALITY (F4) TO THE PARAMETERS


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

STATEMENT:
SE11 -> Select SEARCH HELP RADIOBUTTON -> Specify search help name
starting with Z or Y -> Click on Create -> Select 'Elementary Search Help'
radiobutton -> Click on Continue -> Opens an interface -> Enter Short
description -> Specify table name in 'SELECTION TEXT' field -> Enter field
name in the first tabular column (Under search help parameter) -> Save ->
Activate.
To implement F4 functionality for parameters statement:
SE38 -> Create a program -> Enter the following code:
PARAMETERS MATNUM(20) MATCHCODE OBJECT ZMYSEARCH2.
WRITE MATNUM.
In the above code, 'MATCHCODE OBJECT' addition for parameters statement
is used to assign search help functionality for the parameter variable.
-> Save -> Activate -> Execute.

13) TYPE GROUP:

Type group is a data dictionary object used to store user-defined data types and constants.
DATA statement is used to declare variables for pre-defined data types.
TYPES statement is used to declare user-defined data types.

Navigations to create TYPE GROUP:


SE11 -> Select Type group radiobutton -> Specify type group name starting
with Z or Y -> Click on Create -> Enter short description -> Continue ->
Opens Type Group interface -> Write the following code inside editor:

TYPE-POOL YMYTY .
TYPES : BEGIN OF YMYTY_STALIN,
NAME(20),
COURSE(10),
AGE TYPE I,
END OF YMYTY_STALIN.

Save -> Activate.


In the SE38 editor, write the following code:

TYPE-POOLS YMYTY.
DATA A TYPE YMYTY_STALIN.
A-NAME = 'JEGAN'.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

A-COURSE = 'ABAP'.
A-AGE = '24'.
WRITE :/ A-NAME, A-COURSE, A-AGE.
Save -> Activate -> Execute.
In the above example, TYPE-POOLS statement is used to access user-
defined data types created in a type group.
User-defined data types can be made globally accessed if saved under a type
group.

14) MESSAGE CLASSES:


Message Classes are container of user-defined messages. We can create our
own messages to be displayed in the screen and we can create these
messages in a message pool inside the message class.
SE91 is the Tcode to create a message class.
The created messages can be called from programs using the statement
'MESSAGE'.

SYNTAX:
MESSAGE <type_of_message><message id>(message_class).
TYPES OF MESSAGES:
S - Status message.
I - Information message.
E - Error message.
W - Warning message.
A - Abort message.
T - Terminate message.

You can create up to 1000 messages in a single message class. The message
id ranges from 0 - 999.

Navigations to create a MESSAGE CLASS:


SE91 -> Opens Message Maintenance Initial screen -> Specify Name of
message class starting with Z or Y -> Click on Create -> Enter short
description -> Click on MEssages Tab button -> Save message class under a
package and assign request number -> Define your own messages -> Save
Again -> Come back.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

From SE38 editor, use the following code:


selection-screen pushbutton 10(15) lb1 user-command pb1.
initialization.
lb1 = 'press this'.
at selection-screen.
case sy-ucomm.
when 'PB1'.
MESSAGE T000(ZMYMESSAGE).
ENDCASE.

15) VARIANTS:

This concept is used to create default values for the input fields. Variants are

helpful for the SAP end users and data entry operators.

In SE38 editor, create the following code:

parameters : a(10), b(10), c(10), d(10).


Save -> Activate -> Come back -> Click on Variants radiobutton -> Click on
Change -> Opens Variants Initial Screen -> Specify name of the variant
starting with Z or Y -> Click on Create -> Opens an interface with the input
fields -> Click on Attributes pushbutton from Application toolbar -> Enter
short description for variant -> Save -> Enter variant values in the input
fields -> Save again -> Come back -> Come back -> Click on Source code
radiobutton -> Click on change -> Execute the program -> You will see 'Get
Variant' pushbutton option in the application toolbar -> Click on pushbutton
to get variant values.

16) Steps to create a screen, take the following steps:


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

1. Define the basic features of a screen (screen attributes)


2. Design the screen layout (in the fullscreen editor)
3. Define the field attributes (field list)
4. Write the screen flow logic

17) MODULE POOL PROGRAMMING:

* These are type M programs in SAP.


* Screen painter is a tool used to create GUI in ABAP.
* MPP provides screen painter to create a screen for the program.
* These programs cannot be executed directly.
* Customer-specified Transaction code (starting with Z or Y) should be
created for each MPP program to execute.
* We can create any number of screens for a program and we can call these
screens very easily.
* MPP programs should start with the naming convention SAPMZ or SAPMY.
* SE80 is the Tcode to create MPP programs.

EVENTS IN MPP:
PROCESS BEFORE OUTPUT (PBO)
PROCESS AFTER INPUT (PAI)
PROCESS ON VALUE REQUEST- To provide F4 functionality to MPP program
screen i/p fields.
PROCESS ON HELP REQUEST - To provide F1 functionality to MPP program
screen components.

Navigations to create a simple MPP program:


SE80 -> Select Program from drop-down list -> Specify program namestarting with SAPMZ or SAPMY ->
Press Enter -> Click on Yes to createobject -> Create Top Include File by clicking on Continue icon in
pop-upscreens -> Save under a package -> Assign a request number -> MPPprogram with specified
name is created with Top include File.
To create screen, Right click on program name -> Select Create -> Screen
-> Opens Screen Description page -> Enter short description for screen ->
Select screen type as NORMAL -> Click on LAYOUT pushbutton from
application toolbar -> Opens Screen Painter -> Drag and drop two input
fields from toolbar -> Likewise, create two pushbuttons -> Double click on
each component -> Opens Attributes box -> Specify attributes for each
screen component -> For pushbutton, specify FCT code -> Save the screen
-> Click on Flowlogic pushbutton from application toolbar -> Opens Flow
logic editor to create event functionalities for screen components ->
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Decomment PAI module -> Double click on PAI module name -> Click on Yes
to create PAI module object -> Opens PAI module -> Specify the following
code within module-endmodule statements:

CASE SY-UCOMM.
WHEN 'DISPLAY'.
LEAVE TO LIST-PROCESSING.
WRITE :/ IO1, IO2.
WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

-> Save.

Now double click on 'Includes' Folder (TOP INCLUDE FILE) -> Declare

variables for input fields as follows:

DATA : IO1(10), IO2(10).

Save -> Activate.


Now To create Transaction Code, right click on Main Program Name ->
Create -> Transaction -> Opens an interface -> Enter Tcode name starting
with Z or Y -> Enter short description -> Continue -> Opens interface ->
Enter Main program name and Screen number to be called first -> Save
under a package -> Assign a request number.
Activate all the objects of MPP program by right clicking on Main program
Name -> Click on Activate -> Raises 'Objects Activated' message.
To execute the MPP program, specify Tcode name in the Command Prompt
area -> Press Enter.

EVENTS IN MPP:
PROCESS BEFORE OUTPUT - This event gets triggered whenever the
program is executed using Tcode. This event is used to assign initial default
values to the screen components.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

PROCESS AFTER INPUT - This event gets triggered after some user's action
in the screen (for eg, after clicking pushbutton, subsequent event
functionalities).

PROCESS ON VALUE REQUEST - This event is used to assign F1 functionality


for the screen components.
PROCESS ON HELP REQUEST - This event is used to assign F4 functionality for the input field in the
screen.
Eg. code to make field validations in MPP program:
Using screen painter, design a screen consisting of four input fields for client,
username, password and language as we have in login screen of SAP.
Assign the first two input fields to one group called GR1, the third input field to a group GR2.

Create two pushbuttons and assign FCT codes.


In the TOP INCLUDE FILE, declare following variables:
PROGRAM SAPMYSCREENVALID.
DATA : IO1(3), IO2(8), IO3(8), IO4(2).
DATA A TYPE I.
Save -> Activate.
In Flow logic editor, decomment PAI MODULE, double click on module name,
and inside the module, write the following code:
module USER_COMMAND_0200 input.
case sy-ucomm.
WHEN 'LOGIN'.
CALL TRANSACTION 'SE38'.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
endmodule.
" USER_COMMAND_0200 INPUT
Save -> Activate.
In PBO module, write the following code to assign default input field
attributes:
module STATUS_0200 output.
Save -> Activate.
Create a Transaction Code -> Execute the program.

18)Menu Painter

ADDING USER-DEFIND MENUS TO THE INTERACTIVE REPORTS:

Menu Painter is a tool used to create user-defined menus, application toolbar


and function keys.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

SET PF-STATUS '<menu_name>' is the syntax used in reports to access


Menu Painter directly to create user-defined menus.
A menu bar consists of set of menus.
Menu contains set of menu items.

Each menu item may have its own sub menu items.

Another way of accessing Menu Painter is using SE41 Tcode.

Eg. code:

WRITE :/ 'SELECT ONE FROM THE MENU'.

SET PF-STATUS 'MYMENU'.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN ' SAMPATH 1'.


MESSAGE S000(ZSHABMSG).
WHEN ' SAMPATH 2'.
MESSAGE S001(ZSHABMSG).
WHEN 'SAMPATH3'.
LEAVE PROGRAM.
WHEN 'SUBMENU11'.
CALL TRANSACTION 'SE38'.
WHEN 'SUBMENU12'.

CALL TRANSACTION 'SE37'.

ENDCASE.

-> Save -> Activate -> Execute.

19) TABLE CONTROL COMPONENTS:


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Table Control component is used to view the table records and if needed, we can directly modify table
records and update the database table using table control.

Here, the records can be viewed in rows and columns format separated by
horizontal and vertical lines.

SYNTAX:
CONTROLS <table_Control_name> TYPE TABLEVIEW USING SCREEN
<MPP_screen_number>

CONTROLS statement is used to create a memory space area for table control component in AS.
TABLEVIEW is a data type for table control component.
SCREEN NUMBER should be specified to make the system know where the table control was physically
created.

Steps to create a TABLE CONTROL COMPONENT:


Create MPP program -> In TOP INCLUDE FILE, write the following code:
DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.
CONTROLS TABCTRL TYPE TABLEVIEW USING SCREEN '123'.
DATA CUR TYPE I.
Save -> Activate.

Create a Normal screen (123) -> Drag and drop TABLE CONTROL component
from application toolbar -> Specify its name in attributes box -> Specify title
if necessary -> Select HORIZONTAL and VERTICAL SEPARATORS checkbox
-> If needed, select COLUMN and ROW selection radiobuttons -> Click on
Dictionary/Program Fields from Appn. Toolbar -> Specify internal table name
specified in top include file -> Click on 'GET FROM PROGRAM' pushbutton ->
Choose required fields -> Click on continue -> Place the fields in table
control component -> Add labels for each fields -> Create two pushbuttons
(FETCH, EXIT) -> Save -> Flow Logic.
In PAI module, write following code:
55

CASE SY-UCOMM.
WHEN 'FETCH'.
SELECT * FROM KNA1 INTO TABLE ITAB.
TABCTRL-LINES = SY-DBCNT.
WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

In Flow Logic editor, write following code:

PROCESS BEFORE OUTPUT.


MODULE STATUS_0123.
LOOP AT ITAB CURSOR CUR WITH CONTROL TABCTRL.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0123.
LOOP AT ITAB.
ENDLOOP.
Here, LOOP AT ITAB-ENDLOOP statement in PBO event is used to fetch therecords and insert into table
control component. CURSOR statement is usedto make use of the cursor in table control component
whenever we try toselect a particular field and modify it.
LOOP AT ITAB-ENDLOOP statement in PAI event is used to make necessary
modifications to the database table from table control component.
Create Tcode -> Execute.

TABLE CONTROL:

This component is used to view the internal table records in MPP screen.
Table control modification:
LOOP AT ITAB-ENDLOOP statement in PBO is used to fetch the records into
internal table from db table.
LOOP AT ITAB-ENDLOOP statement in PAI is used to view the current data in
internal table through table control.
To make modification, create one more internal table for the same dbtablestructure used in top include
file. To move first internal table records to thenewly created one, create a separate module to specify a
statement for thispurpose b/w LOOP-ENDLOOP in PAI.
eg.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0800.
LOOP AT ITAB.
MODULE ITABTOITAB1.* New module

ENDLOOP.

Double click on module name to specify following move statement.


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

eg.

MODULE ITABTOITAB1 INPUT.


APPEND ITAB TO ITAB1.
ENDMODULE.
In Screen painter, create 'MODIFY' pushbutton and specify event
functionality in PAI as follows:
WHEN 'MODIFY'.
LOOP AT ITAB1.
MODIFY KNA1 FROM ITAB1.
IF SY-SUBRC = 0.
MESSAGE S006(ZSHABMSG).
ELSEIF SY-SUBRC = 4.
MESSAGE E004(ZSHABMSG).
59

ENDIF.

ENDLOOP.

SELECT * FROM KNA1 INTO TABLE ITAB.


TBCL-LINES = SY-DBCNT.
ENDCASE.

20) TABSTRIP CONTROLS:

Using normal screen, we can add only 40 components to the screen. To addmore than 40 components,
make use of tabstrip control. You can specify anynumber of tab fields for a tabstrip control and create
subscreen for each tabfield created.

Stpes to create tabstrip control:


Create an MPP program -> Create a screen -> Drag and drop tabstrip
control from toolbar -> Specify name for the tabstrip created (KARTHIK) ->
Specify required number of tab fields (2) -> Drag and drop subscreen area
for each tab field -> Name the subscreen areas (SUB1, SUB2) -> Specify
attributes for each tab field (NAME, TEXT, FCTCODE, REF_FIELD) -> Create
two pushbuttons (DISPLAY, EXIT) Save the screen painter -> Click on Flow
logic editor.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Now create two subscreens (10, 20) for each tab field subscreen areas.
Create required screen components for each subscreen (input fields namely
IO1, IO2, IO3, IO4) -> Save -> Come back to Flow logic editor.
In TOP INCLUDE FILE, specify following code:
DATA : IO1(10), IO2(10), IO3(10), IO4(10).
CONTROLS KARTHIK TYPE TABSTRIP.
DATA SCREEN LIKE SY-DYNNR .
CONTROLS statement is used to create a memory for tabstrip component in AS.
SY-DYNNR is a system variable to hold screen number.

Save -> Activate.

In the FLOW LOGIC EDITOR, Specify following code for PBO and PAI
modules:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
CALL SUBSCREEN SUB2 INCLUDING 'SAPMYONCEMORE' '20'.
CALL SUBSCREEN SUB1 INCLUDING 'SAPMYONCEMORE' '10'.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
CALL SUBSCREEN SUB1.
CALL SUBSCREEN SUB2.
Save -> Activate.
Specify following code in PAI event between module-endmodule statements:

CASE SY-UCOMM.
WHEN 'DISPLAY'.
LEAVE TO LIST-PROCESSING.
WRITE :/ IO1, IO2, IO3, IO4, IO5.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'TAB1'.
SCREEN = '10'.
KARTHIK-ACTIVETAB = 'TAB1'.
WHEN 'TAB2'.
SCREEN = '20'.
KARTHIK-ACTIVETAB = 'TAB2'.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

ENDCASE.
Create Tcode -> Activate all components -> Execute the program.

21) LIST OF VALUES:

This concept is used to provide drop-down facility for the input fields createdusing screen painter. Here, a
type group called VRM is used in which we havefollowing structure and internal table:
VRM_VALUE is a structure with following fields,
KEY - Code for the display value
TEXT - Content of the display value
VRM_VALUES is an internal table created for the above structure without
header line.
Declare an internal table (ITAB) of type VRM_VALUES and also declare an
explicit structure (WA) to append values into internal table using LIKE LINE
OF statement.
VRM_SET_VALUES is the function module used to fetch records from internal
table ITAB to input field IO1

22) LSMW ( Legacy System Migration Workbench)


Is a 14 step Navigation to Perfrom BDC, here ABAPer is not writing a single
Code to transfer Flat file data.
LSMW is a collection of Projects.
Project is a collection of Sub Projects.
Sub project is a collection of Objects, here Object represents transactions.
LSMW -> Name the Project ( Z730LSMW ) -> Name the Sub Project ( MM
) -> Name the Object ( MM01 ) -> Click on Create From application toolbar-> Opens an interface -> Enter
the Description for project , sub projectandObject -> Click on Execute from Application toolbar .
Opens an interface with list of LSMW navigations.

Step #1. Maintain Object Attributes


In this step we need to specify a recording object to be assigned for
LSMW to process the BDC data.
select the radiobutton -> Click on Execute from Application toolbar -> Opens
Another Interface -> Click0 on Pushbutton Recording Overviews , to create a
new recording Object -> Opens LPS -> Select the data from screen -> Click
on Create Recording from application toolbar -> Name the recording Object (
zrec1 ) -> Enter description ( any ) -> Click on continue -> Specify Tcode
( mm01 ) -> Accept the SAMPLE data -> Save the Record -> by default sap
displays list of fields information where data is accepted in the form "JTAB"
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

Internal table data -> Move this fields into Recording Object fields by clicking
on "Default all" pushbutton from application toolbar -> save the Entries ->
Come back -> come back ->Change mode of the screen into Change mode
-> Select the radiobutton called as Batch Input Recording -> Name the
recording Object ( ZREC1 ) -> Save the Entries -> Come back .

Step #2 Maintain Source Structures


In this step we have to define Name of the Internal table where data to be
populated from Flat files.
Select -> Execute from Application -> Opens an interface -> Change the
mode into Change mode -> Click on Create Structure From Application
toolbar -> Name the Internal table ( ITAB1 ) -> Enter Description
( Database format internal table ) -> Click on Continue -> save the Entries
-> Come back.

Step #3. Maintain Source Fields


In this step we are adding fields to the Internal table created in Second
step.
Select the radiobutton -> Click on Execute -> Opens an interface -> Change
Mode of the screen -> select the Internal table from the List -> Click on
Create field from application toolbar -> Name the Field ( MATNR ) -> Enter
Description (any) -> Set the Size ( 18) -> Specify Data type ( C ) -> Click
on Continue.
Using the same step add Other Fields
MBRSH ( Industry ) 1 (C)
MTART (Mat type) 4 (C)
MAKTX (Mat Desc) 40 (C)
MEINS (Mat measure) 3 (C)
-> save the Entries -> Come back.

Step #4. Maintain Structure Relations


In this step we need to Generate Relation between ITAB1 and Recording
Object.
select -> Execute -> Opens an interface ->Relation ship , by defult
generated by SAP -> Change mode of the screen -> save the Entries ->
Come back.

step #5. Maintain Field Mapping and Conversion Rules


Mapping the Fieldsof Itab1 with Recording Object is the step to be
processed.
select -> Execute -> Change Mode of Screen -> Select the Field From List of
recording object -> Click on Source Field From Application toolbar ->
Displays the List of Internal table fields -> Double click on Proper Field. In
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

the same way map all Fields of Recording Object with All Fields of Internal
table -> Save the Entries -> Come back.

Step #6. Maintain Fixed Values, Translations, User-Defined Routines


This is optional Step In BDC of LSMW
Execute -> Come back.

Step #7. Specify Files


Select -> Execute -> Opens an interface -> Change Mode of Screen ->select legacy data on PC -> Click
on Create From Application toolbar ->Name the File ( D:\730AM\matdata.txt ) -> Enter Description ( any )
->Sepecify Separator as "Comma" -> Click on Continue-> Save the Entries
-> Come back.

Step #8. Assign Files


In this step we need to assign the Flat fiel Into Internal table created in
Second step.
select -> Execute -> Change Mode of the screen -> Save the Entries ->
Come back.

Step #9. Import Data


In this step SAP Reads the Flat File data and stores in the form of
".lsmw.read" file..
Select -> Execute -> Opens an interface -> Click on Execute -> Sap
Generates a report as Flat file is converted into ".read" file with Number of
transactions -> Come back -> Come back.
Step #10. Display Imported Data
Select ->Execute -> Open an Interface -> Click on Continue -> displays the
data in Internal table (itab1) -> Come back.

Step #11. Convert Data


In this step Data will be converted into ".lsmw.conv" file to make data is
ready for populating into Session object.
select -> execute -> Execute -> Sap Generates a report as file is converted
into Conv -> Come back -> come back.

Setp #12. Display Converted Data


select -> Execute ->Opens an interface -> Click on continue-> Generates a
report with Green Color -> Come back.

Setp #13. Create Batch Input Session


Select ->Execute -> Opens an interface -> Select the checkbox -> Click on
Execute -> Prompts a message.

Step #14. Run Batch Input Session


Opens SM35 tcode to process BDC data.

24) SAPSCRIPTS.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

This is a tool used to redirect SAP data to output devices. SE71 is the Tcode to create SAPScript.
Components of a SAPScript tool are:
1. BASIC SETTINGS.
Paragraph format, character format.
2. ADMINISTRATIVE SETTINGS.

Name of the form, short description.


Layout is used to create a form in SAPScript. Layout is a collection of pages.
Page is a collection of Windows.

Types of Windows:
1. Main Window - This is a common window for all pages. This is a default window.
2. Constant Window - This window is used to create footer space, header space for a particular page.
3. Variable Window - This is a subwindow.
4. Graphical Window - This is an optional window, which is used to create
logos or some other graphics for the page.

NAVIGATIONS FOR CREATING A SAPSCRIPT:


SE71 -> Specify Form name starting with Z or Y (ZSHABFORM) -> Click on
Create -> Opens an interface -> Enter short description -> Click on
'Paragraph Format' from Appn. toolbar -> Specify Paragraph Name (P1)->
Press Enter -> Enter short description -> Click on 'Definitions' pushbutton
from application toolbar -> Specify Default Paragraph (P1) created -> Click
on Layout pushbutton from appn. toolbar -> Opens a layout with a default
window 'MAIN' -> Right click on Main Window -> Select 'Edit Text' -> Opens
a Line Editor -> Specify a statement -> Come back -> Save -> Activate the
form -> A SAPscript is created.
To invoke the form created, we have to create a print program. Create an
Executable Program and specify the following
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

CALL FUNCTION 'OPEN_FORM'


EXPORTING
FORM
= 'ZSHABFORM'
LANGUAGE
= SY-LANGU.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ELEMENT'
WINDOW= 'MAIN'.

CALL FUNCTION 'CLOSE_FORM'.

-> Save -> Activate -> Execute -> Opens an interface -> Specify output
device as LP01 -> Click on Print Preview (F8) pushbutton -> Executes the
form.
The FM 'OPEN_FORM' is used to call the sapscript form. Here, we have to
specify the name of the form as an argument.
'WRITE_FORM' is used to specify the name of the text elements and window types.
'CLOSE_FORM' is used to save and close the form attributes.

The function modules OPEN_FORM and CLOSE_FORM are mandatory ones.


PASSING ARGUMENTS TO THE FORM:

In Line editor, specify an argument enclosed by an ampersand symbol (&).

eg. &KARTHIK&.

Save -> Activate the form.

To pass a value from the print program to the form, declare the variable as
follows in Print PRogram:
DATA KARTHIK(10) VALUE 'CHENNAI'.
....OPEN_FORM
...
....CLOSE_FORM
Save -> Activate -> Execute.

PASSING TABLE VALUES AS AN ARGUMENT TO SAPSCRIPT:


In the line editor, specify the table field arguments enclosed by '&' symbol as
follows:
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

/E ELEMENT
&KNA1-KUNNR& ,, &KNA1-NAME1& ,, &KNA1-LAND1&
Save -> Activate.
In the Print Program, specify following code:
TABLES KNA1.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM
= 'ZSHABFORM1'
LANGUAGE
= SY-LANGU.
SELECT * FROM KNA1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT
= 'ELEMENT'
WINDOW
= 'MAIN'.

ENDSELECT.

CALL FUNCTION 'CLOSE_FORM'.

Save -> Activate -> Execute.


PASSING INTERNAL TABLE AS AN ARGUMENT TO THE FORM:
In line editor, specify following arguments:
/E ELEMENT
&ITAB-KUNNR&
&ITAB-NAME1&
&ITAB-LAND1&

Save -> Activate.


In Print Program, specify following code:
DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.
80

SELECT * FROM KNA1 INTO TABLE ITAB.


CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM
= 'ZSHABFORM1'
LANGUAGE = SY-LANGU.
LOOP AT ITAB.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ELEMENT'
WINDOW = 'MAIN'.ENDLOOP.
CALL FUNCTION 'CLOSE_FORM'.
-> Save -> Activate -> Execute.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

ADDING IMAGES TO THE FORM:


Create a .bmp file and save it in a directory -> Goto SE78 Tcode -> Double
click BMAP Bitmap images -> Click on Import icon from appn. toolbar ->
Opens an interface -> Specify the path of .bmp file from the OS -> Specify
the name for the image -> Select Color bitmap image radiobutton -> Click
on Continue -> Image is imported.
To add the imported image into the form, right click on the form layout ->
Select Create Graphic -> Opens an interface -> Select image from the form
directory -> Select Color bitmap image radiobutton -> Specify resolution as
100 -> Continue -> An image is added to the script.
Simply call the form from the print program.
To upload .TIFF files into the SAPscript directory, make use of a predefined
executable program called as RSTXLDMC.
In SE38 Tcode, specify the above name, click on execute pushbutton from
application toolbar -> Opens an interface -> Specify the file path ->
Execute.
Text Elements in the line editor are used to avoid data duplication

25) SMARTFORMS

ADVANTAGES OF SMARTFORMS:
1. Smartforms does not require paragraph formats as a mandatory one.
2. Smartforms does not duplicate the data.
3. Smartforms are Client-independent and language-independent.
4. We can apply styles for the texts using Smartforms.
5. Print programs does not contain any function modules to call the form.
SMARTFORMS is the Tcode to create smartforms in ABAP.
Smartforms has three components:
Global Settings:
1. Form Attributes - Holds the description about the smartform.
2. Form Interface - Holds the import and export parameters for the
smartforms.
3. Global Definitions - Used to declare variables for the smartform that can
be accessed by any component within the smartform.
Pages and Windows:
This area is used to create new pages, windows (header, footer, constant
window, main window, variable window, graphic window).
Navigations to create Smartforms:
SMARTFORMS -> Specify form name starting with Z or Y -> Click on Create
-> Opens an interface -> Enter short description -> Double click on Form
Interface -> Specify following parameter in IMPORT tab button:
STR TYPE C
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

-> Expand Pages and Windows -> By default, a Main Window is present ->
Right click on Main Window -> Create -> Text -> Opens Form Editor -> To
go to line editor, Click on 'Txt Editor' pushbutton on the upper left corner of
the form editor -> Specify the variable (&STR&) in the first line of line editor
-> Come back -> Save -> Activate -> Execute -> Opens Form Builder with
autogenerated function module for the smartform ('/1BCDWB/SF00000042')
-> Copy the function module generated.
To invoke the smartform from SE38 editor, Call the Function module and
paste the FM copied from smart form function builder screen as follows:
DATA NAME(10) VALUE 'INDIA'.
CALL FUNCTION '/1BCDWB/SF00000042'
EXPORTING
82

STR
= NAME.
-> Save -> Activate -> Execute in the same way as Sapscript.
Navigations to pass internal table as an argument to Smartforms:
Create a smartform -> In the Form interface -> Click on Tables tab

button -> Specify the following internal table:

ITAB LIKE MARA.

-> Double click on Global Definitions -> Specify the global variable as

follows:

ITAB1 LIKE MARA.

-> Expand Pages and Windows -> Right click on Main Window -> Create ->
Table -> Click on Data tab button -> In the LOOP section, for the operand
fields, specify the following:
ITAB INTO ITAB1.
-> Right click on Main Area -> Create -> Table Line -> In the Line Type input
field, a line type called %LTYPE1 is automatically generated -> Select it.
To create internal table fields, right click on Text cell -> Create -> Text ->
Select General Attributes tab button -> Opens Form Editor -> Goto Line
editor by clicking on 'Txt Editor' pushbutton -> Specify the following in the
first line:
&ITAB1-MATNR&,,&ITAB1-MTART&,,&ITAB1-MBRSH&,,&ITAB1-MEINS&
-> Come back -> Save -> Activate -> Execute -> Copy the autogenerated
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

FM.

In SE38 program, specify the following:

DATA ITAB1 LIKE MARA OCCURS 0 WITH HEADER LINE.

SELECT * FROM MARA INTO TABLE ITAB1.


CALL FUNCTION '/1BCDWB/SF00000043'
TABLES
ITAB
=
ITAB1.
Save -> Activate -> Execute in the same way as above.

26) USEREXIT

Userxits allow us to add our own functionality to SAP standard program


without modifying it . These are implemented in the form of subroutines and hence are also known as
FORM EXITs. The userexits are generally collected in includes and attached to the standard program by
the SAP.
All Userexits start with the word USEREXIT_...

FORM USEREXIT_..
z..
ENDFORM.

The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the
correct userexit is found the necessary
customer code is inserted in the customer include starting with the z..
in the form routine.

e.g. USEREXIT_SAVE_DOCUMENT_PREPARE

Certain application like SD still provide this form of enhancement using userexit but this practice is no
longer being followed for newer extensions
instead they are using EXITs which come bundeled in enhancement packages . Neverthiless existing
USEREXITS will be supported by SAP an all the newer versions of SAP.

HOW TO FIND USEREXITS

Userexits can be found in number of ways:


1) To find userexits in SD module , goto object navigator(SE80) and select
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

development class from the list and enter VMOD in it. All of the userexits in SD are contained in the
development class VMOD. Press
enter and you will find all the includes which contain userexits in SD for
different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the
requirement and read the comment inserted in it
and start coding .

Some examples of userexits in SD(SALES & DISTRIBUTION ) are:

1)ADDING OF NEW FIELDS IN PRICING


In Pricing in SD the fields on the basis of which pricing is done are derived from the FIELD CATALOG
which is a structure KOMG .This structure is used to transfer transaction data to the pricing procedure in
SD and is also known as communication structure.This structure KOMG consists of two tables KOMK for
Header related fields and KOMP for item related fields.
The fields which are not in either of the two tables KOMK and KOMP
cannot be used in pricing .Sometimes a need arises when the pricing
is to be based on some other criteria which is not present in the form of fields in either of the two tables.
This problem can be solved by using USEREXITS which are provided for pricing in SD.
Pricing takes place both when the SALES ORDER ( Transaction VA01) is created as well as when
INVOICING ( Transaction VF01) is done.Hence SAP provides 2 userexits ,one for sales order processing
which is

USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
Depending upon which table (KOMK or KOMP) the new fields were inserted we use either of the above
two userexits.These userexits are found in include MV45AFZZ of the standard SAP sales order creation
program SAPMV45A.

In the case of userexit which will be called when invoicing is done ,these
are provided in the include RY60AFZZ which is in the standard SAP
program SAPMV45A. The name of the userexits are same. i.e
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK

These userexits are used for passing the data from the communication structure to the pricing procedure,
for this we have to fill the newely
created field in the communication structure KOMG for this we fill the code in the above userexit using the
MOVE statement after the data that
has to be passed is taken from the database table by using the SELECT statement. The actual structure
which is visible in these userexits and which is to be filled for that particular field is TKOMP or TKOMK.

Before the coding for these userexits is done ,it is necessary to create a new field in either of the two
tables KOMK or KOMP .For this purpose
includes are provided in each of them .
To create the field in header data(KOMK) the include provided is KOMKAZ
and to create the field in item data(KOMP) the include provided is KOMPAZ.
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

One possible example for the need of creating new fields can be e.g. Frieght to be based upon
transportation zone ,for this no field is available in field catalog and hence it can be created in KOMK and
then above userexits can be used to fill the transportation data to it.

2)The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3)The other method of finding userexits is to find the include in case of SD/MM applications where the
userexits are located ,this can be found in the SAP reference IMG generally in the subfolder under
SYSTEM MODIFICATION.

Some other examples of userexits in SD are:

USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES
ORGANIZAION(VKORG) .

USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when
the document (sales order VA01) is just about to be saved.This userexit is used generally for custom
checks on different fields , to display some information before the order will be saved or for making
changes to certain fields before the sales order will be saved.

Exits & Enhancements


There are mainly six types of EXITs in sap which have been collected in the form of enhancement
packages and attached to standard code in SAP.
These are different from USEREXIT in the way that they are implemented
in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are
also sometimes known as function exits .
These start from the word EXIT_ followed by the program name and then followed by a three digit
number.

e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.

TYPES OF EXITS

1)MENU EXITS
2)FUNCTION EXITS
3)TABLE EXITS
4)SCREEN EXITS
5)KEYWORD EXITS
6)FIELD EXITS
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is required
to create the project by using CMOD
selecting the enhancement e.g. V45A0002 and selecting the component
(one which fulfills our need) i.e the exit which will be implemented in SMOD and after coding has been
done the project has to be activated.
An exit can be coded only once.

FUNCTION EXITS
These are used to add functionality through ABAP code . These start from the word
EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any tupe
of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'

This is in contrast to USEREXITs where PERFORM statement is used to call


the required userexit.
To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement
package is selected and from its compnents the function exit to be implemented is selected and on
double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and
the customer code should be entered in this include.

e.g.

ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation


To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a
function exit .This function exit is located
in enhancement no V45A0002 . Before we can choose the exit we have to
create a project in CMOD after that enter V45A0002 in the enhancement field and click on the
components . In the components you will see the
exit EXIT_SAPMV45A_002 . This exit is used for our purpose.

Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in exporting
parameter which is E_KUNNR
of type KNA1-KUNNR i.e if we move the desired customer name to this
structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order.
This function also contains a customer include ZXVVA04 . This include
will be used to write our custom code .
Double clicking on this include and it will prompt us that this include does not exists do you want to
create this object ,select yes and the include will be created .In this include we can write our own code
that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.

Activate the include and Activate the project. Now when ever the SALES ORDER will be created , sold-to-
party field will come up with a predefined
customer .
FIELD EXITS
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

The field exits are managed,created,activated through program RSMODPRF. The field exit is associated
with a data element existing in ABAP dictionary and hence to the screen field using that data element.
The format of field exit is :

FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the screens
containing that data element.
The function module associated with field exit shows two parameters
INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was
invoked by the R/3 , We can write our own code to change the output parameter depending upon our
requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES

ABAP/FIELDEXIT = YES.

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_<program name><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
Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

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"

*27) Steps to create BADI

DEFINING THE BADI


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

1) execute Tcode SE18.


2) Specify a definition Name : ZBADI_SPFLI
3) Press create
4) Choose the attribute tab. Specify short desc for badi.. and specify the type :
multiple use.
5) Choose the interface tab
6) Specify interface name: ZIF_EX_BADI_SPFLI and save.
7) Dbl clk on interface name to start class builder . specify a method name (name,
level, desc).

Method level desc


Lineselection instance methods some desc

8) place the cursor on the method name desc its parameters to define the interface.
Parameter type refe field desc
I_carrid import spfli-carrid some
I_connid import spefi-connid some

9) save , check and activate…adapter class proposed by system is


ZCL_IM_IM_LINESEL is genereated.

IMPLEMENTATION OF BADI DEFINITION

1) EXECUTE tcode se18.choose menuitem create from the implementation menubar.


2) Specify aname for implementation ZIM_LINESEL
3) Specify short desc.
4) Choose interface tab. System proposes a name fo the implementation class.
ZCL_IM_IMLINESEL which is already generarted.
5) Specify short desc for method
6) Dbl clk on method to insert code..(check the code in “AAA”).
7) Save , check and activate the code.

Now write a sample program to use this badi method..


Look for “BBB” sample program.

“AAA”

data : wa_flights type sflight,


it_flights type table of sflight.

format color col_heading.


write:/ 'Flight info of:', i_carrid, i_connid.
format color col_normal.

select * from sflight


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

into corresponding fields of table it_flights


where carrid = i_carrid
and connid = i_connid.

loop at it_flights into wa_flights.


write:/ wa_flights-fldate,
wa_flights-planetype,
wa_flights-price currency wa_flights-currency,
wa_flights-seatsmax,
wa_flights-seatsocc.
endloop.

“BBB”

*&---------------------------------------------------------------------*
*& Report ZBADI_TEST *
*&---------------------------------------------------------------------*

REPORT ZBADI_TEST .

tables: spfli.

data: wa_spfli type spfli,


it_spfli type table of spfli with key carrid connid.

*Initialise the object of the interface.


data: exit_ref type ref to ZCL_IM_IM_LINESEL,
exit_ref1 type ref to ZIF_EX_BADISPFLI1.

selection-screen begin of block b1.


select-options: s_carr for spfli-carrid.
selection-screen end of block b1.

start-of-selection.
select * from spfli into corresponding fields of table it_spfli
where carrid in s_carr.

end-of-selection.
loop at it_spfli into wa_spfli.
write:/ wa_spfli-carrid,
wa_spfli-connid,
wa_spfli-cityfrom,
wa_spfli-deptime,
wa_spfli-arrtime.

hide: wa_spfli-carrid, wa_spfli-connid.


Author: Sumeet .B.Patil
mr.patilsumeet@gmail.com
odigotech

endloop.

at line-selection.
check not wa_spfli-carrid is initial.
create object exit_ref.
exit_ref1 = exit_ref.

call method exit_ref1->lineselection


EXPORTING
i_carrid = wa_spfli-carrid
i_connid = wa_spfli-connid.

clear wa_spfli.

You might also like