1. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page1
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
ABAP DICTIONARY
Abap Dictionary is a centralrepository wherewedefineand maintain theobjects which are
related to database.
Define means creation ofobjects
Maintenancemeans changing anddeleting theobjects.
Theobjects are,
Database table:
It is an object which stores datain theformof rows and columns.
Each rowis called as record, and each column is called as field.
So, to definea tablewe haveto definethefields first.
So, to definea field, we haveto specify the belowthings:
FIELD = DATA ELEMENT + DOMAIN
2. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page2
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Domain:
It is an object which specifies technicalinformation suchas datatype and length for a field.
It also specifies sign, lower case, conversion routine, fixed values, and value table.
Data element:
It is an object which specifies semantic information suchas field description, field labels (short,
medium, long and heading)forafield.
Advantages of data element anddomain:
• Reusability: Thesamedataelement and domain can bereused by multipletablefields,
instead ofcreating again and again.
• Thesearealso used in creating foreign key relationship,search help,ale-idoc’s.
Key field: A field which is used to identify therecord uniquely is called a key field. In a tablethere
should beat least onekey field. We can create ____number ofkey fields.
Steps to create domain:
1. Go to SE11
2. Select Domain
3. Give a name, ex – ‘zcno’
4. Click on Create
5. Provideshort description
6. Providedatatypeas CHAR and length as 10.
7. Press enter
8. Save, check and activate
3. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page3
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Steps to create data element:
1. Go to SE11
2. Select datatype
3. Give a name, ex – ‘zcno’
4. Create -> select dataelement
5. Provideshort description
6. Providedomain nameas ‘zcno’
7. Press enter
8. Click on field label tab, specify short, medium, long and headinglabels
9. Save, check and activate
Steps to create a table:
1. Go to SE11
2. Providethetablename ‘zcust_table’
3. Click on create
4. Providedescription
5. Specify delivery class as ‘A’
6. Specify display maintenanceallowed
7. Click on fields tab
8. Providethefield name, dataelement nameas below
9.
10. Click on save
11. Click on technicalsettings button
12. Providethedetails as dataclass -> APPL0, sizecategory ->0
13. Click on saveand click on back
4. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page4
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
14. Saveand activatethetable
Creating records into the table:
• Go to SE11
• Give thetablename and click on change
• Click on utilities -> table contents ->create
• Providethecno, cname, city
• Repeat thesameprocedureand createtherecords
Displaying the table contents:
• Click on utilities -> table contents ->display
• Click on executebutton
• Therecords will bedisplayed
Note:Sometimes we may get unpredictableerrors in atable, dueto adding ordeleting thefields in a
table. To solvetheerrorfollow thebelowsteps.
• Go to SE14Providethetablename
• Click on edit button
• Click on ‘activateand adjust databasebutton
5. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page5
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Components of a TABLE :
Delivery class:
It specifies thetypeofthe datathat stored in atable.
Thedatacan bebusiness dataorsystemdata.
Business datameans application data(masterand transaction data).
Thefollowing options areavailable.
6. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page6
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Display maintenance:
It specifies whetherthedatashould only bedisplayed orit can also bemaintained.
Datamaintenancemeans creation, deletion, andchanging.
Thereare 3 options available.
• Display maintenance allowed: Datais displayed and maintained
• Display maintenance not allowed: Data is not displayed and not maintained
• Display maintenance allowed with restrictions: Datais displayed, but maintenanceis given
only for someusers based on restrictions.
Data class:It specifies thephysicalareaof a tableinsidethedatabase
Depending on thetableweare supposedto select therequired option. Theoptionsavailableare,
Masterdata:Thedatawhich neverchanges orwhich changes very rarely is called masterdata.
Ex: cno, cname, city etc.
7. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page7
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Transaction data:Theday to day business dataorthedatawhich changes everyday is called
transaction data.
Ex: customerbank transaction data
Organization data:Thedatawhich is related to organizationorcompanylikehowmany company
codes, plants,sales organizationetc, is called organization data.
Size category:It specifies themax. Number of records that can bestored in atable.
Thepossibleoptionsareavailableas below.
In thereal time we always set sizecategory as ‘0’ OR ‘1’, becausewehaveto usesmall amount of
memory.
Supposeifthememory is not sufficient thesystemwill automatically assign thesamememory area as
perthesize category mentionedabove.
Buffer/cachememory: It is a temporary memory to storethedata. It is mainly used to increase
thesystemperformance.
Thefunctionality ofbufferis defined as below.
• TheTables request forthedata
• Thesystemwill check whetherthedatais available in cache/buffermemory
• If it is available thedatawill be immediately given back to the table, thereby increasingthe
systemperformance
• Supposeifthedatais not available, therequest will be sent to database, andtheresponsewill
begiven back to bufferor cachememory to storea copy forfuturereferences
• After the copy is stored then thedatawill begiven back to the table
8. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page8
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Buffering options:
• Buffering not allowed: Datais not stored in buffer
• Buffering allowed but not switchedoff: Used by SAP
• Buffering switched on: Data is stored in buffer
By default buffering not allowed will beselected.
Buffering types:
• Single recordbuffer: Only first record orrecords which areread will bestored in thebuffer
• Fully buffered: All therecords will be stored in thebuffer
• Generic Area: Thekey field’s datais called generic area. Only generic areadata i.e. key fields
data will be stored in thebuffer
Log Data Changes:This Checkboxwould definewhetherchanges to thedatarecords ofthetable
are to belogged/recordedornot.
If checkboxis selected, then every change(Update/Delete)to an existing datarecord is recorded in
theStandard DatabaseLog tableDBTABLOG.
9. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page9
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
CLIENT NUMBER
It is a uniquenumberwhich is used to providesecurity to thedataat thedatabaselevel.
In thereal time, Based on theclient no only, usernames will becreated and theaccess will be given.
In thereal time, normally we usetheclient number(100,120), (200,220), (300,320).
Thefield name, dataelement, and domain forclient numberis ‘MANDT’.
Types of tables based on client number
Ex on Client dependent table:
1. Create a tableby namezcust_table_dp with belowfields.
2.
3. Create somerecords in thetableand display them.
4. Now login to anotherclient. Ex810 client
5. Open thetable and display thedata
6. Thedatawill not beavailable, becauseit is aclient dependent table
10. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page10
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
STRUCTURES IN ABAP
• It is acontainerofreusablefields
• Structures aredefined in datadictionary
• Oncethe structuresaredefined wemust includethemin tables
• Thereare two options forincluding thestructuresin tables
Includestructure
Append structure
Difference between include structure and append structure:
Ex on include structure:
Step 1: Createa structureby name‘zaddr’ with fields city, country, postalcode
1. Go to SE11Selectdatatype provideaname‘zaddr’
2. Click on create and providethedescription
3. Specify thefields and dataelements
4.
11. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page11
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
5. Saveand activate
Steps 2: Includethestructurein atable as below
1. Open any table which is already created
2. Providethefield nameas ‘.include’, dataelement as structurename zaddr(whichis created
above)
3. Enter
4. Thefields will beautomatically copied
Ex on appendstructure: Business requirement:
Add a custom field ‘MNAME’ (middle name)to the standard SAP table ‘KNA1’ .
1. Open thetable kna1in display mode
2. Click on ‘append structure’ button
3. A pop-up is displayed, click on createicon
4. Providetheappend name‘zapp1’ and press enter
5. Providethefield nameas ‘mname’ and dataelement as ‘zmname’
6. Save, activateand click on back
7. Check thefield in thetable, it will be availableat thebottom
12. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page12
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Currency and Quantity fields
• Currency and quantity fields are used to storecurrency amounts dataand quantity data
respectively.
• So, forevery currency and quantity field we haveto specify thecorresponding unitslikeINRor
USD or EUROetc orKGS or EA orPC etc .
• CURR: It is thedatatypewhich is used to storethecurrency amount orpricefields.
• CUKY: It is thedatatypewhich is used to storethecorresponding units(INRorUSD orEURO)
for thecurrency fields.
• QUAN: It is thedatatypewhich is used to specify thequantity foramaterial orstock.
• UNIT: It is thedatatypewhich is used to specify theunits(KGS orEAorPC) for thequantity
fields.
Ex on currency/quantityfields:
1. Open any table which is already created.
2. Add thebelow fields
3. Click on Currency/Quantity fields tab and specify RefTab Name and RefField Name.
a.
4. Saveand activatethetable
13. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page13
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Foreign key relation
Therelation between two tables for validating thedatais called foreign key relation.
Validation means checking whetherthevalueis correct ornot.
Check table:
A table which stores masterdatais called a check table.
Foreign Key Table :
A table which is linked with check tablefor validating its own datais called foreign key table
Foreign key relation :
A relation between two ormoretables for validating thedatais called foreign key relation.
14. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page14
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Steps forforeign key relation:
Step 1: Createa tableby name ‘zcustomers’ with field’s customernumberand customer
name, also createsomerecords.
Step 2: Createanothertableby namezcustomers_bank with fields cno, bankid and
bankname.
Step 3: Createtheforeign key relation as below
1. Open thetable zcustomer_bank
2. Select cno field
3. Click on foreign keys button orIcon
4. Providethecheck tablenameas zcustomer(masterdatatable)
5. Click on generateproposal button
6. Click on copy button
7. Saveand activate
Step 4: Unit testing
• Click on utilities -> table contents ->create
• Entertheinvalid customernumberand click on save
• Theerrormessagewill be displayed
15. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page15
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Real time ex on foreign key relation:
Domain with field values:
• It is an option to maintain someFixed values insidethedomain forvalidation
• It is used forvalidation at thedomain level
• Wehaveto maintain somefixed values at the domain, so that allthetable fields will be
referring to this domain will bechecked against with thefixed values
• If, supposeweenter awrong value for a field which refers this domain, then thesystemwill
check yourvaluewith fixed values. If thevalueis not available, then the systemwill raise the
errormessage
• This option is only used wheneverthenumberofvalues areless than 10or15
• If thevalues are morethan 15, we go for foreign key relation
• Themain advantageofdomain with fixed values is reusability
16. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page16
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Ex on Domain with field values
1. Open thetable zcustomer_bank
2. Add an extra field by name‘gender’ with dataelement and domain as ‘zgender’
3. Now go to thedomain ‘zgender’.
4. Click on valuerangetab
5. Maintain thefixed values as below
a.
6. Saveand activatethedomain and thetable
7. Go to unit testing
8. Entertheinvalid valuefor gender
9. Theerrorwill bedisplayed
VALUE TABLE:
A table namedefined at thedomain level so that all thetable fields will bereferring to
thedomain will be checked orvalidated with asingletable called as valuetable.
Themain advantageofvaluetableis to automatethesystemforforeign key relation
i.e. thesystemwill automatically display check tablename to generateforeign key
proposal.
Weshould just click on YES button,so that valuetableis convertedas check table.
Steps forvaluetable:
STEP1: Create a tablezzcustomerwith field cno and cname, also createsomerecords
STEP2: Define thecheck tablename at domain level as below. Nowcheck table is called as value
table
1. Go to thedomain zcno
2. Click on valuerangetab
17. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page17
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
3. Providethevaluetableas zzcustomer
4. Saveand activate, domain and table
STEP3: Create anothertableby namezzcustomer_bank with fields cno, bankid, bankname
STEP4: Maintain theforeign key relation as below
• Open zzcustomer_bank table
• Select cno field and click on foreign key button
• A pop-up displayedas belowwith valuetableto beproposedforcheck table
• If we click on ‘yes’, foreign key relation will be automatically displayed
• If we click on ‘no’, it will not bedisplayed
Differences between checktable and value table
18. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page18
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Domain properties:
• SIGN: It is used to storethesign ofa number, whetherit is positivesign ornegativesign
• LowerCase: This option is used to storeavaluein thecombination ofcapitaland smallletters
• By default SAP will convert all letters into capitalletters
• If we don’t want to convert allletters into capitalletters, pleaseselect lower caseoption
• Conversion Routine: It is asub-programorfunctionmodulewhich is used to convertavalue
from internalformat to externalformat and viceversa
Conversionroutine function modules:
• Go to any domain, ex: MATNR
• Theconversion routinewillbe displayed, ex: MATN1
• Doubleclick on MATN1
• Two function modules willbe displayed as below
• CONVERSION_EXIT_MATN1_INPUT: This functionmoduleis used to convert materialnumber
from externalformat to internalformat.
• CONVERSION_EXIT_MATN1_OUTPUT: This function moduleis used to convert material
numberfrominternalformat tot externalformat.
19. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page19
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Table Maintenance Generator (SM30):
It is astandard SAPprogramcreated in theformof function modules to maintain mass orbulk
amount ofdata instead ofmaintaining each and every record.
Maintenancemeans creation,deletion and modification.
It is also used forvalidating thetabledatausing theconcept ofevents.
Steps forTMG:
1. Create any tableby name‘zcust’ with mandt, cno,cnameand land1
2. Saveand activatethetable
3. Click on utilities -> select tablemaintenancegenerator
4. Providethedetails as below
5. Authorization group=&NC&
6. Function group =zcust(tablename)
7. Maintenancetype as onestep
8. Click on find screen numberbutton
9. A pop-up is displayed, just pressenter
10. Thescreen numberwill be automatically proposed
11. Click on create icon
12. TheTMG will be created in theform of function modules
Activating TMG:
• Go to SE80
• Select function group fromthelist
• Providefunction groupname(tablename)and press enter
• Right click on function groupnameand select activate
20. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page20
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
Unit testing:
• Go to SM30
• Providethetablename
• Click on ‘maintain’ button
• Entercustomernumber,nameand country forasinglerecord orbulk amount ofrecords.
• Click on save, thedatawill be saved
Validations with TMG:
Sometimes we want to validatethedataby writing programlogic.
In such cases weuseevents in TMG and validatethedata
Thevalidation arepossibleusing theconcept called events
Thereare around 39events available
For each event we need to providearoutinename(sub-programname )
Insidetheroutinewehaveto write theABAP codefor validating thedata
Events in TMG:
• Open thetable
• Click on utilities and select TMG
• Click on environment ->modification -> events
• A new screen will bedisplayed
• Click on ‘new entries’ button
• Click on ‘help’ button on thefirst row, first column
• The39 events will bedisplayed
21. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page21
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
• Doubleclick on any Event Name. Ex : 05
• Providetheroutinenameforaboveevent in thesecond column and press enter
New sub-programwhich will becreated forwriting thelogic
Ex on validation: BusinessRequirement:
1. Create a tableby name‘zkna1’ with kunnr, land1,name1fields
2. Create a TMG as discussedabove
3. Click on environment ->modifications ->events
4. Click on ‘new entries’ button
5. Select the event ‘05’ (creating anew record)and providesub-routinename(sub-program
name)
6.
7. Click on editor icon
Raise an errormessage whenevera newrecord orcustomeris created without
providing the countryorland1.
22. A R J U N … … . L E A R N R E A L T I M E S C E N A R I O S D O N E B Y M E Page22
A B A P & W E B D Y N P R O A B A P @ A R J U N IGROWSOFT
8. Press enter2 times (sub-programwillbe created automatically)
9. Write thebelowABAP code
Form znew_rec.
If zkna1_land1=‘ ’.
Message‘pleaseentercountry’ type‘E’.
Endif.
Endform.
10. Saveand activate
11. Click on back, save
12. Click on back, save
13. Click on save
14. An information messagewill be displayed as ‘functiongroup can’t beprocessed’
15. Click on back -> back -> back
16. Go to SE80and activatefunction group
17. Got SM30 and test it
Assignment
Create a tableby name‘zlfa1’ with vendornumber, name, dateand username. Create
TMG and validatetheTMGso that dateand usernameautomatically saved.