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

Performance tuning on this code

Former Member
0 Likes
545

Hi guys,

This piece of coding is taking ages to execute, any idea how can i fine tune it?

SELECT vbeln vbtyp_n vbtyp_v vbelv

INTO TABLE lt_vbfa1 FROM vbfa

FOR ALL ENTRIES IN lt_vbrp

WHERE vbeln = lt_vbrp-vbeln

AND vbtyp_n IN ('N','S')

AND vbtyp_v IN ('M','P','O').

Thanks in advance!

1 ACCEPTED SOLUTION
Read only

JackGraus
Active Contributor
0 Likes
517

Table VBFA (sales document flow) is to be used to find preceding documents, like cancelation invoices for an invoice.

Here original documents are to be found for a preceding document. Then it's better not to use table VBFA because its key is original document number. Then try to use VBRP-VGBEL (preceding document) or VBRP-AUBEL (preceding sales order). Here something like:

SELECT vbrk~vbeln vbrk~vbtyp vbrp~vgtyp vbrp~vgbel
INTO TABLE lt_vbfa1
FROM vbrk INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln
FOR ALL ENTRIES IN lt_vbrp
WHERE vbrk~vbeln = lt_vbrp-vbeln
AND   vbrp~posnr = lt_vbrp-posnr
AND   vbrk~vbtyp IN ('N','S')
AND   vbrp~vgtyp IN ('M','P','O').

Regards Jack

3 REPLIES 3
Read only

Former Member
0 Likes
517

GOOD MORNING BRO...

try out this one and check performance..

SELECT vbelv vbeln vbtyp_n vbtyp_v

INTO TABLE lt_vbfa1 FROM vbfa

FOR ALL ENTRIES IN lt_vbrp

WHERE vbeln = lt_vbrp-vbeln

AND vbtyp_n IN ('N','S')

AND vbtyp_v IN ('M','P','O').

Read only

Former Member
0 Likes
517

Hi,

Fetch data from the Database table without the where condition.

I.E.

SELECT vbeln vbtyp_n vbtyp_v vbelv

INTO TABLE lt_vbfa1 FROM vbfa

FOR ALL ENTRIES IN lt_vbrp

WHERE vbeln = lt_vbrp-vbeln.

Once that data is fetch use IF condition in loop.

LOOP at <ITAB>.

IF <ITAB>-vbtyp_n IN ('N','S')

AND <ITAB>-vbtyp_v IN ('M','P','O').

ENDIF.

ENDLOOP.

With above code Search in the database will be reduced...

This will solve the performance isse...

Thanks.

Read only

JackGraus
Active Contributor
0 Likes
518

Table VBFA (sales document flow) is to be used to find preceding documents, like cancelation invoices for an invoice.

Here original documents are to be found for a preceding document. Then it's better not to use table VBFA because its key is original document number. Then try to use VBRP-VGBEL (preceding document) or VBRP-AUBEL (preceding sales order). Here something like:

SELECT vbrk~vbeln vbrk~vbtyp vbrp~vgtyp vbrp~vgbel
INTO TABLE lt_vbfa1
FROM vbrk INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln
FOR ALL ENTRIES IN lt_vbrp
WHERE vbrk~vbeln = lt_vbrp-vbeln
AND   vbrp~posnr = lt_vbrp-posnr
AND   vbrk~vbtyp IN ('N','S')
AND   vbrp~vgtyp IN ('M','P','O').

Regards Jack