Application Development 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: 

Vbrk and Vbrp tables performance problem

Former Member
0 Kudos

Hi all,

The below query is taking lot of time in QAS i need to decrease the time without affecting the logic.....

SELECT vbrk~kunag

vbkd~bstkd

vbkd~bstdk

INTO TABLE c_tab_po FROM vbrp

INNER JOIN vbrk ON vbrkmandt = vbrpmandt AND vbrk~vbeln =

vbrp~vbeln

INNER JOIN vbkd ON vbkdmandt = vbrpmandt AND vbkd~vbeln =

vbrp~aubel

AND vbkd~posnr = con_zposnr

WHERE vbrp~vbeln EQ nast-objky.

DELETE ADJACENT DUPLICATES FROM c_tab_po COMPARING ALL FIELDS.

*Getting the other Invoices based on the customer PO number

IF c_tab_po[] IS NOT INITIAL.

SELECT

vbrk~kunag

vbkd~bstkd

vbkd~bstdk

vbkdposex_e vbrkvkorg

vbrpvbeln vbrpposnr vbrp~erdat

vbpakunnr vbrpaubel vbrpaupos vbakerdat

vbrpmatnr vbrkmwsbk vbrp~netwr

vbrkvaldt vbrkzterm vbrk~vbtyp

INTO TABLE g_tab_invoice FROM vbrp

INNER JOIN vbrk ON vbrkmandt = vbrpmandt AND vbrk~vbeln =

vbrp~vbeln

INNER JOIN vbkd ON vbkdmandt = vbrpmandt AND vbkd~vbeln =

vbrp~aubel

AND vbkd~posnr = con_zposnr

INNER JOIN vbpa ON vbpamandt = vbrpmandt AND vbpa~vbeln =

vbrp~aubel

AND vbpaposnr = con_zposnr AND vbpaparvw =

con_parvw

INNER JOIN vbak ON vbakmandt = vbakmandt AND vbak~vbeln =

vbrp~aubel

FOR ALL entries IN c_tab_po

WHERE vbrk~kunag EQ c_tab_po-kunag AND

vbkd~bstkd EQ c_tab_po-bstkd AND

vbkd~bstdk EQ c_tab_po-bstdk.

ENDIF.

15 REPLIES 15

Former Member
0 Kudos

You can create a view to reduce the time becuase it is alwayss to create a view if you are joining more tables.

One more thing you are using for all entries statement but you should be careful while using this statement because for the large no of records this statement gives dump.

0 Kudos

Is it possbile for us to use the view in the logic???

Former Member
0 Kudos

Hi Younus,

Try to look for a FM to fetch all the entries from the table & then later filter it with the condition .

-Bhumika

former_member194613
Active Contributor
0 Kudos

if you are working on these table, always check the SAP note 185530 first, it tells you where you must use index-tables.

Siegfried

0 Kudos

If all else fails, you can do the RFC method: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/performance%2...

The document does not go into a 'monitoring table', which is recommended.

I hope that this helps,

Dan P.

Former Member
0 Kudos

Hi Younus,

First join seems to be oku2026

But you are querying Db tables multiple times to avoid this.

Fetch the fields

vbkdposex_e vbrkvkorg

vbrpvbeln vbrpposnr vbrp~erdat

vbrpaubel vbrpaupos

vbrpmatnr vbrkmwsbk vbrp~netwr

vbrkvaldt vbrkzterm vbrk~vbtyp

in the first join itself.



SELECT vbrk~kunag
vbkd~bstkd
vbkd~bstdk
vbkd~posex_e vbrk~vkorg
vbrp~vbeln vbrp~posnr vbrp~erdat
vbrp~aubel vbrp~aupos 
vbrp~matnr vbrk~mwsbk vbrp~netwr
vbrk~valdt vbrk~zterm vbrk~vbtyp
INTO TABLE c_tab_po FROM vbrp
INNER JOIN vbrk ON vbrk~mandt = vbrp~mandt AND vbrk~vbeln =
vbrp~vbeln
INNER JOIN vbkd ON vbkd~mandt = vbrp~mandt AND vbkd~vbeln =
vbrp~aubel
AND vbkd~posnr = con_zposnr
WHERE vbrp~vbeln EQ nast-objky.

then Just join VBPA & VBAK and get required data.

Thanks,

Sudha

0 Kudos

Hi,

you should use view in this case ...

that will definitely improve the performance

Edited by: Aarif Baig on May 20, 2009 2:02 PM

0 Kudos

>

> you should use view in this case ...

> that will definitely improve the performance

before making suggestions like this you should sit back and think why on earth a view (which is not more than joined tables) would be better than having the joins in the actual select.

have you ever actually improved any query by changing it to a view?

(well, one advantage of using the view is if you are really screwing things up in the join, and at least the person that created the view might know better)

0 Kudos

view always has an advantage

may be you need to think again

0 Kudos

Views are good for reusability, once you found an efficient way to link tables A, B and C you can "fix" the link inside a database view (inner joins only), but there is no difference in performance.

Thomas

0 Kudos

>

> view always has an advantage

Can you provide an example - with run times and traces?

Rob

Former Member
0 Kudos

create view for that tables and do it

sujeet2918
Active Contributor
0 Kudos

Dear Younus,

SAP itself never recommends to use Joins where heavy data is to be retrieved.

better you use seperate internal table for each table and use keyword FOR ALL ENTRIES to select data according to previous table entry. do this serially.

Have a Nice Day,

Cheers,

Sujeet

Edited by: Sujeet Mishra on May 21, 2009 8:44 AM

Edited by: Sujeet Mishra on May 21, 2009 8:47 AM

0 Kudos

Sujeet please see at the top of this forum before posting..

Rob

Former Member
0 Kudos

i resolved it