2008 Jul 14 12:47 AM
Hi All,
I need to get the latest sales order number for Sold-to party and also for ship-to party. I am using VBPA table and fetching the latest sales order but it is taking lot of time.
I have created a index with KUNNR and PARVW in VBPA table but still it is doing a sequential read and taking time. Following is my code:
SELECT vbeln
FROM vbpa
INTO TABLE gt_vbak
WHERE kunnr EQ p_kunnr .
AND parvw EQ 'AG'.
I am sorting the table gt_vbak and getting the latest entry but it is very time consuming
or
SELECT max( vbeln )
FROM vbpa
INTO vbak-vbeln
WHERE kunnr EQ p_kunnr .
AND parvw EQ 'AG'.
Both statements are time consuming.
If any one knows if there is any better way or if there is any table or function module which gives the list of sales orders based on partner function please let me know.
Thanks in advance.
Sonali.
2008 Jul 14 2:14 AM
Avoid 'EQ'. Instead use '='. Try using ODER BY in your clause.
A
2008 Jul 14 3:00 AM
There is no difference between = and EQ. This is from ABAP documentation for SQL conditions.
=, EQ True, if the content of col is the same as the content of f.
It is not very good to use ORDER BY because you transfer your load on your database. It is better to use SORT BY because this is done on the application server. Usually the DB is bottleneck, not the application servers.
2008 Jul 14 2:28 AM
Hi,
Please try to add the primary key to the where condition even they don't used. You can make them as
VBELN in ( ) and POSNR in ( ).
Check it whether it is effective.
Best regards,
Chris.
2008 Jul 14 3:04 AM
Hi,
Try to use some key fields with null value.....if possible can u try PACKAGE SIZE in select stmt....try it out....bcoz performance is d best possible guess only...
Thnx.
2008 Jul 14 3:32 AM
2008 Jul 14 4:14 AM
Use all primary key in your select statement as due to indexing data fetching time would be reduced.
SELECT VBELN POSNR PARVW
FROM vbpa
INTO TABLE gt_vbak
WHERE kunnr EQ p_kunnr .
AND parvw EQ 'AG'.
Reward if usefull,
Thanks.
2008 Jul 14 4:29 AM
Sonali,
Check the SAP Notes 185530.It may give you some lead regarding improving performance in SD Developments.
K.Kiran.