Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to increase performance ?? EXPERTS HELP PLS!

Former Member
0 Likes
1,218

Hi Experts,

I am gonna post a sample code which takes the most time in my program. It takes great deal of time and i need to decrease its working time. Pls help. Getting data from vbak takes a hell of time.! In Queue tb_ekbe has 26700 data temp_vbak has 8500 data and then t_vbak it is hell of data. IS there anyway to correct my coding. There is no way to change the criterias.

data: tb_ekbe like table of ekbe with header line,

t_vbak type sorted table of vbak with header line

with non-unique key BSTNK,

t_vbap like vbap occurs 0 with header line.

DATA : BEGIN OF TEMP_VBAK OCCURS 0,

BSTNK LIKE VBAK-BSTNK,

END OF TEMP_VBAK.

SELECT * FROM EKBE

INTO CORRESPONDING FIELDS OF TABLE TB_EKBE

WHERE VGABE IN RA_VGABE AND

BUDAT IN SO_BUDAT.

LOOP AT TB_EKBE.

TEMP_VBAK-BSTNK = TB_EKBE-EBELN .

APPEND TEMP_VBAK.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM TEMP_VBAK COMPARING BSTNK.

SELECT * FROM VBAK

INTO CORRESPONDING FIELDS OF TABLE T_VBAK

FOR ALL ENTRIES IN TEMP_VBAK

WHERE BSTNK EQ TEMP_VBAK-BSTNK.

LOOP AT TB_EKBE.

.......... code here.

LOOP AT T_VBAK WHERE BSTNK = TB_DATA-EBELN.

CLEAR T_VBAP.

REFRESH T_VBAP.

SELECT * FROM VBAP

INTO CORRESPONDING FIELDS OF TABLE T_VBAP

WHERE VBELN EQ T_VBAK-VBELN AND

MATNR EQ TB_DATA-MATNR.

LOOP AT T_VBAP.

-


code here

ENDLOOP.

ENDLOOP.

-


code here

endloop.

Thanks!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,192

first remove all move correspoind fields and remove * in selects

feach only the fields u need and build the internal table in that way.

Hi Experts,

I am gonna post a sample code which takes the most time in my program. It takes great deal of time and i need to decrease its working time. Pls help. Getting data from vbak takes a hell of time.! In Queue tb_ekbe has 26700 data temp_vbak has 8500 data and then t_vbak it is hell of data. IS there anyway to correct my coding. There is no way to change the criterias.

data: tb_ekbe like table of ekbe with header line,

t_vbak type sorted table of vbak with header line

with non-unique key BSTNK,

t_vbap like vbap occurs 0 with header line.

DATA : BEGIN OF TEMP_VBAK OCCURS 0,

BSTNK LIKE VBAK-BSTNK,

END OF TEMP_VBAK.

SELECT * FROM EKBE

INTO CORRESPONDING FIELDS OF TABLE TB_EKBE

WHERE VGABE IN RA_VGABE AND

BUDAT IN SO_BUDAT.

LOOP AT TB_EKBE.

TEMP_VBAK-BSTNK = TB_EKBE-EBELN .

APPEND TEMP_VBAK.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM TEMP_VBAK COMPARING BSTNK.

SELECT * FROM VBAK

INTO CORRESPONDING FIELDS OF TABLE T_VBAK

FOR ALL ENTRIES IN TEMP_VBAK

WHERE BSTNK EQ TEMP_VBAK-BSTNK.

LOOP AT TB_EKBE.

.......... code here.

LOOP AT T_VBAK WHERE BSTNK = TB_DATA-EBELN.

CLEAR T_VBAP.

REFRESH T_VBAP.

SELECT * FROM VBAP

INTO CORRESPONDING FIELDS OF TABLE T_VBAP

WHERE VBELN EQ T_VBAK-VBELN AND

MATNR EQ TB_DATA-MATNR.

LOOP AT T_VBAP.

-


code here

ENDLOOP.

ENDLOOP.

-


code here

endloop.

Thanks!

8 REPLIES 8
Read only

Former Member
0 Likes
1,192

Hi

1. Remove the select query withen the loop and instead use

" for all entries".

2. Avoin using Move corresponding.

Regards,

Jaya Vani

Read only

Former Member
0 Likes
1,193

first remove all move correspoind fields and remove * in selects

feach only the fields u need and build the internal table in that way.

Read only

Former Member
0 Likes
1,192

avoid corresponding in select statement

avoind select statement inside the loop.

give proper key field in where condition.

Reward IF...........

Regards

Anbu

Read only

GauthamV
Active Contributor
0 Likes
1,192

Hi,

Some of the tips to improve the Performance of a Program.

1. Avoid using SELECT...ENDSELECT...or SELECT *. Construct and use SELECT ... INTO TABLE.

2. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot. And dont forget to check if the internal table is empty before you use For All Entries statement.

3 Avoid using nested SELECT statement, SELECT within LOOPs.

4. Try not to use INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.

5. Dont use nested loops when working with large internal tables.

6. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.

7. Use "CHECK" instead of IF/ENDIF whenever possible.

8.. Use "CASE" instead of IF/ENDIF whenever possible.

9. Use "MOVE" with individual variable/field moves instead of "MOVE-

CORRESPONDING".

10. You can use the transaction SE30 and use the examples and check your code if you have any further doubts.

Reward if useful.

Read only

Former Member
0 Likes
1,192

Thanks for the answers i will check these out

Read only

Former Member
0 Likes
1,192

Hi,

The very basic thing try to get data in internal table first then use FOR ALL ENTRIES instead of SELECT in LOOP.

When you use FOR ALL ENTRIES see that the table IS NOT INITIAL.

SELECT * also hampers the performance so use SELECT fields.

Remove all INTO CORRESPONDING FIELDS OF use INTO TABLE.

Try to give condition in SELECT in same sequence in which the primary kay is there.

Use workarea as far as possible.

Try to fetch all relevant data in all internal tables before using it.

Always check sy-subrc after every select statement.

Hope this will help you.

Plz reward if useful.

Thanks,

Dhanashri.

Read only

ThomasZloch
Active Contributor
0 Likes
1,192

here some more specific advice:

> SELECT * FROM EKBE

> INTO CORRESPONDING FIELDS OF TABLE TB_EKBE

> WHERE VGABE IN RA_VGABE AND

> BUDAT IN SO_BUDAT.

--> not using any index, full table scan, slow

> SELECT * FROM VBAK

> INTO CORRESPONDING FIELDS OF TABLE T_VBAK

> FOR ALL ENTRIES IN TEMP_VBAK

> WHERE BSTNK EQ TEMP_VBAK-BSTNK.

--> same as above

Greetings

Thomas

Read only

Former Member
0 Likes
1,192

Hi Aycan,

Here are the steps:

1.) try to avoid into corresponding fields, use into table.

2.) avoid the statement * select * from *. try to get only the specific field for your internal table.

3.) Use for all entries if you want to refer an internal table to another itab.

4.) make sure your declaration of your internal table is not using occurs. Try using types.

hope this will help you!

Regards,

Mark