You are on page 1of 72

Abap Class Notes

ABAP CLASS NOTES.


Topics Covered In The Document :
1.DataDictionar.
!.Interna"Ta#"es.
$.%odu"ari&ation Techni'ues.
(.)eports
*.%PP
+.OOPS
,.BDC
-.SapScripts
..Smart/orms.
10.Enhancements.
11.CrossApp"ications.
1!.)/C.
1$.BAPI.
1(.1enera"Topics.
ABAP Page 1
Abap Class Notes
ABAP2 Advance Business App"ication Pro3ramin3.
Coding language for SAP.
ABAP is a Space sensitive not case sensitive.
Every ABAP statement must be terminated with a period (..
!essages in ABAP must be enclosed with in single "uotations.
#rite statement is output statement in ABAP. #rite is the statement to print messages
or values in $PS ($ist processing screen.
Synta%&'
#rite (message)*+variable,.
E%&'
#rite (#elcome).
-*P&'
#elcome.
4o5 to create a pro3ram.
.o to SE/0.
.ive report name
Name should start with 1 or 2.
3eport 4 5test 6.
Clic7 on create button.
8t will show a popup. 9ill the entries in that popup.
:itle 4report program for test purpose6
4E%ecutable program6.
Clic7 on save.
8t will give a standard line.
3eport 1test.
After this line we can write the code.
;No Standard page heading< is the synta% to remove the standard heading of report.
Synta%&' 3eport +name, No standard page heading.
E%&' 3eport 5test .
#rite (#elcome).
-*P&' 3eport program for test purpose.
#elcome.
E=&' 3eport 1test no standard page heading.
#rite (#elcome).
-*P&'#elcome.
$ine'Si5e is the option to control $PS line width.
.!a%imum line'si5e can be applied as (>?@/).
.minimum line Asi5e can be applied as (>).
.negative numbers cannot be used as line'si5e.
Synta%&'
3eport +name, $ine'Si5e 4n6.
E%&' 3eport 5test line'si5e /.
ABAP Page 2
Abap Class Notes
#rite (welcome).
-*P&'
#el
& indicates if it has more than one line. & is the 7ey word use instead of multiple
statements li7e writeB dataB tablesB constants.
But the statement should be separated by (B) (comma.
Synta%&' write& (message)*+var,B (message)*+var,B (message)*+var,.
Cata& +var, type +data type,B +var, type +data type,.
E=&' #rite& (#elcome)B (8ndia)B (or)B (DE).
-*P&' #elcome 8ndia or DE.
* is the 7ey word to print the messages or variable in ne%t line.
Synta%&' #rite *)message)*+var,.
E%&' write (welcome).
#rite (8ndia).
-*P&' welcome 8ndia.
E%&' write& (welcome)B
*)8ndia).
-*P&' welcome
8ndia.
Position is the number by which you can control the $PS form where you need to start
printing the message or variable. Position is always from beginning of the line.
Synta%&' write F)message)*+var,.
8n $PS it will leave F places and start printing the message or variable.
E%&' write F)welcome).
-*P&' '''''#elcome.
#idth is the number by which you can control the message or variable how many
characters you need to print. Controlling width of a variable or messages.
Synta%&'
#rite (width (message)*+var,.
E%&' #rite (F (#elcome).
-*P&'
#elco.
*Pos(width option must be used together
Synta%&' write4*64pos64(width6 (message)*+var,.
E%&' write& (welcome)B
*G(>? (india).
-*P&' welcome
''''''india.
8n ABAP H and ;are called comment characters.
By using H the entire line became a comment. :he line won)t e%ecute at the time of
e%ecution.
Couble "uotes (; we can use to comment the line between line. Eeep the double
"uotes form where you want to comment and place period before your double "uotes.
ABAP Page 3
Abap Class Notes
E%&'
#rite& (welcome)B
* (india)B
* (always).
-*P&'
#elcome
8ndia
Always.
E=&' #rite& (welcome)B
H * (india)B
* (always).
-*P&'
#elcome
Always.
E=&' #rite& (welcome). ;* (india)B * (always).
-*P&' welcome.
Ctrl I +&' sets selected bloc7 as a comment.
CtrlI,&' sets selected bloc7 as un comment.
Customi5ed obJects in sap must starts with 1 or 2.
:o print blan7 lines in SAP.
Synta%&' set blan7 lines +on*off,.
8s the statement in abap controls the blan7 lines can be printed or not in $PS. By
default this statement is off.
E=&'
Set blan7 lines on.
#rite (welcome).
#rite *) (.
#rite *) (.
#rite *)india).
-*P&'
ABAP Page 4
Abap Class Notes
#elcome
8ndia.
SE8P&' S7ip is the statement to generate multiples blan7 lines.
Synta%&' s7ip 4n6.
#here n is number of lines to s7ip.
E=&'
#rite (welcome).
S7ip @.
#rite (india).
-*P&'
#elcome
8ndia.
C-$-3&' color is the option to applies color for the te%t. 9or te%t bac7ground we use
inverse option.
Synta%&'
#rite& (message)*+var, color 4id6 4inverse6.
Kere id are from > to G.
E%&' write (welcome) color F.
E%&' write (welcome) color F inverse.
Sy'uline&' is the option to print hori5ontal line in lps.
Synta%&' write sy'uline.
E%&'
#rite& (welcome)B
* sy'uline.
-*P&'
#elcome
Sy'vline&' is the option to print hori5ontal line in $PS.
Synta%&'
#rite sy'vline.
E%&'
#rite& (welcome)B sy'vlineB (india).
-*P&'
#elcome L india.
No'.ap&' No'.ap is the option to avoid single character gap between multiple
messages.
Synta%&' wite (message)*+var, no'gap (message)*+var,.
E%&'
#rite& (welcome) no'gapB (india).
-*P&'
#elcomeindia.
No'Sign&' 8s the option in ABAP used for numeric variables to avoid (sign) symbol in
$PS output.
Synta%&'
ABAP Page 5
Abap Class Notes
#rite +num, no'sign.
E%&'
Cata a type i.
A M '>.
#rite a.
-*P&'
>'.
E%&' write a no'sign.
-*P&'
>.
Con trolling alignment modes in write statement.
Synta%&'
#rite& (message)*+var, 4alignment'mode6.
#here alignment'mode is left'JustifiedB right'JustifiedB centered.
E%&'
#rite >?(@F (welcome) color F centered.
-*P&'
#elcome.
Sy'datum&' system variable to print date.
E%&' write sy'datum.
-*P&'
>?*@N*@?>/.
Sy'u5eit&' system variable to print time.
E%&' write sy'u5eit.
-*P&'
F.>/.
K-: SP-: -N&' is used to add single clic7 event functionality of the data in $PS.
Syn&'write (message)*+var, hotspoton.
E%&' write (welcome) hotspoton.
4O6 TO C)EATE PAC7A1E.
.o to se@> or se0?.
.ive pac7age name 45otc6.
Clic7 on create.
Provide short description.
A popup message will displayed for :3.
Clic7 on create :3 re"uest.
Provide short description.
Press enter.
ABAP Page 6
Abap Class Notes
1.Data Dictionar.
28Ta#"e: :able is a collection of 3ows and Columns means fields and records.
N-:E&'#e will create all the re"uired Comains and Cata Elements first so that we can
simply provide the same while creating the :able.
#e can create Cata Element in :wo ways
i. Create the Comain', Cata element (Bottom A :op.
ii. Start with Cata element creation then Comain from there.(:op A Bottom.
Creatin3 domain 9Bottom : ;p Approach<.
.o to SE>>.
Select the radio button Comain.
Comain 45empno6.
Clic7 on create.
Enter the short description 4employee number6.
Clic7 on Cefinition tab and provide (Cata type) and (No of characters).
Cata type 4CKA36.
No characters 4F6.
Save chec7 and activate.
Creatin3 Data e"ement 9Bottom : up approach<.
.ot SE>>.
Select the radio button (Cata :ype).
ABAP Page 7
Abap Class Notes
Cata type 45empno6.
Clic7 on create.
A pop up window will open with / radio buttons.
Select radio button (Cata element).
Clic7 on continue.
.ive short description 4data element for employee number6.
Clic7 on (Cefinition) tab and provide the Comain.
Comain 41empno6.
Clic7 on (9ield label) tab and provide the description of the field.
!edium >? empnum.
$ong >F empnumber.
NOTE:2 :his label will be displayed when we refer the same while designing the
screen in !PP4!odule pool programing6.
Save chec7 and activate.
3epeat the same procedure to create all the Comains and attach Comain to the
corresponding Cata Element while creating the Cata Elements.
', Creatin3 a simp"e customi&in3 ta#"e.
28 .o to SE11.
', select 3adio button Cata base table.
Cata base table 45empOinfo6.
Clic7 on create button.
.ive short description 4:able for employee information6.
Clic7 on (Celivery and maintenance) tab.
9ill the details.
Celivery class 4A6.
:able view maintenance 4maintenance allowed6.
Clic7 on (9ields) tab.
.ive the field name and corresponding data element which we created already.
Empno 5empno.
Press the enter after the data element so that we get all the information attached to it.
Chec7 the 7ey field and intial 7ey .
.ive the second field name and we create the other Cata element and Comains by
top' down approach.
Empname 5empname.
Kere the 1empname is not yet created .:o creates it double clic7 on the field type
(5empname.
8t will show a popup message which is as7ing to save the e%isting table clic7 on yes.
8t will show another popup message as7ing to create Cata element clic7 on yes.
Provide short description 4employee name6.
Provide the domain name
ABAP Page 8
Abap Class Notes
Comain 45empname6.
Couble clic7 on the domain to create it.
8t will show a popup message which is as7ing to save the e%isting data element clic7
on yes.
8t will show another popup message as7ing to create Comain clic7 on yes.
Provide short description 4employee name6.
Provide Cata type and No characteristics.
Cata type 4char6.
No characteristics 4/?6.
SaveB chec7 and activate.
Provide all the fields in the same manner.
Clic7 on ;:echnical settings< on the toolbar.
Enter Cata class and si5e category.
Cata class 4APP$?6.
Si5e category 4?6.
SaveB Bac7.
.oto E%tras ', Enhancement category.
A pop up screen will appear choose the radio button ;can be enhanced<.
Chec7 and activate.
4o5 to create entries.
.o to SE>>.
.ive the table name and display.
.o to utilities ', table contents ', new entries.
Provide the entries and clic7 on save.
Clic7 on reset and give the ne%t entries repeat the same for all the entries.
O)
.o to SE>N.
.ive the table name.
Clic7 on create entries button in the tool bar.
.ive the entries and clic7 on save.
Clic7 on reset the give the remaining entries repeat the same procedure for entering
all the records.
4o5 to Disp"a entries.
.o to SE>>.
.ive the table name and display.
.o to utilities ', table contents ', display.
E%ecute.
#e can see all the entries.
O)
.o to SE>N.
.ive the table name.
Clic7 on e%ecute button.
8t will show all the entries.
ABAP Page 9
Abap Class Notes
De"iver and %aintenance&'
De"iver c"ass:2
8t defines which type of table it is and which type of data stored in it.
A A Application table (!aster and :ransaction data.
C A Customi5ing table maintains only by custB not SAP import.
$ A :able for storing temporary dataB delivered empty.
. A Customi5ing tableB protected against SAP uploadB only 8NS:A$$ (SAP may insert
new data records but may not overwrite or delete e%isting ones.
E A Control tableB SAP and customer have separate 7ey areas.
S A System tableB maintenance only by SAPB change M modification. (Cata changes
have the status of program changes.
# A System tableB contents transportable via separate :3 obJects.
Ta#"e vie5 maintenance:2
:able view maintenance has three options.
1. %aintenance a""o5ed&' SAP will create tow screens one for to insert records and
another to display records.
2. %aintenance a""o5ed 5ith restriction&'SAP will create only one screen that is to
display data or records.
3. %aintenance not a""o5ed&' SAP doesn)t create any screens .
/IELDS&' 9ields are the names.
:o create a field Cata element and Comain re"uired.
Data E"ement&' Cescription of the field along with data type and number of
characters.
Domain&' Comain defines which type of data and how much si5e need for a field.
Note&'>. #e can reuse Comain in several Cata elements.
!. #e can reuse Cata element in several fields.
$. #e can reuse the fields in several tables.
Primar =e&'
Primary 7ey defines mainly / steps.
>. Dni"ue (Cuplicates are not allowed.
@. Not null (Null values are not allowed.
/. 3elationship property.
ABAP Page 10
Abap Class Notes
Currenc > ?uantit @ie"ds&' 9or currency and "uantity fields (CD33B PD:2 we
need to mention the reference table and reference field in the currency * "uantity
fields tab.
Technica" settin3s&' :echnical settings defines in which place of Cata base it has to
store and how much space it has to occupy.
Data C"ass&' Cefines where it needs to place in Cata base.
APPL0&' master dataB transparent tables.
APPL1&' :ransaction dataB transparent tables.
APPL!&' -rgani5ation and customi5ing.
DDI%&' Cimension table in B#.
D/ACT&' 9acts table in B#.
DODS&' -CS table in B#.
Si&e cate3or&' Kow much space needs to be leave in Catabase in ranges from ? A 0.
0 A ? to //?B
1 A //? to >B//?B
A
A
- : NQ?B??? to >B/??B???.
Bu@@erin3:' :he tables which is stored in Application server is called Buffering.
:here are / types of Buffering.
>. Buffering.
@. Buffering switch off.
/. Buffering not allowed.
8n Buffering allowed there are / types they are.
>. Single record buffering.
@. .eneric buffering.
ABAP Page 11
Abap Class Notes
/. 9ully buffering.
>. Sin3"e record #u@@erin3&' -nly the records of a table which are actually accessed are
loaded into the buffer.
9or large tables where there are fre"uent single record accesses.
@. 1eneric #u@@erin3&' All the records in the buffer whose generic 7ey fields match this
record are loaded when one record of the table accessed.
/. /u"" #u@@erin3&' :he entire table will store in application server.
NOTE&' #ithout Cata element and Comain also we can create fields by clic7ing
(Predefine types).
Domain&' Comain defines which type of data and how much si5e need for a field.
Cata type 4 char 6.
No char 4 >? 6.
Decima" p"aces&' we can fill if you are giving pac7ed data type.
Output "en3th&' 8t automatically fills by system.
Conversion )outine&' Conversion ta7es place when converting the contents of a screen
field from display format to sap internal format and vice versa.
A conversion routine is identified by its five place name and is stored as a group of two
function modules (9!.
ConversionOE%itO=====Oinput&' it is the function module or conversion routine which is
used to convert e%ternal format to internal format.
ConversionOE%itO=====Ooutput&' it is the function module or conversion routine which
is used to convert a value from internal to e%ternal format.
Si3n&' 8f you flag then you can enter negative values CECB 9$:PB PDAN R CD33.
Lo5er case&' 8f you flag then it will distinguish small R capital letters which you entered
otherwise it will convert all the letter to upper case.
ABAP Page 12
Abap Class Notes
Ba"ue )an3e:2 you can enter fi%ed values with description or you can also give range of
values in this.
#e can define a list of fi%ed values for a domain. So that it will accept only those
values.
Any other values stored as error
:he use of fi%ed values is for validation
Salidation for a field can be done through foreing 7ey relation or fi%ed values in the
domain.
2ou can also provide value table in this tab.
Ba"ue ta#"e:2 Salue table is maintained at domain level . SoB that all table fields referring
to domain will be validate against a single table.
#henever we maintain chec7 table or master data name of domain level the system will
propose a foreign 7ey relation automatically by ma7ing the value table as a chec7 table.
Creatin3 Ba"ue ta#"e&'
.o to SE>>.
.ive the data base table name 4 6.
Clic7 on change
Select the field and respective data element and double clic7 on the data element and
double clic7 on domain and go to value range table and provide value table.
Bac7B bac7.
Eeep the cursor on the field and select the foreign 7ey.
8t will show a popup message and clic7 on (yes).
:he value table is connected as a chec7 table
Copy proposal
8f clic7 on (No)B no proposal will be generated.
So always clic7 yes.
Save and activate.
/orei3n =es:2 8t is used to define relationship between tables in the ABAP Cictionary.
Create value chec7s for input fields and lin7 several tables in a view or loc7 obJect.
/ie"d Assi3nment in the @orei3n =e:' A foreign 7ey lin7s two tables :> and :@ by
assigning fields of :> to the primary 7ey fields of table :@.
ABAP Page 13
Abap Class Notes
:able :> is called foreign 7ey table (dependent table. And table :@ is the chec7 table
(reference table.
:he pair of fields for the two tables must have same data type and length.
8nput valid because the entered value e%ist in the chec7 table.
Technica" )e'uirements to create a /orei3n =e&'
1. :he Comain names of the field in the foreign 7ey table and for the field in the chec7
table should be same.
!. :he field in the chec7 table should be primary 7ey.
Creatin3 a Chec= ta#"e&'
ABAP Page 14
Abap Class Notes
.o to SE>>.
Select data base table 4 6.
Select change.
Select the field for which we need to create chec7 table.
Clic7 on foreign 7ey.
.ive the details.
Provide the chec7 table nameB short te%t and clic7 on (.enerate Proposal) button.
:he system .enerates a proposal with the foreign 7ey and the entire primary 7ey field
from chec7 table whose domain name are same with the foreign 7ey Comain.
Chec7 table 4 :??F 6.
:??F mandt 7na> mandt
:??F land> 7na> land>.
Select radio button (non 7ey'fields * candidates).
.ive the cardinality as (C& CN).
Press enter or copy button foreign 7ey relation is established between two tables.
Save activate.
Di@@erence #et5een chec= ta#"e and va"ue ta#"e&'
Chec= ta#"e va"ue ta#"e.
8t defines at field level it defines at domain level by giving
By using foreign 7ey fi%ed values.
Ta#"e maintenance 3enerator&' it is used to maintain the bul7 amount of data.
!aintenance means creationB deletionB modification of the records. 8t is also used
for validating the table records by using the events.
.o to SE>> or S!/?.
Select data base table 4 6.
Clic7 on change.
Clic7 on utilities ', table maintenance generator.
Provide the details
Authori5ation group 4 RNCR6.
9unction group 4same table name you can give6.
!aintenance table Select the radio button (one step).
!aintenance screen no.
Clic7 on (propose screen number (it will create automatically by sap.
Save.
Bac7.
Activate the table.
Ba"idations 5ith T%1&'
By using the events available in :!. we can write the validation
:otally there are around /F to TF events are available
:o chec7 the events fallow the below steps
.o to SE>>.
.ive the table name 5%%% and clic7 on change
Clic7 on utilities', :!.
ABAP Page 15
Abap Class Notes
Clic7 on environment', modification', events
Clic7 on the button new entries
8n the first column of the table clic7 on search help button
All the events will be displayed
Event name te%t
> before saving the data in database
@ after saving the data in database
/ before deleting the data displayed
T after deleting the datat displayed
F creating new entry
UUUU.
Business re'uirement&'
3aise an error message when ever the customer number is entered and customer name is
blan7
Steps&'
go to utilities', table maintenance generator
clic7 on environment', modification ', events
clic7 on the new entries
create the element ?F i.eB create a new entry
give the form routine name as ;createOnewOrec< press enter
clic7 on the code to display the abap editor and write the below code
form createOnewOrec.
if 5cust'table'name> M ( (.
!essae (please enter customer name) type (E).
Endif.
Endform.
Save and activate
Clic7 on bac7 and clic7 on save
Clic7 on bac7 and clic7 on save
Clic7 on bac7
A message will be displayed as function group can)t be processed
Now go to SE0? and active the function group
Now test the table by entering customer number and leaving customer name as
blan7.
Properties o@ T%1:2
Authori&ation 3roup&'
8t specifies the group of users who have the access to maintain the table data
ABAP Page 16
Abap Class Notes
Authori5ation group is given by basis consultant
/unction 3roup&'
8t is a container of function modules which are generated by SAP when creating :!.
:hese function modules will contain the ABAP code for :!..
%aintenance tpe&'
8t specifies whether one screen * two screens to be displayed for maintaining the data.
One step:2
8f this option is selected only one single screen is displayed for maintaining the table
data.
T5o step&'
8f this option is selected only two screens are displayed for maintaining the table data.
)ecordin3 routine&'
8t is a routine which is used to read the table changes
8f standard record routine is selectedB all the changes are recorded by standard
routine.
8f no record routine is selected no changes are recorded.
8f user recording routine is available then those changes are recorded by user routine
Creation o@ TCODE to TABLE or T%1&'
.o to SEQ/.
Enter transaction code 41====%6.
Clic7 on create.
.ive description 4 6.
Select last radio button.
(:ransaction with parameters (parameter transaction.
Enter values.
:ransaction 4S!/?6.
Clic7 all the chec7 bo%es in the .D8 Support.
Provide the details below.
Name of Screen fields value.
S8E#NA! 5table name.
Dpdate =.
Save.
Structure&' structure is nothing but collection of fields.
ABAP Page 17
Abap Class Notes
Creatin3 structure.'
.o to SE>>.
Select data type 45str6.
Clic7 on create.
Pop up will show in that select the radio button (structure).
.ive the description 4 6.
Clic7 on (components) tab.
Create fields.
9ield name dataelement.
Save and activate.
Addin3 @ie"ds to a ta#"e&'
By using Append or 8nclude statement we can add fields to table.
.APPENC .8NC$DCE
>. By using append structure By using 8nclude structure we can add
the
#e can add the fields at the fields where ever we need in the middle
$ast of the table. Also.
@. Append structure is not reusable 8nclude structure is reusable across the
:able and in the table also.
/. Naming convention of the fields No restriction.
Should start with 11.
Addin3 @ie"ds to a ta#"e # usin3 .Append&'
.o to SE>>.
Select (Cata base table) 45===%6.
Clic7 on change.
Clic7 on (Append Structure) push button.
Clic7 on (create append).
.ive the append name 45=====%6.
Continue
.ive short description 4 6.
Clic7 on (components) tab.
.ive the field details which need to append.
Save activate.
Bac7.
Save and activate.
Addin3 @ie"ds to ta#"e # usin3 .Inc"ude&'
.o to SE>>.
Select data base table 45%%%%6.
Clic7 on change.
Place the cursor where you need to insert fields press plus symbol.
8t will show a blan7 line.
ABAP Page 18
Abap Class Notes
8n that line write.
.include 5%%%.
.ive the structure name which we already created.
Save and activate.
IndeCes&' :here are two types of inde%es are there. these are used to read the data from
database table with less spoon of time.
1. Primary inde%
!. Secondary inde%.
:he primary inde% is created by sap with all 7ey fields when we create table itself.
:he secondary inde% created by user to their own re"uirements.
Note&' !a%imum we can create Q inde%es.
A per the best programming techni"ue every select statement must contain all the 7ey
fields in the where condition.
8f non 7ey fields are used in the where condition then it will ta7e long time for
e%ecution.
So to improve the performance of the above statement creates an inde% on the above
non'7ey field called as secondary inde%.
Creatin3 secondar indeC&'
.o to SE>>.
Select data base table 45%%%%6.
Clic7 on change.
Clic7 on (inde%es) push button.
Clic7 on (create inde%).
.ive inde% name 4%%%6 only three letters and short description.
Select radio button (inde% on all database systems.
.ive the field name for which you need to create inde%.
!andt
Sbeln
Erdat
Save and activate.
NOTE&'After saving and activating the inde% it won)t available in database. :o do that
we need to adJust the database by using SE>T tcode.
AdDustin3 the data#ase ta#"es&'
.o to SE>T.
Enter obJect name 4 vba76.
ABAP Page 19
Abap Class Notes
Clic7 on (Edit) button.
Select (save data).
Clic7 on (Activate and adJust the data base).
Save.
Search he"p&'providing a help for the list of the values to be selected on input field is
called search help.
.iving 9T functionality to a field is called search help.
:here are two types of search helps.
1 Elementary search help&' A single search help for an input field is called elementary
search help.
! Collective search help&' group of elementary search helps for a single input field is
called collective search help.
Creatin3 E"ementar Search he"p:2
.o to SE>>.
Select (search help) 45%%%%6.
Clic7 on (create).
Select (elementary search help).
.ive short description 4 6.
Provide the fields.
Search help method 4 lfa>6.
Search helps parameter imp e%p lpos spos
!andt * * > >
$ifnr * @ @
$andt * / /
Save and activate.
Creatin3 co""ective search he"p&'
.o to SE>>.
Select (search help) 4 6.
Clic7 on create.
Select (collective search help)
.ive short description 4 6.
Provide the values
8n definition tab
$ifnr * * lifnr
$and> * * land>
Select (include search help) tab.
Provide the search help name which we create in elementary search help.
5===%.
Save and activate.
Assi3n search he"ps&'
#e can assign search help at the table level and program level.
ABAP Page 20
Abap Class Notes
Assi3n search he"p at pro3ram "eve"&'
%atch code o#Dect&'
8t is a statement use to assign custom search help by replacing the standard search
help if it is available.
8f standard search help is not availableB it will display the custom search help directly
Parameters& +pOname, type +table'fieldname, match code obJect +custom search
help name,.
E%&'
3eport 5%%%%.
Parameters& pOmatnr type mara'matnr matchcode obJect 5%%%%.
Assi3n search he"p at ta#"e "eve"&'
:here are / steps to be fallowed
Step>&' create a table.
Step@&' create a search help
Step/&' assign the search help to the table A field.
Step>&' create a table as below fields.
!atnr'5matnr (de
!tart'5mtart (de
!brsh'5mbrsh (de
!eins'5meins (de
Create some few records
Step@&' create a search help as below
Search help name & 5eO5mara
Selection method & 5mara
ABAP Page 21
Abap Class Notes
SK parameters are & !A:N3B !:A3:
Assign the SK to the table fields as below
Step/&' open the table 5mara
Select matnr field
Clic7 on search help button
.ive sh name as 5eO5mara
Clic7 on ;generate proposal<
Clic7 on ;copy<
Save activate and test it.
Search he"p properties&'
Se"ection method&' it specifies either the table name or view name so that the values can be
selected for search help.
LPOS&' 8t specifies the list position on the screen
SPOS:' 8t specifies the selection screen position of the field
Importin3&' if this chec7 bo% is selectedB the value is imported by list screen from the
selection screen.
ECportin3&' 8f this chec7 bo% is selectedB the selected value by the user will be e%ported form
list screen to the selection screen.
ABAP Page 22
Abap Class Notes
Dia"o3 tpe&' we have / options available here
Note&' dialog means screen in sap.
Disp"a va"ues immediate"&' the values are immediately displayed as soon as we clic7 on
the search help button
Dia"o3 5ith va"ue restriction&' the values are not displayed immediately but instead a screen
is displayed where you can put a filter value.
Dia"o3 depends on set o@ va"ues&'
8t is the combination of above two optionsB i.eB if the set of values are less than F??B the
values are immediately displayed.
8f the set of values are more than F?? a dialog screen is displayed.
;sin3 he"p vie5 in search he"ps&'
Step>&' create a help view with the fields !A:N3B !:A3:B SP3ASB !AE:= save and
activate
Step@&' create an elementary search help by the name 5%%%%.
Step/&' provide the selection method as 5%%%%% (viewOname.
StepT&' provide the search help parameter as belowB matnrB mtartB sprasB ma7ts.
ABAP Page 23
Abap Class Notes
StepF&' save activate and test it
StepN&' assign the search help at global level or field level.
Di@@erence #et5een E"ementar and Co""ective search he"p&'
1. Elementary SK describe a search path. :he elementary SK must define where the
data of the hit list should be read from (selection method. Kow the e%change of
values between the screen template and selection method is implemented (interface of
the SK and how the online input help should be defined (online behavior of the
search help.
!. Collective SK combine several elementary search helps. CSK thus can offer several
alternative search paths.
$. An elementary SK defines the standard flow of an input help.
(. A CSK combines several ESK. :he user can thus choose one of several alternative
search paths with collective SK.
*. A collective SK comprises several elementary SK. 8t combines all the search paths
that are meaningful for a field.
+. Both elementary SK and other SK can be included in a collective SK. 8f the collective
SK are contained in collective SKB they are e%panded to the level of the elementary
search help when the input help is called.
Note&' we can add search helps in Cata element and also in table and also in programs
means reports by using (!atch code obJect).
Tpe 1roups&'
8f we want to use same custom types (li7e tables B variablesB constants in various
programs then we can create a type group and declare the custom types in that type
group and use it where ever re"uired.
Several type groups are available in SAP for e%ample (ABAP)B (S$8S).
:o use this in program we use the 7eyword (:ype'pools).
E%&' :ype'pools S$8S.
Creatin3 tpe 3roup&'
ABAP Page 24
Abap Class Notes
.o to SE>>.
Select (type group) 45%%%%%6 (F letters.
Clic7 on create.
.ive the short description 4 6.
Chec7 (Dnicode conversion).
Clic7 on save button.
8n the (source code) tab.
#e can declare the variablesB constantsB types etc.
Save and activate.
Note&'Every type group structureB variableB constants start with name of the type group.
SntaC&' +name of the type group,O====.
Bie5s&' Siew acts li7e database table onlyB but it won)t occupy storage space. :here are T
types of views.
1. Cata base view.
!. ProJection view.
$. !aintenance view.
(. Kelp view.
Data#ase vie5:2 :hese are implemented with an e"uivalent view of the database view.
A view created on two or more tables data base tables using inner Join is called as
data base view.
Dsing data base view we can only read the data
#e can)t do any maintenance
:hese views are used to generate simple reports
ProDection vie5:' :hese are used to hide fields (only proJection
4e"p vie5:' :hese can be used as a selection method in search help.
%aintenance vie5:' Allows you to maintain the data distributed to several tables for one
application obJect at a time.
Creatin3 a Data#ase vie5:' Cata base view is created only with one tableB then you can
ma7e changes to the view. 8f it is with several tablesB only read access are allowed. 2ou
can use both open s"l and native s"l to access this view.
.o to SE>>.
Select Siews radio button and give the name 41otcOprc6.
Clic7 on create.
ABAP Page 25
Abap Class Notes
A popup will open choose (Catabase Siew).
Enter short description 4 6.
Enter the tables in the tables column
AF?/
E-NP
Eeep the cursor on the table name and clic7 the button (3elationship)
Popup comes where lin7ed tables are present.
Select the table and press (Copy).
Voin conditions.
AF?/ END!K M E-NP END!K
AF?/ !ANC: M E-NP !ANC:.
8n the (Siew fields) tabB we want to enter all the fields which we need in view. #e can
enter directly or we can copy from CB.
Clic7 on (:able 9ields) button it will show the above table select the table and enter it
will show all the fields from that table.
Select fields which you want and clic7 on copy.
Con)t repeat the fields which are common in both.
#e can also formulate the selection by selecting (Selection conditions) tab.
.ive tableB field and value.
Save and activate.
Chec7ing the definition of view&'
Clic7 on utilities', data base obJect', display
8t will display the SP$ statements.
Creatin3 proDection vie5&' :his is used to mas7 out (hide the fields from table. #e can
use only one table to create proJection view. #e can use this to read and write access with
open s"l.
.o to SE>>.
Select view 45otcOpvOson6.
Clic7 on create.
Select (proJection view).
.ive the description 4 6.
.ive base table 45otcOtOsonerpro6.
Clic7 on (:able fields) button to choose fields.
Select re"uired fields copy.
Save and activate.
%aintenance Bie5&'8t permits a business view on data and enables maintenance of this
data. 2ou can change it either with the table maintenance transaction S!/? or SEFT.
!ainly we use this view in module pool programming.
ABAP Page 26
Abap Class Notes
8t is a view which is created on multiple database tables using inner Join concept
#e can read the data and we can maintain the data
!aintenance view are specially designed for sap
#e don)t use maintenance views in real time becauseW maintenance should be done
through the sap screens or transaction codesB to maintain data integrity or data
consistency.
As per the best programming standards maintenance should be done through viewsB
as it involves updating multiple data base tablesB but in stand use sap transaction
codes
Steps to create maintenance vie5&'
.o to SE>>.
Select views 45otcO7otgF?@6.
Select (create).
Select (!aintenance view).
Enter description
Provide the following.
8n (table*Joins) tab
E-:.F?@
8n (view fields) tab
EAPP$ E-:.F?@ EAPP$.
Save and activate.
Kelp view&'
8t is a special type of view which is designed only for search helps
8t is a view created on two or more tables using outer Join concept
#e can)t e%ecute this view directly because it is only used with search helps.
#e can only read the data.
Steps to create he"p vie5&'
.o to SE>>.
.ive the view name 5%%%%
Clic7 on createB provide the descriptionB give the table name as !AE:B clic7 on
relation ships.
Select !AE:'!A3A
Clic7 on ;copy<
Clic7 on view fields tab.
Select the below fields
Siewfields table
!A:N3 !A3A
!:A3: !A3A
ABAP Page 27
Abap Class Notes
!B3SK !A3A
SP3AS !AE:
!AE:= !AE:
Provide the selection condition if any
Save and activate
Note&' we can)t use this view directly as it is used only with search helps.
Ta#"e tpe&'8t is nothing but internal table which creates in data dictionary.
.o to SE>>.
Select (Cata type) 45%%%%%%6.
Clic7 on create.
.ive short description 4 6.
Select the (line type (tab.
Select line type raiobutton 45otcOsOsubitem6.
$ine type is nothing but description.
Save and activate.
Loc= o#Dects&' Sap system will synchroni5es several users simultaneously access to the
same data records with loc7 mechanism.
$oc7 obJects generate two function modules.
En"ueueO+loc7 obJect name,B CE"ueueO+loc7 obJect name,. $oc7 obJects name should
start with E1 or E2 only.
.o to SE>>.
Select (loc7 obJect) 4E1======6.
.ive short description 4 6.
Select (:ables) tab.
Provide details
Name 45otcOiOt@Opland6.
$oc7 mode 4e%clusive not cumulative6.
Select (loc7 parameters) tab.
!andt 5otcOiOt@Oplamd.
Sbeln 5otcOiOt@Opland.
4o5 to use the "oc= o#Dects in pro3ram&'
Call function (ENPDEDEOE1-:CO:O8@OP$ANC).
CeleteB !odifyB 8nsertB etc.
Commit wor7.
Call function (CEPDEDEOE1-:CO:O8@OP$ANC).
ABAP Page 28
Abap Class Notes
Loc= modes&'
1. E%clusive loc7s&' :he loc7ed data can be displayed or edited by one user only.
3e"uest for any other loc7 is reJected.
!. Shared loc7s&' Several users have simultaneous read access to the same data.
3e"uest for e%clusive loc7 is reJected and shared loc7 accepted.
$. E%clusive but not cumulative&' 8t can be re"uested once by the same transaction.
Each further loc7 re"uest will be reJected.
Tpes o@ Ta#"es&' :here are / types of tables.
1. :ransparent table.
!. Pool table.
$. Cluster table.
Poo" ta#"e:2
:he tables are used to store the system data such as screen se"uenceB statistical dataB
hierarchal data etc.
:his tables will have many'to'one relation ship between a table created in data
dictionary and a table in data base
:he name of the table which is created in data base is called table pool
:he structure of table pool is as below
>. :able name ' this field stores the name of pooled table e%& P:>.
@. Sar7ey ' this field stores the 7eyfields of pooled table e%& E9>
/. Cataln A this field stored the length of pooled table e%& NF? 7b
T. Sardata A this field stores the data of pooled table e%& 5abcd.
E%amples&' mOmtvmaB mOmtvmbB mOmverbB mOmverc.
C"uster ta#"e&'
:hese tables are also used to store the system data
:hese tables are same as pooled tables but the structure of cluster table is different
from pooled table
:hese tables also have many'to'one relationship.
:he structure of table cluster will contain below fields
>. :abname
@. Sar7ey
/. Cataln
T. Sardata
F. Pageno A this field stores the page no of data
N. :ime stamp A this field stores the dateB timeB user name of person created the data.
E%amples&' BSE.B BSESB BSECB ADA2B ADAA.
ABAP Page 29
Abap Class Notes
Di@@erence #et5een transparent poo" and c"uster ta#"es&'
Transparent ta#"e&'
>. Contain a single table used to store master data.
@. 8t has one'to'one relationship with a table in the database.
/. 9or each transparent table there is a one associated table in the data base.
T. :he database table has the same nameB same number of fields and the fields have
the same names.
F. :hey is only single table.
N. Single table can have one or more primary 7ey.
G. Secondary inde%es can be created (ma% Q.
0. :hey can be accessed using open or native SP$.
Q. DSE&' they are used to hold master data.
>?. E=&' table vendors or table for customers e%ample of transaction data is orders
placed by customers.
Poo" ta#"e&'
1. :hey are used to hold a large number of very small tables (stores customi5ing
data or system data.
!. 8t has many'to'one relationship with a table in the database.
$. 8t is stored with other pooled tables in a single table called table pool in the
database.
(. :he database table has different name and different number of fields and fields
has different names.
*. :able pool contains more tables than table cluster.
+. Primary 7ey of each table does not begin with same fields or fields
,. Secondary inde%es cannot be created.
-. :hey can be accessed using open SP$ only.
.. DSE&' :hey reduce the amount of database resources needed when many small
tables have to be opened at the same time.
C"uster ta#"e&'
1. :hey are used to hold data from a few numbers of large tables (stores system
data.
!. 8t has many'to'one relationship with a table in the database.
$. !any cluster tables are stored in a single table in the database called table
cluster.
(. :he database table has different nameB different number of fields and fields have
different names.
ABAP Page 30
Abap Class Notes
*. Contains less tables than pools.
+. Primary 7ey of each table begins with same fields or fields.
,. Secondary inde%es cannot be created.
-. :hey can be accessed using open SP$ only.
.. DSE&' they would be used when the tables have primary 7ey in common and data
in this tables are all access simultaneously.
Creatin3 a ta#"e poo"&'
.o to se>>.
Select the radio button database table.
Select the (utilities) and (other dictionary obJects) from the menu bar.
Select the radio button (table pool or cluster) and provide the name.
Clic7 on create.
8t shows a pop up bo% with two options choose (table pool) radio button.
Clic7 on continue.
.ive the short description.
!odify the length of the fields if you want.
.o to ', technical setting in the menu bar and provide the si5e category.
Save chec7 and activate.
Note&' Same steps we need to fallow to create table cluster. 9allow the below steps to
create cluster table.
Creatin3 a poo" ta#"e&'
.o to se>>.
Select the radio button and create a table how you are creating a database table then
Select E%tras', Change table category in the menu bar.
Choose pooled table radio button.
Clic7 on delivery and maintenance tab and provide the table pool name which we
created earlier.
Save chec7 and activate.
Data tpes o@ ABAP&'
ABAP Page 31
Abap Class Notes
SntaC o@ Inte3er:2
Cata +variable name, type 8.
E%&'
Cata A type i.
:he initial value of integer is ?.
SntaC o@ Pac=ed decima"&'
Cata +variable name, type p decimals +num,.
E=&' Cata A(F type p decimals @.
:he initial value of pac7ed decimal is .??.
SntaC o@ /"oat&'
Cata +variable name, type f.
E=&'
Cata A type 9.
:he initial value of float is ?.??.
SntaC o@ char&'
ABAP Page 32
Abap Class Notes
Cata +variable name, type c.
E=&'
Cata A(>? type c.
:he initial value of char is space.
SntaC @or numeric char N&'
Cata +variable name, type N.
E%&'
Cata A type N.
:he initial value of N is ?.
SntaC o@ Date&'
Cata +variable name, type C.
E%&'
Cata A type C.
:he initial value of Cate is ????????.
:he initial format is yyyy mm dd.
SntaC o@ Time&'
Cata +variable name, type :.
E%&'
Cata A type :.
:he initial value of time is ??????.
:he initial format is hh mm ss.
Di@@erence #et5een pac=ed decima" and /"oat&'
ABAP Page 33
Abap Class Notes
Pac=ed decima"&'
Pac7ed data types will round off the value to its nearest value.
Pac7ed data types supports the selection screen.
/"oat&'
9loat data types doesn)t round off the value.
9loat data types doesn)t support the selection screen.
Conditiona" Statements&'
>. 8fU..Endif*if U..elseUU..endif * if UU.elseifUUUelseUUUendif.
@. CaseU.whenUU..endcase.
Synta%&'
>.8f +condition,.
+Statement bloc7,.
Endif.
E%&'
8f pOday M >.
#rite (Sunday).
Endif.
/. if +condition,.
+statement bloc7,.
Else.
+statement bloc7,.
Endif.
E%&'
8f pOday M >.
#rite (Sunday).
ABAP Page 34
Abap Class Notes
Else.
#rite (!onday).
Endif.
T. 8f +condition,.
+statement bloc7,.
Elseif +condition,.
+statement bloc7,.
Else.
+statement bloc7,.
Endif.
E%&'
8f pOday M >.
#rite (Sunday).
Elseif pOday M @.
#rite (!onday).
Else.
#rite (:uesday).
Endif.
F. Case +field,
#hen +field>,.
+statement bloc7,.
#hen +field@,.
+statement bloc7,.
#hen others.
+statement bloc7,.
Endcase.
E%&'
Case pOday.
#hen >.
#rite (Sunday).
ABAP Page 35
Abap Class Notes
#hen @.
#rite (!onday).
.
.
.
#hen others
#rite (invalied input).
Endcase.
Loopin3&'
>. conditional (Co'Enddo.
@. Dn conditional (#hile'Endwhile.
SntaC&'
1 DO statement&'
Co +N, times.
;
;
Enddo.
E%&'data count type i.
Co >? times.
Count M count I >.
#rite count.
Enddo.
-*P&'
ABAP Page 36
Abap Class Notes
> @ / T F N G 0 Q >?.
3. 6hi"e statement&'
#hile +condition,.
;
;
endwhile.
E%&'data count type i.
Count M >.
#hile count +M >?.
Count M count I >.
#rite count.
Endwhile.
-*P&'
> @ / T F N G 0 Q >?.
4. LOOP statement&'
These statements are used to e%ecute the same set of statements again and again.
8n single words all the repeatable statements are placed in a loop.
Synta%&'
$oop at +itab, into +wa,.
UUU..
UUUU..(statements
UUU
Endloop.
E%&' loop at itOvba7 into waOvba7.
#rite&* waOvba7'vbelnB
ABAP Page 37
Abap Class Notes
#aOvba7'erdat.
Endloop.
S2indeC&' it is a system variable which holds the loop iteration counter i.eB whether it is
first iteration or second iteration etc.
EC&' while vOcount + ?.
6rite& X sy'inde%.
SOcount M vOcount I >.
Endwhile.
EEIT&' this statement is used to e%it the loop.
SntaC&' e%it.
EC&' data vOcount type i.
SOcount M >.
Co >? times
#irte&X vOcount.
SOcount M vOcount I >.
8f sy'inde% M F.
E%it.
Endif.
Enddo.
Continue:' this statement is used to continue the ne%t iteration by bypassing all the below
statements under it.
Synta%&' continue.
E%&' data vOcount type i.
ABAP Page 38
Abap Class Notes
SOcont M >.
Co >? times.
8f sy'inde% M F.
SOcount M vOcount I >.
Continue.
Endif.
#rite&X vOcount.
SOcount M vOcount I>.
Enddo.
Parameters:'
8t is a 7eyword used to create single input fieldB chec7 bo%B and radio buttons on the selection
screen.
Synta%&' parameters +variable,(length type +data type,.
E%&'
Patameters pOvbeln type i.
De@au"t&'
Cefault is a 7ey word to provide the default values to the input field.
Synta%&' parameters +variable, type +data type, default +value,.
E%&'
Parameters a type 8 default @?.
O#"i3ator&'
ABAP Page 39
Abap Class Notes
-bligatory is 7ey word to provide the input field as the mandatory.
Synta%&' parameter +variable name, type +data type, obligatory.
E%&'
Parameter A type 8 obligatory.
Chec= #oC&'
Synta%&' Parameters +name, as chec7bo%.
E%&' parameters A as chec7bo%.
)adio #utton&'
Parameters name is created with type c and length > and is assigned to group +.>,.
Each group has at least two radio buttons and by default the first radio button from the group
is selected.
Synta%&' parameters +name, type c radiobutton group'name +gOname, default (%) .
E%&' parameters& pOrb> radiobutton group abcB
POrb@ radiobutton group abcB
POrb/ radiobutton group abc default (=).
Se"ect2options&'
Parameters accept only single value but select'options will accept range of values.
Synta%&' data var> tpe +data type,.
Select'options +var@, for +var>,.
e%&' data f type i.
Select'options g for f.
8t consist of lowB highB signB option.
ABAP Page 40
Abap Class Notes
Si3n&'
Possible values are 8 and E.
8 stands for ;inclusive<.
E stands for ;e%clusive<.
Option&'
Possible operators are
8f high is emptyB you can use EPB NEB .:B $EB $:B CP and NP.
8f high is filledB you can use B: and NB.
)estrictin3 entr to one ro5:2
Synta%&' select'options +variable, for +variable, no'e%tension.
E%&' select'options sOlifnr for vOlifnr no'e%tension.
)estrictin3 entr to sin3"e @ie"ds&'
Synta%&' select'options +variable, for +variable, no'intervals.
E%&' select'options sOlifnr for vOlifnr no'intervals.
Note&' by using select options we can define not only range of values but also.
>. #e can also define multiple single values. (>?B >@B >FBU..
@. #e can define multiple single ranges. (>?'>FB >G'@?BUU..
/. #e can e%clude multiple single values.
T. #e can e%clude multiple single ranges.
Se"ection2screen s=ip FnG:29 #"an= "ines<.
:o print blan7 lines in selection'screen.
Synta%&'Selection'screen s7ip 4n6.
#here n is number of lines.
E%&' selection'screen s7ip @.
ABAP Page 41
Abap Class Notes
Se"ection2screen u"ine&'
:o print hori5ontal line.
Synta%&' selection'screen uline 4*6+pos(length,.
E%&' selection'screen uline *>?(/?.
Se"ection2screen #e3ins o@ #"oc=&'
Synta%&' selection'screen begin of bloc7 +Bloc7 name, with frame title +te%t(n,.
Selection'screen end of bloc7 +bloc7 name,.
Se"ection2screen comment&'
:his statement is used to provide custom label for a selection screen field.
Synta%&' selection'screen comment 4*6+pos(length, +comm, 4for field +f,6.
:his statement writes the +comm, comment on the selection screen. 9or +comm, B you can
specify te%t symbol. 2ou must always specify the +pos(len, addition.
-nly if there are several elements in one lineB can you omit+pos,.
:he te%t +comm, will be displayed starting in column +pos,B for a length of +len,. 8f you
do not use a slash(* the comment is written into the current lineB otherwise a new line is
created.
2ou use for field +f, to assign a field label to the comment. +f, can be the name of a
parameter or a selection criterion (select'option.
E%&' selection'screen begin of line.
Selection'screen comment @(>? te%t'??/.
Parameters& pOland> type 7na>'land>.
Selection'screen comment @?(>? te%t'??T.
Parameters& pOmtart type mara'mtart.
Selection'screen end of line.
ABAP Page 42
Abap Class Notes
Bariant&'
8t is an obJect which is used to store selection screen field valuesB for future reference.
.enerally we create variants for the test cases.
Create a program with parameters statements as below.
Parameters& pOland> type 7na>'land>B
POmtart type mara'mtart.
Clic7 on e%ecute.
Enter the values as below.
POland> 4us6.
POmtart 4fert6.
Clic7 on save button.
.ive the name as 4test>6.
:his test> is called a variant.
Similarly create variant @.
i.eB test@.
An icon will be visible on the selection screen to display list of variants.
Se"ection screen test&'
By default when ever we create a selection screen all the fields in the selection screen
will be displayed with technical names.
:o avoid thisB we need to maintain selection screen te%t.
Step>&' open SE/0 program.
Step@&' clic7 on (goto) ', te%t elements', selection te%ts
Step/&' in this we provide our own te%t or we can copy the te%t from data dictionary.
Name te%t data dictionary
POland> country
POmtart material type (chec7 the bo%).
StepT&' save activate and te%t the program.
ABAP Page 43
Abap Class Notes
!.Interna" ta#"es:2
8t is an instance of data base table. 8t is temporary memory location which is used to store
the data of data base table. By default 07b si5e will be allocated to internal table and if will
increase dynamically based on the data. 8nternal table store multiple records. Pushing data
to the internal table or reading the data from the internal table is always record by record i.eB
through 5or= area&' 8t is also a temporary memory location which can store a single record
Sariable&' it is also a temporary memory location which stores a single value.
Di@@erence #et5een interna" ta#"e and data #ase ta#"e&'
Data #ase ta#"e interna" ta#"e
>. Cata base table are permanent >.internal tables are temporary storage
!emory location. $ocation.
@. Scope is global that means we @. :he scope of the internal table is upto
Can access the CB table from the program.
Any where in the abap.
/. #e must provide the si5e category /. #e no need to provide si5e category to
:he internal table.
SntaC @or dec"arin3 the interna" ta#"e and 5or= area&'
>. Cata +itab, type standard table of +CB table,.
Cata +wa, type +CB table,.
E%&' data itOvba7 type standard table of vba7.
Cata waOvba7 type vba7.
8n this case the internal table will have all the fields of standard table vba7.
@. Cata +itab, type table of +user defined type,.
Cata +wa, type +user defined type,.
Kere user define type can be defined by ;types< 7ey word.
Synta%&' types& begin of +structure,B
+ 9ield, type +CB'field,B
+field, type +data element,B
ABAP Page 44
Abap Class Notes
End of +structure,.
E%&' types& begin of tyOvba7B
Sbeln type vbelnOdaB
Erdat type vba7'erdatB
End of tyOvba7.
Cata& itOvba7 type table of tyOvba7.
Cata waOvba7 type tyOvba7.
8n this e%ample the internal table and the wor7 area consist of only two fields by name vbeln
and erdat.
/. Cata +itab, type +dbtable, occurs ? with header line.
E%&' data itOvba7 type vba7 occurs ? with header line.
8n this case no need to create wor7 area internal table implicitly creates a header line
which acts li7e wor7 area.
T. Cata+itab, type +userdefined table, occurs ? with header line.
Se"ect the data @rom data#ase ta#"e into interna" ta#"e&'
#e can pull the records of data base table in to internal table by using select statements.
Synta%&'
>. Select H from +db table, into +wa,.
Append +wa, to +db table,.
Endselect.

E%&' select H
9rom vba7
ABAP Page 45
Abap Class Notes
8nto waOvba7.
Append waOvba7 to itOvba7.
Endselect.
8n this e%ample it will pull all the records one by one places into wor7 area and it is add the
records to internal table by using append statement.
@. Select +f>,
+f@,
.
.
.
9rom +db table,
8nto +wa,.
Append +wa, to +itab,.
Endselect.
E%&' select vbeln
Erdat
9rom vba7
8nto waOvba7.
Append waOvba7 to itOvba7.
End select.
8n this e%ample it will pull all the records of vbeln and erdat into wor7 area and add this to
internal table by using append statement.
/. Select H
9rom +db table,
8nto table +itab,.
E%&' select H from vba7 into table itOvba7.
8n this e%ample it will pull all the records into internal table in one iteration.
T. Select H
9rom +db table,
8nto +itab,
Dp to +n, rows.
ABAP Page 46
Abap Class Notes
E%&' select H from vba7 into table itOvba7 up to >? rows.
8n this e%ample it will pull first >? records from the data base table to internal table.
F. Select H
9rom +db table,
8nto table +itab,
#here +conditions,.
E%&' select H from vba7 into table itOvba7 where vbeln M (>@@/@).
8n this e%ample it will chec7 the condition and according to the condition it will pull the
records from data base table into internal table.
N. Select H
9rom +db table,
8nto corresponding fields of table +itab,
#here +condition,.
E%&' select H from vba7 into corresponding fields of table itOvba7 where vbeln M (>@/T).
8n this case if the structure of internal table and data base are different then also it is also fill
the corresponding fields.
G. Select single +field>,
+field@,
8nto +wa,
9rom +db table,
#here +condition,.
E%&' select single vbeln erdat into waOvba7 from vba7 where vbeln M (>@/).
8t will pull the e%act maching single record from the data base table.
0. Select +field>,
+field@,
8nto +wa,
Dp to > row
9rom +db table,
#here +condition,.
Endselect.
E%&' select vbeln erdat into waOvba7 up to > row from vba7.
Endselect.
ABAP Page 47
Abap Class Notes
8n this e%ample it will pull the first matching record.
Note:'
8f all the 7ey fields are available in your program then use select single. 8t is very fast.
8f only some 7ey fields are available then use the selected up to one row. it is slow.
6or=in3 5ith Doins&'
8n relational databaseB you normally need to read data simultaneously from more than one
database table into an application program. 2ou can read from more than one table in a
single select statement via Joins.
:here are two types of Joins.
>. 8nner Join.
@. $eft outer Join.
Synta%&' select +dbt>,Y+f>,
+dbt>,Y+f@,
+dbt@,Y+f/,
+dbt@,Y+fT,
8nto table +itab,
9rom +dbt>, inner Join*left outer Join
-n +dbt>,Y+f>, M +dbt@,Y+f@,
#here +conditions on fields from dbt> and dbt@ (if re"uired,.
Inner Doin&'
:he Join e%pression lin7s each line of +dbt>, with the lines in +dbt@, that meet the Join
condition +cond,. :his means that there is always one or more lines from the right hand
table that is lin7ed to each line from the left hand table by the Join. 8f +dbt@, does not
ABAP Page 48
Abap Class Notes
contain any lines that meet the Join conditions +cond,B the line from +dbt>, is not included
in the selection.
Le@t outer Doin&'
8n an inner JoinB a line from the left'hand database table or Join is only included in the
selection if there is one or more lines in the right'hand database table that meet the on
condition +cond,. :he left outer JoinB on the other hand reads lines from the left'hand
database table or Join even if there is no corresponding line in the right'handle table.
E%&'select vba7Yvbeln
Sba7Yerdat
SbapYposnr
SbapYmatnr
8nto table itOvba7p
9rom vba7 inner Join vbap
-n vba7Yvbeln M vbapYvbeln
#here vba7Yvbeln in sO7unnr.
/or a"" entries:2
:his statement is used to replace inner Joins or select with Joins it is used to read the data
from one or more than / tablesB it can be used to read the data from @B/BT etc. it doesn)t put
any load on the data base.
Synta%&' select H
9rom +db table>,
8nto table +itab>,
#here +condition,.
8f not +itab>, is initial.
ABAP Page 49
Abap Class Notes
Select H
9rom +dbtab@,
8nto table +itab@,
9or all entries in +itab>,
#here +field>, M +itab>,'+field>,.
Endif.
E%&' select bu7rs
Belnr
=blnr
Budat from b7pf
8nto table itOb7pf
#here belnr in sObelnr.
8f not itOb7pf is initial.
Select bu7rs
Belnr
.sber
Eunnr from bseg
8nto table itObseg
9or all entries in itOb7pf
#here belnr M itOb7pf'belnr.
Endif.
Prere"uisite for for all entries is to chec7 the base table is initial or not.
ABAP Page 50
Abap Class Notes
Tpes o@ interna" ta#"es&'
:here are / types of internal tables they are.
>. standard table
@. sorted table
/. Kashed table.
>. standard ta#"e&' :hese are the default internal tbale. :he 7ey of a standard table is
always non'uni"ue so duplicates are allowed.
Synta%&' data +itab, type standared table of +ty,.
3ecords can be accessed through both inde% and condition.we can sort the table n
number of times.
E%&' data itOvba7 type standared table of vba7.
@. Sorted ta#"e&' 8n the sorted internal table records are always in sorted order.
3ecords can be accessed through both inde% and with 7ey (condition.
Sorted internal tables cannot be sorted again.Sorted internal tables are alwaysB either
uni"ue * non uni"ue.
Synta%&' data +itab, type sorted table of +ty, with uni"ue * non uni"ue 7ey +f>,
+f@,U
/. 4ashed ta#"es&' Kashed tables are non inde% tables hashed table always have a
uni"ue 7ey. 2ou can not access a hashed table using its 8NCE=.
Synta%&' data +itab, type hashed table of +ty, with uni"ue * non uni"ue 7ey +f>,
+f@,..
List o@ the interna" ta#"e operations&'
>. Append
@. 8nsert
/. Sort
T. Cescribe table
F. 3ead table
N. $oop at +itab,
G. !odify
0. Celete
Q. clear
>?. refresh
>>. free
>@. collect
>/. move'corresponding
>T. append lines of
>F. insert lines of
Append:' this statement is used to add a single record form wor7 area to internal table.
ABAP Page 51
Abap Class Notes
Synta%&' append +wor7 area, to +internal table,.
E%&' waO7na>'7unnr M (>@/).
#aO7na>'land> M (CE).
#aO7na>'name> M (ramesh).
Append waO7na> to itO7na>.
Note:' the record will always added at the bottom of the internal table.
Insert&' this statement is used to insert the record form wor7 area into internal table at
specified location.
Synta%&' insert +wa, into +itab, inde% +no,.
E%&' waO7na>'7unnr M (>@/).
#aO7na>'land> M (CE).
#aO7na>'name> M (ramesh).
8nsert waO7na> into itO7na> inde% /.
Sort:' this statement is used to sort the internal table data either in ascending order or
descending order.
Synta%&' sort +itab, by +f>, +f@, +f/, U.. +Ascending * descending,.
E%&' sort iO7na>.
Sort iO7na> by name>.
Sort iO7na> by land> descending.
Note&' the sort statement sorts the data by acceding order by default.
8t will sort based on the order of the fields i.eB 9>B9@B9/U.
Descri#e ta#"e&' this statement is used to find the total number of records in the internal
table.
Synta%&' describe table +itab, lines +var'name,.
ABAP Page 52
Abap Class Notes
E%&' data vOlines type i.
Cescribe table iO7na> lines vOlines.
#rite&* (total number of lines)B vOlines.
)ead ta#"e&' this statement is used to read a single record from internal table into wor7 area.
:here are two forms of read statements.
>. 3ead table with inde%.
@. 3ead table with 7ey.
>. )ead ta#"e 5ith indeC&'
:his statement will read the record specified by the inde% no into wor7 area.
Synta%&' read table +itab, into +wa, inde% +no,.
E%&' read table itO7na> into waO7na> inde% /.
!. )ead ta#"e 5ith =e&'
:his statement will read single record from internal table into wor7 area one which is
specified by the field values.
Synta%&' read table +itab, into +wa, with 7ey +fname>, M +value,
+fname@, M +value,UUUUUU Binary search.
Note:':he prere"uisite for the above statement isB the internal table should be sorted.
E%&' sort iO7na>.
3ead table iO7na> into waO7na> with 7ey 7unnr M (vinay)
Binary search.
Search&' we are having two types of search
>. $inear search.
@. Binary search.
ABAP Page 53
Abap Class Notes
>. Linear search&' in linear search the search will be happen line by line so it will ta7e more
time while searching the record.
@. Binar search&' the binary search will divide the entire internal table into tow half)s. :hen
it will search for the record roughly either in first half or in the second half.
8t the record is available in the first half then it will again divide the first half into two parts
by deleting the second half.
Again it will search roughly either in first half or second half. :he procedure will continuous
until it finds the e%act record.
So it is faster than linear search and it will improve the performance of the read statement.
Loop and End"oop&' this statement is used to read multiple records from internal table into
wor7 area one by one.
Synta%&' loop at +itab, into +wa,.
UUUU..
BUUUUUU
Endloop.
E%&' loop at itO7na> into waO7na>.
#rite&X waO7na>'7unnrB waO7na>'land>.
Endloop.
Synta%&' loop at +itab, into +wa, from +n>, to +n@,.
UUUU.
Endloop.
#here n> and n@ are the inde% numbers.
E%&' loop at itO7na> into waO7na> from > to >?.
#rite&X waO7na>'7unnrB waO7na>'land>.
ABAP Page 54
Abap Class Notes
Endloop.
Synta%&' loop at +itab, into +wa, where +filed>, M +value,
+field@, M +value,.
UUUUU.
Endloop.
E%&' loop at itO7na> into waO7na> where land> M (DS).
#rite&X waO7na>'7unnrB waO7na>'land>.
Endloop.
%odi@:' this statement is used to modify a single record or multiple records based on the
condition.
Synta%&' modify +itab, from +wa, inde% +no, transporting +f>, +f@, U..
E%&' sort itO7na> by 7unnr.
3ead table itO7na> into waO7na> with 7ey 7unnr M (>@/)
Binary search.
#aO7na>'name> M (sony).
#aO7na>'land> M (8N).
!odify itO7na> from waO7na> inde% sy'tabi% transporting name> and land>.
S2ta#iC&' it is a system variable which holds the inde% number of the internal table which is
currently process.
De"ete&' this statement is used to delete the data from internal table .
Synta%&'
delete +itab, from +wa,.
Celete +itab, inde% +no,.
ABAP Page 55
Abap Class Notes
Celete +itab, where +f>, M value
+f@, M valueU..
De"ete adDacent dup"icates&' this statement is used to delete the duplicate records which one
adJacent isB side by side to each other.
:he prere"uisite to this statement is the internal table should be sorted.
Synta%&' delete adJacent duplicates from +itab, comparing +f>, +f@, +f/, U.all fields.
E%&' delete iO7na> inde% /.
E%&' delete iO7na> where 7unnr M (>@/).
E%&' sort iO7na>.
Celete adJacent duplicates from itO7na> comparing all fields.
C"ear&' this statement is used to delete the data from a variable or wor7 area or internal
table.
Synta%&' clear +variable name,.
Clear +wor7 area,.
Clear +itab,46.
E%&' clear vOname.
E%&' clear waO7na>.
E%&' clear itO7na>46.
8t will clear the body of internal table itO7na>.
)e@resh&' this statement is used to delete the data from internal table only.
Synta%&' refresh +itab,.
E%&' refresh itO7na>.
/ree&' this statement is similar to clear and refresh. i.eB it will also delete the data from a
variableB wor7 area and internal table.
ABAP Page 56
Abap Class Notes
:he difference is B with the clear and refresh statement the data will be deleted but not he
memory. #ith the free statement the data will be deleted and memory also deleted.
Synta%&' free +varOname,
9ree +wa,.
9ree +itab,.
E%&' free vOname.
E%&' free waO7na>.
E%&' free itO7na>.
Co""ect&'
8t similar to append statement
:he difference between append and collect isB the collect statement chec7s whether
the wor7 area record already e%its in the internal table or not.
8f it e%its it will add the numerical field.
8f it doesn)t e%its it will add new record to the internal table. :hat is similar to
append.
Synta%&' collect +wa, into +itab,.
E%&' collect waO7na> into itO7na>.
Append "ines o@ &' this statement is used to add multiple records from one internal table to
another internal table.
Synta%&' append lines of +itab>, from +n>, to +n@, to +itab@,.
E%&' append lines of itO7na> from / to N to itO7na@.
Insert "ines o@ &' this statement is used to add the data from one internal table to another
internal table at a specified inde% number.
Synta%&' insert lines of +itab>, from +n>, to +n@, into +itab@, inde% +no,.
E%&' insert lines of itO7na> from N to 0 into itO7na@ inde% /.
%ovin3 data @rom one interna" ta#"e to another interna" ta#"e&'
ABAP Page 57
Abap Class Notes
>. 8tab@46 M itab>46. (best processing.
@. $oop at itab> into waOitab.
#aOitab@'f> M waOitab>'f>.
#aOitab@'f@ M waOitab@'f@.
UUUU
Append waOitab@ to itab@.
Endloop. (bad processing.
%ove correspondin3&'
:his statement is used to move the data for corresponding fields from one wor7 area to
another wor7 area.
Synta%&' move corresponding +wa>, to +wa@,.
E%&' loop at itO7na> into waO7na>.
!ove corresponding waO7na> to waO7na@.
Append waO7na@ to itO7na@.
Endloop.
:his statement is not advisable because it need to compare each field from source
wor7 area to target wor7 area.
%ove&'
:his statement is used to move the data from source to target individual fields.
Synta%&' move +wa>'f>, to +wa@'f>,.
E%&' loop at itO7na> into waO7na>.
!ove #aO7na>'7unnr to waO7na@'7unnr.
UU..
Append waO7na@ to itO7na@.
Endloop.
Statements dea"s 5ith data#ase&'
ABAP Page 58
Abap Class Notes
:he statements are used to update data base are.
>. 8nsert
@. !odify
/. Dpdate
T. Celete
Insert&'
8t is used to insert a single or multiple records from internal table to data base table.
Sy'subrc M ?B means all the records where successfully inserted.
Sy'subrc NE ?B means only few records are inserted or no records are inserted.
:here are two forms of insert statement.
>. 8nsert from table
@. 8nsert from table accepting duplicate 7eys.
Insert @rom ta#"e&'
:his statement will insert the records into database tables.
Suppose if there are only duplicate records in the internal table it will through the an
runtime error.
Insert @rom ta#"e acceptin3 dup"icate =es&'
8f we use this statement it will not through any runtime error even through it has
duplicate records.
8t is Just to use runtime error.
Synta%&'
8nsert +db table, from +wa,.
8nsert +db table, from table +itab,.
E%&' insert t??>w from waOt??>w.
E%&' insert t??>w from table itOt??>w.
%odi@:2
:his statement is used either to modify a record i.eB update or insert a new record.
8t will modify if the matching record found other wise insert the record.
Sy'subrc is always ? because it may modify or insert a new record.
ABAP Page 59
Abap Class Notes
Synta%&'
!odify +db table, form +wa,.
!odify +db table, from table +itab,.
E%&' modify vba7 from waOvba7.
E%&' modify vba7 from table itOvba7.
;pdate:'
:his statement will update the record which is available in the data base table.
Sy'subrc M ?. !eans if at least one record is updated.
Sy'subrc NE ?B means none of the record)s are updated.
:here are two forms for update statement.

Synta%&'
Dpdate +db table, from +wa,.
Dpdate +db table, from table +itab,.
E%&' update vbap from waOvbap.
E%&' update vbap from table itOvbap.
De"ete:'
:his statement is used to delete either a single record or multiple records from data
base table.
ABAP Page 60
Abap Class Notes
Sy'subrc M ? means all records are successfully deleted.
Sy'subrc NE ? means no records are deleted.
Synta%&'
Celete +db table, from +wa,.
Celete +db table, form table +itab,.
E%&' delete mara from waOmara.
E%&' delete mara from table itOmara.
Prere'uisites @or a#ove statements&'
Always wor7 with internal tables rather than wor7 areas to insert*update*modify data
into database table.
:he structure of internal table * wor7 area must be same as data base table.
E%&' data& iO7na> type standard table of 7na>.
Sstem varia#"es&'
:here are two system variables which are update automatic for each open s"l operations.
>. Sy'subrc.
@. Sy'dbcnt.
S2su#rc&'
8t is a system variable which stores the return code of an open s"l operation.
8f sy'subrc M ?. 8t menas the operation is successfully e%ecuted.
8f sy'subrc NE ?. 8t means the operation is failed.
S2d#cnt&'
8t is a system variable which stores the number of records successfully processed.
Note&' apart form these two we are having so many system variables which we can see in syst
table.

ABAP Page 61
Abap Class Notes
/.%odu"ari&ation.
!odulari5ation is a better techni"ue of dividing a main program in sub programs for a better
readability and reusability is called modulari5ation. !odulari5ation is achived using the
fallowing techni"ue.
>. 8nclude programs
@. 9unction modules
/. Subroutines
T. !acros (used in K3'ABAP module.
F. Class methods (used in --ABAP.
Inc"ude pro3rams&'
:hese programs contain a set of reusable statements.
:hese can not be e%ecuted independently.
:hese must be inserted in the main program for e%ecution
:hese programs are called as type (8) programs.
8t does not contain any parameters interfaces i.eB no importing no e%porting
parameters.
E%&' SAP!STFA is the standard program for sales order which contains n number of
include programs.
8nclude 5mainOprogOtop.
Creatin3 a inc"ude and ca""in3 the inc"ude in the eCecuta#"e pro3ram&'
.o to SE/0 and provide the progam name 45%%%%%%%%%6.
Clic7 on create.
.ive the description and in the program type select the type as ;include program<.
Clic7 on create
8t will create a program with the statement ;include 5%%%%.)
#rite the code which you want to reuse.
Save chec7 and activate.
.o to se/0 and provide the program name 5%%%%%%%%
Clic7 on create
.ive the description and in the program select the type as ;e%ecutable program<.
Clic7 on create
8t will create a program with the statement ;report 5%%%%).
Now in that program where ever you want write the code as
8nclude 5%%%%.
So that 8t will call the code at that position.
Save chec7 and activate.
ABAP Page 62
Abap Class Notes
/unction modu"es&'
8t is a repository obJects which contain ABAP logic or statements for doing a specific
tas7 or functionality.
9unction modules contain parameters interfaces i.eB importB e%portB changingB tables
etc.
:hese are mainly used for global modulari5ation.
9unction modules can be remote enable. i.eB they can access remote servers to fetch
the data.
9unction modules contain e%ceptions to catch certain type of errors.
/unction 3roup&'
8t is a group or container of function modules.
Every function module must be inserted in a function group.
/unction modu"e parameter inter@ace (se/G ro SE0?&'
Import&' input variables to function modules are called importing parameters.
ECport:' output variables from function modules are called as e%porting parameters.
Chan3in3&' variables which acts as importing and e%porting are called as changing
parameters.
Ta#"es&' internal tables which acts as importing and e%porting are called as tables
parameters.
ECceptions&' these are used to catch certain types of errors . E%ceptions are returns in sy'
subrc variable.
Source code&' it consist of ABAP code for doing a specific tas7.
Steps to create a @unction 3roup&'
#e can create function group either in SE/G*SE0?.
.o to SE0?
Select function group.
.ive the name as 5%%%%.
Press enter
Clic7 on yes
Provide the short description.
ABAP Page 63
Abap Class Notes
Clic7 on save
Activate the function group immediately.
Steps to create @unction modu"e&'
Business re"uirement&' develop a function module which displays customer details.
.o to SE/G.
.ive the name as 5%%%%%%.
Clic7 on create
.ive function groupB descriptionB clic7 on save
Provide the importing parameters as shown
8mO7unnr type 7na>'7unnr.
Provide the e%porting parameters as shown.
E%O7na> type 7na>.
Provide the e%ception as shown.
NoO7unnr type noO7unnr.
8nvalidO7unnr type invalidO7unnr.
#rite the below source code.
8f imO7unnr is initial.
3aise noO7unnr.
Else.
Select single H form 7na> into e7O7na>
#ehere 7unnr M imO7unnr.
8f sy'subrc M ?.
3aise invalidO7unnr.
Endif.
Endif.
SaveB activate and test it.
;sin3 @unction modu"e in pro3ram&'
Cata& waO7na> type 7na>.
Parameters& pO7unnr type 7na>'7unnr.
Call function (5%%%%)
E%porting
8mO7unnr M pO7unnr
8mporting
E%O7na> M waO7na>
ABAP Page 64
Abap Class Notes
E%ceptions
No'7unnr M >
8nvalid'7unnr M @
-thers M /.
8f sy'subrc M >.
!essage&)please enter customer no)B type (8).
Elseif sy'subrc M @.
!essage (please enter valied cust no)B type (8).
Elseif sy'subrc M /.
!essage (unprdictable error) type (8).
Endif.
#rite&* waO7na>'7unnrB waO7na>'name>.
Su#routines&'
Subroutines contains piece of ABAP code which one mainly used for readability and
reusability.
:hese one also used for local modulari5ation.
Synta%&' subroutines contains two steps.
>. Subroutine definition.
@. Subroutine implementation.
SntaC @or su#routine de@inition&'
Perform +subroutine, using +v>, +v@,
Changing +ch>, +ch@,
:bale +it>, +it@,.
SntaC @or su#routine imp"ementation&'
ABAP Page 65
Abap Class Notes
9orm +subroutine, using +v>, +v@,
Changing +ch>, +ch@,
:able +it>, +it@,.
UUU.
UUUU
UUUU.
Endform.
Tpes o@ su#routines&'
:here are two types of subroutines.
>. $ocal subroutine
@. .lobal subroutine
Loca" su#routine&' if subroutine definition and implementation i.eB perform and
formU..endform are available in same program then it is called as local sub routine.
1"o#a" su#routine&' if subroutine definition is available in one program and subroutine
implementation is available in another program then it is called as global subroutine or
e%ternal subroutines.
SntaC @or 3"o#a" su#routine&'
Perform +subroutine, program +program name,
using +v>, +v@,
Changing +ch>, +ch@,
:bale +it>, +it@,.
9orm +subroutine, using +v>, +v@,
Changing +ch>, +ch@,
:able +it>, +it@,.
ABAP Page 66
Abap Class Notes
UUU.
UUUU
UUUU.
Endform.
Parameters inter@ace or su#routines&'
;sin3&' 8mporting variables to sub routines one defined with using.
Chan3in3:' e%porting variables areB defined with changing.
Ta#"es&' internal tables for importing and e%porting one definition with tables.
Tpes o@ passin3 va"ues&'
:here are / types to send the values form subroutine definition to subroutine implementation.
>. Pass by value or call by value
@. Pass by reference
/. Pass by value and return.
Pass # re@erence&'
8n this typeB the actual and formal parameters will be referring to the same location.
8f any changes made to the formal parameters the actual parameters will also
effected.
ABAP Page 67
Abap Class Notes
Pass # va"ue&'
8n this type the actual and formal parameters will be referring to separate memory
locations.
8f any changes are made to the formal parameters it will not affect the actual
parameters.
Pass # va"ue and return&'
8n this type the actual and formal parameters will be referring to separate memory
locations.
8f any changes made to the formal parametersB the actual parameters will be changed
only when the last statement in the subroutine implementation or the entire subroutine
is e%ecuted.
ABAP Page 68
Abap Class Notes
ECamp"e on su#routine&'
Cata a type i.
A M >?.
#rite &* (before subroutine call (B A.
Perform passObyOref using A.
Perform passObyOvalue using A.
Perform passObyOvalueOreturn changing A.
#rite&* (after subroutine call)B A.
9orm passObyOref using fOa.
9Oa M fOa I >?.
Endform.
9orm passObyOref using value (fOa.
9Oa M fOa I >?.
Endform.
9orm passObyOvalueOreturn changing value (fOa.
9Oa M fOa I >?.
Endform.
ABAP Page 69
Abap Class Notes
Note&' creation for class and method are in the ooabap material.
%essa3es&'
All the messages are stored in a class called as message class.
SE>Q is the tcode for creating message class.
.enerally there will be a single message class for entire proJect.
%essa3e2id&'
8t is the 7eyword which is used to assign the message class to our report so thatB our
report can access all the messages in the message class.
Tpe o@ messa3es&'
:ype description
E error message
S success
# warning
8 information
A abort
Su#stutiona" parameters&'
(R) is the symbol use to substitute a variable or parameter in to the message.
#e can substitute a ma%imum of T substitution parameters.
Synta%&'
>. !essage +msg t%t, type +msg type,.
@. !essage +msg type, +msg no,
/. !essage +msg type, +msg no, with +su>,
+su@,
UUUU
Steps to create messa3e c"ass&'
.o to SEQ>.
.ive the name as 5%%%%.
Clic7 on create.
ABAP Page 70
Abap Class Notes
.ive description.
Clic7 on message tab.
Cefine the message as below.
!essage message short te%t.
? material does not e%it.
??> material number R does not e%it.
??@ R R R R
', clic7 on save.
;sin3 messa3e c"ass in report&'
3eport 5%%%%%% message'id 5%%%%%.
Cata waOmara type mara.
Parameters& pOmatnr type mara'matnr.
Select single H from mara
8nto waOmara
#here matnr M pOmatnr.
8f sy'subrc M ?.
#rite&* waOmara'matnr.
Eelse.
!essage (material does not e%it) type (E).
!essage 8???.
!essage 8??> with pOmatnr.
!essage 8??@ with (material) (does) (not) (e%it).
Endif.
Di@@erence #et5een inc"ude @unction modu"e and su#routine:2
8nclude function module subroutine
ABAP Page 71
Abap Class Notes
Can not be e%ecuted can be e%ecuted can not be e%ecuted
No parameter interface parameter interface parameter interface
No e%ception e%ception no e%ception
No 39C 39C no 39C.
ABAP Page 72

You might also like