Performance OO ABAP v/s Procedural ABAP
Hi Experts,
I want to know if the performance of any particular program is enhanced by the use of OO ABAP over Procedural ABAP. Please let me know if there are any articles (books, blogs and forum threads...) which discuss the same.
Thank you
-Joe
Hello Joe,
it depends on what you are doing;-)
First of all: You can develop fast programs with classical abap and very fast programs with abap oo.
I think, If you have enough experience with Abap OO, you can develop very good programs. In fact it is quite difficult, to develop "beautiful" programs which are although the fastest in the world.
If you measure the runtime of your programs, you will see, that there are other problems than "OO"-related. Its often how your data is organized and how you work with internal tables, data structures, references and field-symbols.
I found this very useful: http://www.amazon.com/ABAP-Performance-Tuning-SAP-PRESS/dp/1592292895/ref=sr_1_2?ie=UTF8&qid=1329902376&sr=8-2
Kind regards,
Hendrik
Similar Messages
-
The performance of ABAP programs
Hey Experts , how can one analyze the performance of ABAP programs apart from using the generic tools such as Trace etc.
Hi Chakradhar,
Overview & Introduction
The runtime analysis tool allows you to examine the performance of any ABAP programs, such as reports, subroutines, function modules or classes, that you create in the ABAP workbench. It saves its results in performance data files, which you can display as lists. You can use these results to identify runtime-intensive statements, to combine table accesses, and show the hierarchy of program calls.
Normally you use the runtime analysis tool to measure the runtime of complex program segments or complete transactions (if you want to measure the runtime of smaller program segments or individual ABAP statements you can use the ABAP statement GET RUN TIME FIELD ).
However, we use only simple
The Programs to be Analyzed
Let's assume I am a very newbie in ABAP and I have written a tiny little program which is doing the following:
reading data from a database table
storing that data in an internal table
display that data on a list (at the start of the program you have to specify certain key values; only matching data should be displayed later on).
So here it comes (and it seems to work as designed ...)
REPORT y_wlog_atra_1.
PARAMETERS: p_carrid TYPE sbook-carrid DEFAULT 'LH',
p_connid TYPE sbook-connid DEFAULT '0400'.
DATA: wa_sbook TYPE sbook,
itab_sbook TYPE STANDARD TABLE OF sbook.
*SELECT * FROM sbook INTO wa_sbook.*
CHECK: wa_sbook-carrid = 'LH' AND
wa_sbook-connid = '0400'.
APPEND wa_sbook TO itab_sbook.
ENDSELECT.
LOOP AT itab_sbook INTO wa_sbook.
WRITE: /,
wa_sbook-carrid,
wa_sbook-connid,
wa_sbook-fldate,
wa_sbook-bookid,
wa_sbook-customid,
wa_sbook-custtype.
ENDLOOP.
A nice colleague has thrown a glance at my source code. He has given the hint to use a WHERE clause with the SELECT statement instead of the CHECK statement for reasons of better performance.
So I have written another program:
REPORT y_wlog_atra_2.
*SELECT * FROM sbook INTO wa_sbook*
WHERE carrid = 'LH' AND
connid = '0400'.
APPEND wa_sbook TO itab_sbook.
ENDSELECT.
I am curious about the performance now. Let's compare the 2 variants with the ABAP Runtime Analysis tool.
ABAP Runtime Analysis: Tool & Procedure
To start it, choose Test --> Runtime Analysis in the SAP Menu, or use transaction SE30 .
The runtime analysis procedure consists of two parts:
Recording performance data (upper part of the screen)
Analyzing the performance data (lower part of the screen; this part only appears if there are performance data files in place)
The procedure for the first part (Recording performance data):
We go to the initial screen of the runtime analysis (transaction code SE30 ) and specify the name of the first program (Y_WLOG_ATRA_1) in the relevant input field. After that we press the button Execute .
The selection screen of the program Y_WLOG_ATRA_1 (including the 2 input fields) is displayed. At the bottom of the screen we are informed that the measurement has been started. We continue by clicking the Execute button.
Later on we will see that a file (containing performance data) has been created in parallel.
Now we repeat that procedure for our second program (Y_WLOG_ATRA_2).
The second step is the analysis of the generated performance data.
To do that we have to go to the initial screen of the Runtime Analysis tool again. On the bottom part of the screen you can specify those performance data files you want to analyze.
You can see some information related to the last measurement run (in our case that was program (Y_WLOG_ATRA_2). By pressing the button Other File we are able to select those performance data files we like to analyze.
I want to see all the files I have created (user BCUSER).
I get the relevant list with 2 lines (related to the performance data files of the programs Y_WLOG_ATRA_1 and Y_WLOG_ATRA_2).
Based on that list you can display the distinct performance data per line. You have to click in the column Object Type of the relevant line.
As a start the tool displays the evaluation overview (showing the cumulated execution times for the ABAP, database and system-level).
Here comes the evaluation overview for program Y_WLOG_ATRA_1
We can do the same for the other program Y_WLOG_ATRA_2
By comparing the perfomance data of the 2 programs we clearly see that I have done well with listening to the advice of my colleague. The performance of the second program is dramatically better.
In the next step you can forward to a more detailed display of the performance data (Hitlists). That listing shows the different granular execution steps ( according to your filter adjustments ). Here you can easily identify the most time-consuming progam units.
And it will also be a good idea to glance at the Tips & Tricks corner. You will find many valuable suggestions about good performance definitely.
Please use the below link to see the Screen shots of the screens
[http://searchsap.techtarget.com/tip/0,289483,sid21_gci1265920,00.html|Performance Analysing] -
Performance of ABAP query program
Hi All,
A custom program AQNWZ_TALAT=====TCS_AP_ITEMS== is taking lot of time running. And when checked the cost of the select statement is very high.
I guessed it must be some custom abap query. Correct me if I am wrong.
Also please let me know how to do the performance tuning on this code? Should I be editing the program directly or should I edit at the abap query level.
Regards,
Pooja
Moderator message: Please Read before Posting in the Performance and Tuning Forum
Edited by: Thomas Zloch on Dec 3, 2010 11:01 AM>A few tips you can use for finetuning a Report
The actually a good collection of the most important pain points. But the recommendations are unfortunately quite poor, and even wrong. I have updated them a little bit.
And for German speaking people I have added a reference to a textbook, where arll my recommendations are explained in detail.
Siegfried
1) Use mostly primary key to access data.
... nonsense, the task determines the WHERE clause, it is not your choice
2) Before READ u sort the itab
No
3) use mostly the indexes fields in ur where clause.
... as 1, it is the other way, the task determines the WHERE-clause, make surwe that there is an index which
supports it
4) Restrict the the fields retrieved by your select sentences to the minimal set. (Avoid select *)
nonsense, most SELECT use and must use *, use field list in wide tables
5) try to use specify where clause so the abap sql optimizer chooses the right index.
o.k., but who understands that in depth?
6) Avoid sentences like select lifnr name1 into corresponding fields of lfa1 from lfa1 where....
feel free to use if required
(You should declare a working area and select into the working area, is twice faster)
... such general statements are always incorrect
7) use hashed tables instead of standard tables. They are faster
no, use sorted tables, hashed are very special and can only be used if there is a unique key
8) avoid the use of collect as much as you can.
total nonsense, use collect with hashed tables, works perfect, if you use it with standard tables, do not mix it with other statements
1 Always check the driver internal tables is not empty , while using FOR ALL ENTRIES
100% correct
2 Avoid for all entries in JOINS
... not generally true
3 Try to avoid joins and use FOR ALL ENTRIES.
... hmmm, there are pages of discussions, this statement was wrong, is wrong and will be wrong!!!
4 Try to restrict the joins to 1 level only ie only for 2 tables
nonsense, joins are complicated, you must know hw indexes are used, if everything is fine, then 10 or 20 tables can be joined
5 Avoid using Select *.
see 4)
6 Avoid having multiple Selects from the same table in the same object.
... try to avoid to SELECT the same data, different criteria can be necessary
7 Try to minimize the number of variables to save memory.
... obvious,
8 The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
... no is must not the optimizer will not be influenced be the order , but do it, it increases readability
9 Avoid creation of index as far as possible
... no, o.k. if you are not experienced than avoid ... otherwise the creation of the required indexes is absolutely mandatory for new tables, for SAP standard tables most indexes are already there. But still if very new accesses are added, then new indexes can become necessary.
10 Avoid operators like , > , < & like % in where clause conditions
... no, you must add them, but be aware that the search is only poorly supported by them, but the result set is reduced.
11 Avoid select/select single statements in loops.
... if they are going to the database! If the tables are buffered, then these statements are perfect!
12 Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
.... Actually try to avoid standard tables, use sorted tables instead. If you must use a standard table, than the recommendation is true.
13 Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
.... no, use them if required. Again, if table is buffered, then they MUST be avoided.
14 Avoid using ORDER BY in selects
... if it is not ORDER BY PRIMARY KEY. Again, if the table is buffered, then other orders MUST be avoided.
15 Avoid Nested Selects
... use join. Again, if the tables are buffered, then Nested SELECTs are fine!
16 Avoid Nested Loops of Internal Tables
.... impossible, there is no other option. Use sorted tables and verything is fine!
17 Try to use FIELD SYMBOLS.
... what means try? Use ASSIGNING fieldsymbol in LOOPs, but use it in READs only for very wide tables (>1kB). Use it always for tables with tables in the workarea!
18 Try to avoid into Corresponding Fields of
... see 6) is wrong!
19 Avoid using Select Distinct, Use DELETE ADJACENT.
.... no, use it if required and if it can reduce the result set by a factor of 2 or more. Again, if table is buffered, then it MUST be avoided.
Wenn Sie mit der Performance Ihres ABAP Programms nicht zufrieden sind, werfen Sie doch einen Blick in mein neues Buch:
Siegfried Boes: Performance-Optimierung von ABAP®-Programmen Nov. 2009 464 Seiten 59u20AC
Leseproben und weitere Informationen: http://www.dpunkt.de/buecher/3096.html
Edited by: Thomas Zloch on Dec 3, 2010 10:53 AM -
Improve data load performance using ABAP code
Hi all,
I want to improve my load performance using ABAP code, how to do this?. If i writing ABAP code in SE38 how i can call
in BW side? if give sample code to improve load performance it will be usefull. please guide me.There are several points that can improve performance of your ABAP code:
1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
3. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
4.Avoid using nested SELECT and SELECT statements within LOOPs.
5. Avoid using INTO CORRESPONDING FIELDS OF. Instead use INTO TABLE.
6. Avoid using SELECT * and select only the required fields from the table.
7. Avoid Executing a SELECT multiple times in the program.
8. Avoid nested loops when working with large internal tables.
9.Whenever using READ TABLE use BINARY SEARCH addition to speed up the search.
10. Use FIELD-SYMBOLS instead of a work area when there are more than 200 entries in an internal table where some fields are being manipulated.
11. Use MOVE with individual variable/field moves instead of MOVE-CORRESPONDING.
12. Use CASE instead of IF/ENDIF whenever possible.
13. Runtime transaction code se30 can be used to measure the application performance.
14. Transaction code st05 can be used to analyse the SQL trace and measure the performance of the select statements of the program.
15. Start routines can be used when transformation is needed in the data package level. Field/individual routines can be used for a simple formula or calculation. End routines are used when you wish to populate data not present in the source but present in the target.
16. Always use a WHERE clause for DELETE statement. To delete records for multiple values, use SELECT-OPTIONS.
17. Always use 'IS INITIAL' instead of equal to '' because null for a character is '' but '0' for an integer.
Hope it helps. -
Performance problem with java stored procedure
hi,
i developped a java class, then I stored it in Oracle 8.1.7.
This class contains several import of other classes stored in the database.
It works, but the execution perfomances are disappointing. It's very long. I guess, that's because of the great number of classes to load that are necessary for my class execution.
I tried to increase the size of the java pool (I parameter 70 Mo in the java_pool_size parameter of the init.ora), but the performance is not much better.
Has anyone an idea to increase the performance of this execution of my class ?
In particular, is there a way to keep permanently in memory the java objects used by my class ?
Thanks in advance
bye
[email protected]
nullbefore running Java, the database session needs to be Java enabled; this might be the reason why it is taking so long. If this is the case, you should see an improvement in subsequent calls, once a database session is Java enabled, other users can benefit from it.
Kuassi
I have some performance issue with java stored procedure. Hope some one will be able to help me out. I'm using java stored procedures in my application and basically these procedures are used to do some validation and form the XML message of the database tables. I have noticed that when I call the PL/SQL wrapper function, it is taking time to load the java class and once the class is loaded the execution is faster. Most of the time is spent for loading the class rather than executing the function. if I reduce the class load time, I can improve the performance drastically. Do any one of you know how to reduce the class load time. The following are the platform and oracle version.
O/S: IBM AIX
Oracle: 8.1.7 -
Performance Check - ABAP and Database color bars
Hello everyone,
When i go for the performance check of my object, i see Database in red bar and ABAP in green bar.
The smaller the difference between these two bars, the better.
But what does the color mean ? ( Somethimes the smaller bar is Red )
ThanksHere is the explanation (depends % of total) in [sap library - SE30|http://help.sap.com/saphelp_nw2004s/helpdata/en/c6/617d2ae68c11d2b2ab080009b43351/frameset.htm]
>
shalaxy s wrote:
> The smaller the difference between these two bars, the better.
NO, it depends completely of what does your program! -
Form - Perform and ABAP coding
Hi:
I have a requirement to get vendor address from database and print on the form. I could print only one field only Name1, but not details like Street or country Etc are not getting printed. Even if we pass multiple variables as input and putput variables using perform of form, I think we need to declare only one input as INTTAB STRUCTURE ITCSY and one out put variable as OUTTAB STRUCTURE ITCSY in the ABAP program. In the program I am using Index option like 1, 2 and modifying details of OUTTAB. Is it correct?.
Still I am unable to print complete address on the form.
For this I am unsing Perfom option in the form.
Can you please help in the following:
1) Can I pass one value vendor from form using perform and get back a structure from ABAP program?.
2) I am using following:
DEFINE &VENDOR_NAME& = ' '
DEFINE &VENDOR_STREET& = ' '
PERFORM GET_DATA IN PROGRAM Z_TEST
USING &VENDOR_NO&
CHANGING &VENDOR_NAME&
CHANGING &VENDOR_STREET&
ENDPERFORM.
For Printing I am using inthe form
&VENDOR_NAME&
&VENDOR_STREET&
In the ABAP program I am using
FORM GET_DATA TABLES INTTAB STRUCTURE ITCSY
OUTTAB1 STRUCTURE ITCSY.
IF SY-SUBRC EQ 0.
SELECT SINGLE NAME1 STR_SUPPL1
FROM ADRC
INTO (V_NAME1,V_STR_SUPPL1)
WHERE ADDRNUMBER = V_ADRNR.
IF SY-SUBRC EQ 0.
*- Name1
READ TABLE OUTTAB1 INDEX 1.
MOVE V_NAME1 TO OUTTAB1-VALUE.
MODIFY OUTTAB1 INDEX SY-TABIX.
*- Street
READ TABLE OUTTAB1 INDEX 2.
MOVE V_STR_SUPPL1 TO OUTTAB1-VALUE.
MODIFY OUTTAB1 INDEX SY-TABIX.
ENDIF.
Can you please check above code and let me know if I am doing mistake anywhere?..like passing variables, printing variables on the form and ABAP sub-routine etc.
Please do not copye again same code what is find in SAP ABAP help.
Thanks in advance for your help.
Thanks,
RamaNaren:
Your code did not work...
Sorry I did not paste my complete code(when I posted message )as too much code might be confusing. Please find my code below:
FORM GET_DATA TABLES INTTAB STRUCTURE ITCSY
OUTTAB1 STRUCTURE ITCSY.
DATA: V_ADRNR LIKE LFA1-ADRNR,
V_NAME1 LIKE ADRC-NAME1,
V_STR_SUPPL1 LIKE ADRC-STR_SUPPL1,
V_LIFNR LIKE LFA1-LIFNR.
READ TABLE INTTAB INDEX 1.
V_LIFNR = INTTAB-VALUE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V_LIFNR
IMPORTING
OUTPUT = V_LIFNR.
SELECT SINGLE ADRNR
INTO V_ADRNR
FROM LFA1
WHERE LIFNR = V_LIFNR.
IF SY-SUBRC EQ 0.
SELECT SINGLE NAME1 STR_SUPPL1
FROM ADRC
INTO (V_NAME1,V_STR_SUPPL1)
WHERE ADDRNUMBER = V_ADRNR.
IF SY-SUBRC EQ 0.
*- Name1
READ TABLE OUTTAB1 INDEX 1.
MOVE V_NAME1 TO OUTTAB1-VALUE.
MODIFY OUTTAB1 INDEX SY-TABIX.
*- Name1
READ TABLE OUTTAB1 INDEX 2.
MOVE V_STR_SUPPL1 TO OUTTAB1-VALUE.
APPEND OUTTAB1.
ELSE.
READ TABLE OUTTAB1 INDEX 1.
MOVE 'NO NAME' TO OUTTAB1-VALUE.
MODIFY OUTTAB1 INDEX SY-TABIX.
ENDIF.
ENDIF.
ENDFORM.
I am not sure where the mistake can be in the SAP-Form or in the ABAP Subroutine code....
Thanks,
Rama -
Performance of ABAP coding very poor
Hi gurus,
I'm a newbie in ABAP programming.
Currently, I managed to write an ABAP coding for BW to load data from a source DSO to target DSO.
We are using BW 3.5.
In the source, we have YTD amount as Key Figures.
In the start routine, we use ABAP coding to calculate the Monthly value and Last 12 Months value.
Monthly value is defined as: current month YTD - last month YTD (except when current month = January, then monthly value for January = YTD value for January)
Last 12 months value is calculated for example as follow:
for March 08, then Last 12 months value is April 07-March08
Thus the formula for last 12 Months value is:
YTD current month current year + YTD month12 last year - YTD current month last year
I used internal table to read and store all of the information
However, I need to read 3 times from internal table to get all of the necessary value to calculate the monthly value and last 12 months value.
The performance is very low. The system runs for 40 minutes to read and calculate 15500 data.
Therefore if you can perhaps give some hint/tip/tricks how to improve the performance of the code, it will be highly appreciated.
Thank you very much in advance.
Best regards,
Fen
My code is as follow:
Define internal table to hold last year & current year data:
DATA: LCYEARDATA type sorted table of /bic/aZABC3_O00
with unique key /BIC/ZABC_ENTI /BIC/ZABC_ACC
/BIC/ZABC_SUBA /BIC/ZABC_VERS CALMONTH
with header line.
Create variables needed to hold last month/year values.
DATA: CALMONTHLOW TYPE /BI0/OICALMONTH.
DATA: CALMONTHHIGH TYPE /BI0/OICALMONTH.
DATA: CALYEARTHISYEAR TYPE /BI0/OICALYEAR.
DATA: CALYEARLASTYEAR TYPE /BI0/OICALYEAR.
DATA: CURRENTMONTH TYPE /BI0/OICALMONTH2.
DATA: CURRENTMONTHLASTYEAR TYPE /BI0/OICALMONTH.
DATA: LASTMONTH TYPE /BI0/OICALMONTH.
DATA: CALMONTH12LASTYEAR TYPE /BI0/OICALMONTH.
DATA: LASTMOYTD type /BI0/OIAMOUNT.
DATA: LAST12MONTH TYPE /BI0/OIAMOUNT.
DATA: YTDLASTYEAR type /BI0/OIAMOUNT.
DATA: FIRSTRUN type N.
DATA: MONTHLYVALUE type /BI0/OIAMOUNT.
DATA: YTDMONTHLASTYEAR type /BI0/OIAMOUNT.
DATA: AMOUNT type /BI0/OIAMOUNT.
Set initial value of all variables to 0.
CALMONTHLOW = 0.
CALMONTHHIGH = 0.
CALYEARTHISYEAR = 0.
CALYEARLASTYEAR = 0.
CURRENTMONTH = 0.
CURRENTMONTHLASTYEAR = 0.
LASTMONTH = 0.
LASTMOYTD = 0.
LAST12MONTH = 0.
YTDLASTYEAR = 0.
YTDMONTHLASTYEAR = 0.
FIRSTRUN = 0.
MONTHLYVALUE = 0.
CALMONTH12LASTYEAR = 0.
Loop through data package.
LOOP AT DATA_PACKAGE.
IF DATA_PACKAGE IS NOT INITIAL.
First run:
IF FIRSTRUN = 0.
Get current year from any line in the data package.
CALYEARTHISYEAR = DATA_PACKAGE-CALMONTH(4).
FIRSTRUN = 1.
ENDIF.
Calculate last year (i.e. data package year - 1).
CALYEARLASTYEAR = CALYEARTHISYEAR - 1.
Calculate current month
CURRENTMONTH = DATA_PACKAGE-CALMONTH+4(2).
*Set CALMONTHLOW and CALMONTHHIGH as time period to fill the internal
*table:
CONCATENATE CALYEARLASTYEAR CURRENTMONTH INTO CALMONTHLOW.
CONCATENATE CALYEARTHISYEAR CURRENTMONTH INTO CALMONTHHIGH.
Fill internal table with Last Years data and Current Year data:
select *
from /bic/aABC2_O00
into table LCYEARDATA
WHERE CALMONTH >= CALMONTHLOW
AND CALMONTH <= CALMONTHHIGH
AND /BIC/ZABC_ENTI = DATA_PACKAGE-/BIC/ZABC_ENTI
AND /BIC/ZABC_ACC = DATA_PACKAGE-/BIC/ZABC_ACC
AND /BIC/ZABC_SUBA = DATA_PACKAGE-/BIC/ZABC_SUBA
AND /BIC/ZABC_VERS = DATA_PACKAGE-/BIC/ZABC_VERS.
Continue with the looping
Get last month from current month.
LASTMONTH = DATA_PACKAGE-CALMONTH - 1.
*CHECK IF CURRENTMONTH = JAN then LastmonthYTD amount = 0, else read
*from the internal table.
*CURRENTMONTH = DATA_PACKAGE-CALMONTH+4(2). (this variable has been set
*above)
IF CURRENTMONTH = '01'.
LASTMOYTD = 0.
ELSE.
READ TABLE LCYEARDATA
WITH KEY
/BIC/ZABC_ENTI = DATA_PACKAGE-/BIC/ZABC_ENTI
/BIC/ZABC_ACC = DATA_PACKAGE-/BIC/ZABC_ACC
/BIC/ZABC_SUBA = DATA_PACKAGE-/BIC/ZABC_SUBA
/BIC/ZABC_VERS = DATA_PACKAGE-/BIC/ZABC_VERS
CALMONTH = LASTMONTH.
IF sy-subrc IS INITIAL.
LASTMOYTD = LCYEARDATA-AMOUNT.
ENDIF.
ENDIF.
*Calculate Monhtly value for this month (to later be stored in data
*package)
MONTHLYVALUE = DATA_PACKAGE-AMOUNT - LASTMOYTD.
Count value for Last 12 Months:
1: Get the YTD Month12 Last Year & YTD CurrentMonth Last Year.
CONCATENATE CALYEARLASTYEAR CURRENTMONTH INTO
CURRENTMONTHLASTYEAR.
CONCATENATE CALYEARLASTYEAR '12' INTO CALMONTH12LASTYEAR.
READ TABLE LCYEARDATA
WITH KEY
/BIC/ZABC_ENTI = DATA_PACKAGE-/BIC/ZABC_ENTI
/BIC/ZABC_ACC = DATA_PACKAGE-/BIC/ZABC_ACC
/BIC/ZABC_SUBA = DATA_PACKAGE-/BIC/ZABC_SUBA
/BIC/ZABC_VERS = DATA_PACKAGE-/BIC/ZABC_VERS
CALMONTH = CALMONTH12LASTYEAR.
IF sy-subrc IS INITIAL.
YTDLASTYEAR = LCYEARDATA-AMOUNT.
ENDIF.
READ TABLE LCYEARDATA
WITH KEY
/BIC/ZABC_ENTI = DATA_PACKAGE-/BIC/ZABC_ENTI
/BIC/ZABC_ACC = DATA_PACKAGE-/BIC/ZABC_ACC
/BIC/ZABC_SUBA = DATA_PACKAGE-/BIC/ZABC_SUBA
/BIC/ZABC_VERS = DATA_PACKAGE-/BIC/ZABC_VERS
CALMONTH = CURRENTMONTHLASTYEAR.
IF sy-subrc IS INITIAL.
YTDMONTHLASTYEAR = LCYEARDATA-AMOUNT.
ENDIF.
2. Specify YTD This month.
AMOUNT = DATA_PACKAGE-AMOUNT.
*3: Last 12 Months = (YTD Last Year - YTD Month Last Year) + YTD This
*Month
LAST12MONTH = YTDLASTYEAR - YTDMONTHLASTYEAR + YTDTHISMONTH.
LAST12MONTH = YTDLASTYEAR - YTDMONTHLASTYEAR + AMOUNT.
Save MONTHLYVALUE and LAST12MONTH to the DATA_PACKAGE.
DATA_PACKAGE-/BIC/ZAMTMO = MONTHLYVALUE.
DATA_PACKAGE-/BIC/ZAMTLTM = LAST12MONTH.
modify DATA_PACKAGE.
ENDIF.
ENDLOOP.
ABORT = 0.Hi,
Just check these blogs to improve performance...
The SQL Trace (ST05) u2013 Quick and Easy
The SQL Trace (ST05) Quick and Easy
The ABAP Runtime Trace (SE30) - Quick and Easy
The ABAP Runtime Trace (SE30) - Quick and Easy
Regards,
Sachin -
View past transation performance of ABAP and portal
I would like to know where I can find past statistics on transaction performance for both an ABAP stack and a java like a portal system.
I am familiar with NWA on java but I don't know where to find a performance period for inbound transaction and how many seconds it tooks to process.
Also I would like to know the transaction where I can find how long it took for a transaction for a particular period or a particular user.
I know under admin--> workload there is a large bunch of information but I need to find transaction performance and I can't seem to find it under this tcode.
Thanks
Weyland Y.Weyland,
You need to enable Portal Activity Report for Enterprise Portal 7.0 and then you will be able to see it.
Check this link and SAP Note 1084379
[http://help.sap.com/saphelp_nw04/helpdata/en/48/6aa9429b930b31e10000000a1550b0/content.htm]
Thanks,
Digesh
Edited by: digeshjoshi on Dec 15, 2009 4:32 PM -
How do you take care of performance issues in your abap programs?
HI
and you can see this also
Ways of Performance Tuning
1. Selection Criteria
2. Select Statements
Select Queries
SQL Interface
Aggregate Functions
For all Entries
Select Over more than one Internal table
Selection Criteria
1. Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement.
2. Select with selection list.
Points # 1/2
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list
SELECT CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
WHERE SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
Select Statements Select Queries
1. Avoid nested selects
2. Select all the records in a single shot using into table clause of select statement rather than to use Append statements.
3. When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index.
4. For testing existence , use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit.
5. Use Select Single if all primary key fields are supplied in the Where condition .
Point # 1
SELECT * FROM EKKO INTO EKKO_WA.
SELECT * FROM EKAN INTO EKAN_WA
WHERE EBELN = EKKO_WA-EBELN.
ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
FROM EKKO AS P INNER JOIN EKAN AS F
ON PEBELN = FEBELN.
Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.
Point # 2
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table
SELECT CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
WHERE SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
Point # 3
To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields . In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.
Point # 4
SELECT * FROM SBOOK INTO SBOOK_WA
UP TO 1 ROWS
WHERE CARRID = 'LH'.
ENDSELECT.
The above code is more optimized as compared to the code mentioned below for testing existence of a record.
SELECT * FROM SBOOK INTO SBOOK_WA
WHERE CARRID = 'LH'.
EXIT.
ENDSELECT.
Point # 5
If all primary key fields are supplied in the Where condition you can even use Select Single.
Select Single requires one communication with the database system, whereas Select-Endselect needs two.
Select Statements contd.. SQL Interface
1. Use column updates instead of single-row updates
to update your database tables.
2. For all frequently used Select statements, try to use an index.
3. Using buffered tables improves the performance considerably.
Point # 1
SELECT * FROM SFLIGHT INTO SFLIGHT_WA.
SFLIGHT_WA-SEATSOCC =
SFLIGHT_WA-SEATSOCC - 1.
UPDATE SFLIGHT FROM SFLIGHT_WA.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
UPDATE SFLIGHT
SET SEATSOCC = SEATSOCC - 1.
Point # 2
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
WHERE CARRID = 'LH'
AND CONNID = '0400'.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
WHERE MANDT IN ( SELECT MANDT FROM T000 )
AND CARRID = 'LH'
AND CONNID = '0400'.
ENDSELECT.
Point # 3
Bypassing the buffer increases the network considerably
SELECT SINGLE * FROM T100 INTO T100_WA
BYPASSING BUFFER
WHERE SPRSL = 'D'
AND ARBGB = '00'
AND MSGNR = '999'.
The above mentioned code can be more optimized by using the following code
SELECT SINGLE * FROM T100 INTO T100_WA
WHERE SPRSL = 'D'
AND ARBGB = '00'
AND MSGNR = '999'.
Select Statements contd Aggregate Functions
If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself.
Some of the Aggregate functions allowed in SAP are MAX, MIN, AVG, SUM, COUNT, COUNT( * )
Consider the following extract.
Maxno = 0.
Select * from zflight where airln = LF and cntry = IN.
Check zflight-fligh > maxno.
Maxno = zflight-fligh.
Endselect.
The above mentioned code can be much more optimized by using the following code.
Select max( fligh ) from zflight into maxno where airln = LF and cntry = IN.
Select Statements contd For All Entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Points to be must considered FOR ALL ENTRIES
Check that data is present in the driver table
Sorting the driver table
Removing duplicates from the driver table
Consider the following piece of extract
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
The above mentioned can be more optimized by using the following code.
Sort int_cntry by cntry.
Delete adjacent duplicates from int_cntry.
If NOT int_cntry[] is INITIAL.
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
Endif.
Select Statements contd Select Over more than one Internal table
1. Its better to use a views instead of nested Select statements.
2. To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.
3. Instead of using nested Select loops it is often better to use subqueries.
Point # 1
SELECT * FROM DD01L INTO DD01L_WA
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
SELECT SINGLE * FROM DD01T INTO DD01T_WA
WHERE DOMNAME = DD01L_WA-DOMNAME
AND AS4LOCAL = 'A'
AND AS4VERS = DD01L_WA-AS4VERS
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
The above code can be more optimized by extracting all the data from view DD01V_WA
SELECT * FROM DD01V INTO DD01V_WA
WHERE DOMNAME LIKE 'CHAR%'
AND DDLANGUAGE = SY-LANGU.
ENDSELECT
Point # 2
SELECT * FROM EKKO INTO EKKO_WA.
SELECT * FROM EKAN INTO EKAN_WA
WHERE EBELN = EKKO_WA-EBELN.
ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
FROM EKKO AS P INNER JOIN EKAN AS F
ON PEBELN = FEBELN.
Point # 3
SELECT * FROM SPFLI
INTO TABLE T_SPFLI
WHERE CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK'.
SELECT * FROM SFLIGHT AS F
INTO SFLIGHT_WA
FOR ALL ENTRIES IN T_SPFLI
WHERE SEATSOCC < F~SEATSMAX
AND CARRID = T_SPFLI-CARRID
AND CONNID = T_SPFLI-CONNID
AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
The above mentioned code can be even more optimized by using subqueries instead of for all entries.
SELECT * FROM SFLIGHT AS F INTO SFLIGHT_WA
WHERE SEATSOCC < F~SEATSMAX
AND EXISTS ( SELECT * FROM SPFLI
WHERE CARRID = F~CARRID
AND CONNID = F~CONNID
AND CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK' )
AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
1. Table operations should be done using explicit work areas rather than via header lines.
2. Always try to use binary search instead of linear search. But dont forget to sort your internal table before that.
3. A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime.
4. A binary search using secondary index takes considerably less time.
5. LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified condition internally.
6. Modifying selected components using MODIFY itab TRANSPORTING f1 f2.. accelerates the task of updating a line of an internal table.
Point # 2
READ TABLE ITAB INTO WA WITH KEY K = 'X BINARY SEARCH.
IS MUCH FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY K = 'X'.
If TAB has n entries, linear search runs in O( n ) time, whereas binary search takes only O( log2( n ) ).
Point # 3
READ TABLE ITAB INTO WA WITH KEY K = 'X'. IS FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY (NAME) = 'X'.
Point # 5
LOOP AT ITAB INTO WA WHERE K = 'X'.
ENDLOOP.
The above code is much faster than using
LOOP AT ITAB INTO WA.
CHECK WA-K = 'X'.
ENDLOOP.
Point # 6
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1 TRANSPORTING DATE.
The above code is more optimized as compared to
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1.
7. Accessing the table entries directly in a "LOOP ... ASSIGNING ..." accelerates the task of updating a set of lines of an internal table considerably
8. If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.
9. "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to LOOP-APPEND-ENDLOOP.
10. DELETE ADJACENT DUPLICATES accelerates the task of deleting duplicate entries considerably as compared to READ-LOOP-DELETE-ENDLOOP.
11. "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to DO -DELETE-ENDDO.
Point # 7
Modifying selected components only makes the program faster as compared to Modifying all lines completely.
e.g,
LOOP AT ITAB ASSIGNING <WA>.
I = SY-TABIX MOD 2.
IF I = 0.
<WA>-FLAG = 'X'.
ENDIF.
ENDLOOP.
The above code works faster as compared to
LOOP AT ITAB INTO WA.
I = SY-TABIX MOD 2.
IF I = 0.
WA-FLAG = 'X'.
MODIFY ITAB FROM WA.
ENDIF.
ENDLOOP.
Point # 8
LOOP AT ITAB1 INTO WA1.
READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.
IF SY-SUBRC = 0.
ADD: WA1-VAL1 TO WA2-VAL1,
WA1-VAL2 TO WA2-VAL2.
MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.
ELSE.
INSERT WA1 INTO ITAB2 INDEX SY-TABIX.
ENDIF.
ENDLOOP.
The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by
LOOP AT ITAB1 INTO WA.
COLLECT WA INTO ITAB2.
ENDLOOP.
SORT ITAB2 BY K.
COLLECT, however, uses a hash algorithm and is therefore independent
of the number of entries (i.e. O(1)) .
Point # 9
APPEND LINES OF ITAB1 TO ITAB2.
This is more optimized as compared to
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
Point # 10
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.
This is much more optimized as compared to
READ TABLE ITAB INDEX 1 INTO PREV_LINE.
LOOP AT ITAB FROM 2 INTO WA.
IF WA = PREV_LINE.
DELETE ITAB.
ELSE.
PREV_LINE = WA.
ENDIF.
ENDLOOP.
Point # 11
DELETE ITAB FROM 450 TO 550.
This is much more optimized as compared to
DO 101 TIMES.
DELETE ITAB INDEX 450.
ENDDO.
12. Copying internal tables by using ITAB2[ ] = ITAB1[ ] as compared to LOOP-APPEND-ENDLOOP.
13. Specify the sort key as restrictively as possible to run the program faster.
Point # 12
ITAB2[] = ITAB1[].
This is much more optimized as compared to
REFRESH ITAB2.
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
Point # 13
SORT ITAB BY K. makes the program runs faster as compared to SORT ITAB.
Internal Tables contd
Hashed and Sorted tables
1. For single read access hashed tables are more optimized as compared to sorted tables.
2. For partial sequential access sorted tables are more optimized as compared to hashed tables
Hashed And Sorted Tables
Point # 1
Consider the following example where HTAB is a hashed table and STAB is a sorted table
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE HTAB INTO WA WITH TABLE KEY K = N.
IF SY-SUBRC = 0.
ENDIF.
ENDDO.
This runs faster for single read access as compared to the following same code for sorted table
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE STAB INTO WA WITH TABLE KEY K = N.
IF SY-SUBRC = 0.
ENDIF.
ENDDO.
Point # 2
Similarly for Partial Sequential access the STAB runs faster as compared to HTAB
LOOP AT STAB INTO WA WHERE K = SUBKEY.
ENDLOOP.
This runs faster as compared to
LOOP AT HTAB INTO WA WHERE K = SUBKEY.
ENDLOOP. -
hi experts
in one of my program the performance is getting affected in the abap statement not in the database access
the program logic goes in this way from the main program 3 performs were called for in the last performa onlythe entire processing starts
in that last perform it s callin for a report through submit and return statement , the called report s again refering to one include program.
in se30 the highest % it showssthe last perform that s said and the program that s called through submit statement the include program is not affecting the performance please tell mehow to change the report insucha wayi can improve the performance
please reply
will assign marks for sure
thanks in advanceFrom your as I understand your original message, your report is calling another report and it is taking a very long time in that step.
Obviously, the second program is taking time and that is the one to be analyzed. So, you put a break-point on the SUBMIT statement and see what are the parameters that being sent to the second program. Then, run the second program all by itself using the parameters you have noted down and analyze what the problem is.
If my response is totally off of your question, please clarify the question. -
how perform on commit & rollback works explain with real time example ?
hi,
PERFORM n ON COMMIT
Addition
1. ... LEVEL level
Effect
Executes the specified subroutine when a COMMIT WORK occurs. This allows you to execute a subroutine only if the logical transaction has ended successfully. The subroutine is not executed until the key word COMMIT WORK is called. FORMs specified several times are executed only once on COMMIT WORK (see COMMIT WORK ).
If you call ROLLBACK WORK , you delete all the specified routines.
Note
With PERFORM ... ON COMMIT , you cannot transfer any data with USING/CHANGING . To do this, you must either store the data in global variables or store it temporarily with EXPORT ... TO MEMORY .
Addition 1
... LEVEL level
Effect
The addition LEVEL , followed by a field, defines the order in which the subroutines are executed after COMMIT WORK . They are called in ascending order of level. If there is no addition LEVEL , the subroutine always has the level zero. If the level is the same, the order of calls determines the order of execution. Level assignment occurs during development, e.g. by defining constants in an include program. The level must be of type I.
Implicit Database Rollbacks in the R/3 System
The following cases lead to an implicit database rollback:
· Runtime error in an application program
This occurs whenever an application program has to terminate because of an unforeseen situation (for example, trying to divide by zero).
· Termination message
Termination messages are generated using the ABAP statement MESSAGE with the message type A or X. In certain cases (updates), they are also generated with message types I, W, and E. These messages end the current application program.
Also follow this link.
http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/content.htm
Hope this helps, Do reward.
Edited by: Runal Singh on Apr 24, 2008 11:53 AM -
Performing Initial ABAP Configuration
Can anyone describe or list all the Initial ABAP configurations to be performed on a newly installed NetWeaver System with AS JAVA and usage types except MI.
Examples rz04,rz03,rz10, STMS, SMLG, sm28, se06, scc4,sm37 etc.
We need to create a document with all the Initial Configuration steps but have checked the online documents and they just list a few.
Many thanks.
Regards
JohnHi John,
Go through below links.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/0b207fd3-0a01-0010-3d83-8cf14fd6929f
http://help.sap.com/saphelp_nw70/helpdata/en/95/10fb40af87ee6fe10000000a1550b0/content.htm
http://www.sap-img.com/basis/useful-sap-system-administration-transactions.htm
Regards,
Syf
Edited by: syfulla shaik on Aug 14, 2008 5:50 PM
Edited by: syfulla shaik on Aug 14, 2008 5:53 PM -
Dear Friends,
Plz explain what is T code to check performance tunig
can u plz explain me what important points 2 improve performance
reddyin most cases performance issue is caused by select query.... most common mistake being.. imagin there is a report with the following fields on the selection screen
bukrs,belnr,gjahr,werks,matnr...and u have to make a select on BSEG table
select * from bseg into tb_bseg
where bukrs in s_bukrs and
belnr in s_belnr and
gjahr in s_gjahr and
werks in s_werks and
matnr in s_matnr.
if u do it this way ur program will get killed... always use key fields on the where clause of select query. and delete the reset using delete statament as follows.
select * from bseg where bukrs in s_bukrs and
belnr in s_belnr and
gjahr in s_gjahr .
delete tb_bseg where not werks in s_werks or
not matnr in s_matnr.
above method will have a tremendous impact on the performance of the program. -
Performance issue on Java Stored Procedure
I have converted the Stored Procedures into JSP with SQLJ. I
loaded the classes (not the source) onto Oracle 8i Database and
published within tbe stored packages. What I found out was the
performance is about 12 times on average slower than the PL/SQL
stored packages when I made calls to JSP. I am not surprise JSP
is slower than PL/SQL but can we improve by tunning the Java
codings or VM within the 8i database?
nullJames Chan (guest) wrote:
: I have converted the Stored Procedures into JSP with SQLJ. I
: loaded the classes (not the source) onto Oracle 8i Database and
: published within tbe stored packages. What I found out was the
: performance is about 12 times on average slower than the PL/SQL
: stored packages when I made calls to JSP. I am not surprise JSP
: is slower than PL/SQL but can we improve by tunning the Java
: codings or VM within the 8i database?
all user written java code in the 8i rdbms is currently running
as bytecode in the jvm.
a future release will provide a component called "Native Compiler
[NCOMP]" so it should run considerably faster then.
see the following link for details :
http://technet.oracle.com/files/search/search.htm?ncomp
null
Maybe you are looking for
-
I tried this in the Mac Mini section without any help. I have my Airport Extreme in my home office. My DSL is hooked to the Extreme and then out to my iMac which does not have an Airport card. My son is using an Express in his bedroom to use the DSL
-
How to output contents as they're processed
This is probably a very simple question, but I'm just wondering how to output the items on a page as they're processed, instead of having to wait for the processing for the entire page to be done before displaying anything. Does this make sense? Than
-
When I open Firefox, the tab to type in the web address is not there, nor anywhere else--Where did it go?
-
Music sound won't play but video will
I have had my 80 GB ipid video for only a couple of weeks now and it was working perfectly fine until the other day when the sound quit on me. I could sometimes hear a scratching noise, but most of the time I don't hear anything. The sound on my vide
-
Searching for Archiving Object for table COMH PP-PI messages header
Hallo, i am faced to archive records from table COMH (PP-PI message headers). And searched SMP, SDN, Dataguides but i could not find any objects or delete-reports for this table. Could anyone give input on how to get rid of the records in COMH? with