Professional Documents
Culture Documents
Write a report that displays the text 'Hello world' on your screen.
Solution
Ok, because this is your first program, you get an extra help.
Call Transaction 'SE38'.
Create a new program.
To proceed in an SAP 3.x system you must be registered as a Developer. You get your
Developer Key from your Sys. admin in a couple of minutes/hours/days after you
applied for it. It must be entered once when you create your first program.
Program attributes:
Type: 1
Application: S
Choose a meaningful title
(Save)
Choose Development Class &TMP or press Button 'Local object'
Now you can edit the source code.
Position the cursor in a line number cell. Press F1 for the help of editor line
commands.
enter i3 which inserts three new rows into your program.
report zbctcb98.
write: / 'hello world'.
(Save, Generate, Execute)
In 3.x you can set your Editor mode in menu /Settings/Editor mode
(in 2.x this is the only editor mode)
If you choose Command mode you get an extra input line, where you can execute
commands. Position the cursor here and press F1 for the available commands. My
favorite one is the HELP command.Try out the HELP WRITE command. What you
see now is a hypertext (clickable). I know that this online help is an online
meaningless chaos for the first time, but sooner or later it should become your
reference.
The title of the report should not be printed in your list. Define an integer variable
with a value of 2. Display the text 'example' and then this variable. Create an integer
input parameter (Default value 20). Display the 'hello world' in the same row, the input
parameter tells in wich column. Check that the the value of your input paramater is
between 0 and 40.
On the screen you should get something like this:
example
hello world
Solution
Modify the second example. Display a title row with page number and date. Put a
counter before the rows and display a header line at the top of each page. Format the
numbers so, that just 4 places are displayed. (the value of the parameter is 40 to get a
nice list)
The list should look like this one:
Page: 1
Counter
1
2
3
4
Solution
Text
example
example
example
example
Third Example
Number
2
2
2
2
18.03.1997
Introduction
hello world
hello world
hello world
hello world
Read a logical database (you must have data in those tables, now LFA1), fill up an
internal table. Sort the data by a given field and then display the internal table.
solution
loop at t.
write: / t-name1, t-lifnr.
endloop.
BC Tips&Tricks
You run a report as job and it does not want to finish.
You might want to debug the report to find out what causes this 'neverending' run.
1. Start the report as a job.
2. Call transaction 'SM50'
3. Put the cursor on the workprocess which runs your job.
4. Push button 'Debugging'.
You will get a session where you can debug the running job. Be careful! When the job
is in the middle of a SELECT it will dump when you try to debug.
If you start the report online and already opened a second session, you can start
transaction 'SM04'. Click on the user-id and choose the session you want to debug.
After pressing the button 'Debugging', the choosen session jumps in debug mode.
Infosystem
You forgot the name of an SAP table or program, but found one which is quite similar to it.
I found the easiest way to use the development class as search field. Look for it in the
attributes of the known program/table. Then go to the infosystem in the development
workbench. Select the object type you are looking for. Set only the development class on the
selection screen.
Program analysis
You want to find out which tables are used in a standard program, but the source code is too
complex to analyze or debug.
Switch on the SQL trace and run the program. Later you can find all the used tables in the
trace log.
System fields
ABCDE
APPLI
BATCH
BATZD
BATZM
BATZO
BATZS
BATZW
BINPT
BREP4
BSPLD
CALLD
CALLR
CCURS
CCURT
CDATE
COLNO
CPAGE
CPROG
CTABL
CTYPE
CUCOL
CUROW
DATAR
DATLO
DATUM
DATUT
DAYST
DBCNT
DBNAM
DBSYS
DCSYS
DSNAM
DYNGR
DYNNR
FDAYW
FDPOS
FMKEY
HOST
INDEX
LANGU
LDBPG
LILLI
LINCT
LINNO
LINSZ
LISEL
LISTI
LOCDB
LOCOP
LOOPC
LSIND
LSTAT
MACDB
MACOL
MANDT
MARKY
MAROW
MODNO
MSGID
MSGLI
MSGNO
MSGTY
MSGV1
MSGV2
MSGV3
MSGV4
OPSYS
PAART
PAGCT
PAGNO
PDEST
PEXPI
PFKEY
PLIST
PRABT
PRBIG
PRCOP
PRDSN
PREFX
PRIMM
PRNEW
PRREC
PRREL
PRTXT
REPID
RTITL
SAPRL
SCOLS
SLSET
SPONO
SPONR
SROWS
STACO
STARO
STEPL
SUBRC
SUBTY
SYSID
TABIX
TCODE
TFDSN
TFILL
TIMLO
TIMUT
TITLE
TLENG
TMAXL
TNAME
TOCCU
TPAGI
TSTLO
TSTUT
TTABC
TTABI
TVAR0
TVAR1
TVAR2
TVAR3
TVAR4
TVAR5
TVAR6
TVAR7
TVAR8
TVAR9
WILLI
WINCO
WINDI
WINRO
WINSL
WINX1
WINX2
WINY1
WINY2
WTITL
XCODE
ZONLO
Tips&Tricks
How to customize the display options?
In the right upper corner of your SAP window you can find a symbol. Click on it. In the
Options you can change the colors, text fonts. Hide or display various elements of the
standard SAP window. There are two important settings.
In the Cursor folder enable AutoTAB. This means that after filling an 8 character field with
eight character you don't have to push the TAB button to jump to the next field, the system
automatically puts the cursor there.
In the General folder you can deselect the statusbar. This enlarges the work area of your
window. When you receive a warning this comes in a small window and you must press the
button to return to your work. But you don't see the time, system and session number in the
status line any more.
With the Default Size options you can easily change your window back to the default size.
Office Tips
You want to send an urgent message to an SAP user. When you send your mail choose the
option Express. The user receives your letter immediately and a popup window informs him
that he has an express mail in his mailbox.
Go /Office/Outbox/Edit and create a mail. In the Extras menu you can find the Insert URL
function. Fill out the fields and press Ok. This puts a text in your letter which referes to a Web
page (same as an html link). If your network has Internet access, when the receiver clicks on
the text the Web browser starts and loads the refered Web page automatically.
Printer problems
Printing does not work in SAP. There is a printer definition for your local printer, but it does
not work. Presuming that you use the program SAPLPD on your computer.
Boot your computer and start only the SAPLogon and the SAPLpd program.
Delete all of your old print jobs in the SAP system (Transaction SP01).Generate only
one new print job.
Check that there is enough resource in your computer. Check the free memory (Win
3.1x) and the free disk space (The lists are temporarily saved on your disk).
Open the SAPLPD and read the print log in the window. The printer definition must
correspond with the parameters shown here.
Check that the standard printer is on the same lpt (Win 3.1: Control panel, Printer) as
defined for the printer (usually lpt1).
In Transaction SP01 read the protocol of your print job. Do not generate new print
jobs! Wait till the SAP system changes the status of the print job.
If you can not find the print job in SP01 anymore, then the print job was successfully
printed out. If it didn't come out on your printer and the SAPLpd didn't indicate an
incoming print job, then the connection was realised with another PC. Then SAP
printer definition you used, does not correspond with your computer.
Use icons in your mail
Put the code @nn@ in the title or in the body of your SAP mail where nn is a number, for
example 01 ( @01@ ). The system will look up the icon and displays it in the mail. The next
program lists the icon codes, their length with other information and the corresponding icons.
REPORT ZMDICON2.
TABLES: ICON.
DATA: ICONE LIKE ICON-ID.
DATA: BUFFER(4),
FF LIKE ICON-NAME.
INCLUDE <ICON>.
FIELD-SYMBOLS: <F>.
WRITE : /
'Icon
Id
L B S M F Name der Icone'.
ULINE.
WRITE : /
'Icone
Id
Lnge
F fr Funktionstaste geeignet'.
WRITE : /
'
M
fr Nachricht (message) geeignet'.
WRITE : /
'
S
fr Statusanzeige geeignet'.
WRITE : /
'
B
fr Drucktaste (button) geeignet'.
ULINE.
SELECT * FROM ICON.
Leaving aside the hyperbole, a performance optimized ABAP program saves the time of the end user, thus
increasing the productivity of the user, and in turn keeping the user and the management happy.
This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs
efficient in doing their work. This tutorial also assumes that the reader is well versed in all the concepts and
syntax of ABAP programming.
NOTE: Performance of a program is also often limited due to hardware restrictions, which is out of the scope of
this article.
================================================================================
Maxnu = zflight-fligh.
Endselect.
Recommended
Select max( fligh ) from zflight into maxnu where airln = LF and cntry = IN.
The other aggregate functions that can be used are min (to find the minimum value), avg (to find the average of a
Data interval), sum (to add up a data interval) and count (counting the lines in a data selection).
Recommended
Select * from zcnfl where cntry like IN% and airln = LF.
Endselect.
Recommended
Refresh: int_fligh.
Recommended
Int_fligh-flag = X.
Modify int_fligh transporting flag where flag is initial.
Recommended
Read table int_fligh with key airln = LF binary search.
Recommended
Append lines of int_fligh1 to int_fligh2.
1.
2.
3.
4.
Select distinct
Select for update
Order by, group by, having clause
Joins
Use the Bypass buffer addition to the select clause in order to explicitly bypass the buffer while selecting the
data.
1. Duplicates are automatically removed from the resulting data set. Hence care should be taken
that the unique key of the detail line items should be given in the select statement.
2. If the table on which the For All Entries IN clause is based is empty, all rows are selected into
3.
the destination table. Hence it is advisable to check before-hand that the first table is not
empty.
If the table on which the For All Entries IN clause is based is very large, the performance will
go down instead of improving. Hence attempt should be made to keep the table size to a
moderate level.
Not Recommended
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
Recommended
Select * from zfligh appending table int_fligh
The trace list has many lines that are not related to the SELECT statement in the
ABAP program. This is because the execution of any ABAP program requires
additional administrative SQL calls. To restrict the list output, use the filter introducing
the trace list.
The trace list contains different SQL statements simultaneously related to the one SELECT statement in
the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3
Application Server - maps every Open SQL statement to one or a series of physical database calls and
brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and
database system. For example, the SELECT-ENDSELECT loop on the SPFLI table in our test program
is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
The WHERE clause in the trace list's SQL statement is different from the WHERE
clause in the ABAP statement. This is because in an R/3 system, a client is a selfcontained unit with separate master records and its own set of table data (in
commercial, organizational, and technical terms). With ABAP, every Open SQL
statement automatically executes within the correct client environment. For this
reason, a condition with the actual client code is added to every WHERE clause if a
client field is a component of the searched table.
To see a statement's execution plan, just position the cursor on the PREPARE statement and
choose Explain SQL. A detailed explanation of the execution plan depends on the database
system in use.