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: 

Freeze on vbap search by vgbel

Former Member
0 Kudos

I was wondering if any one knows of an issue when searching vbap by a corresponding vgbel. I am writing a program that first gets data from ordered, then gets data from the corresponding vgbel = vbap-vbeln in lips. For the program, I am trying to search first by lips, then by vgbel = lips-vbeln. When run from vbap to lips the search takes about 1.5 seconds, but when run from lips to vbap the program essentially freezes on the search( I have not actually let it complete even one select because it takes so long). Here are examples...

VBAP to LIPS (This works great)

SELECT vbeln matnr umvkz umvkn spart kwmeng meins abgru ean11

INTO CORRESPONDING FIELDS OF TABLE input_tab

FROM vbap

WHERE spart IN p_spart

AND erdat IN p_dat.

LOOP AT input_tab ASSIGNING <input_ref>.

SELECT SINGLE werks lgmng

FROM lips

INTO (<input_ref>-werks, <input_ref>-lgmng)

WHERE vgbel = <input_ref>-vbeln

AND matnr = <input_ref>-matnr.

ENDLOOP.

LIPS to VBAP ( This freezes)

SELECT vbeln matnr umvkz umvkn spart werks lgmng meins ean11

FROM lips

INTO CORRESPONDING FIELDS OF TABLE input_tab

WHERE spart IN p_spart

AND lgmng > '0'.

LOOP AT input_tab ASSIGNING <input_ref>.

SELECT SINGLE kwmeng abgru <====Doesn't even complete one iteration

INTO (<input_ref>-kwmeng, <input_ref>-abgru)

FROM vbap

WHERE vgbel = <input_ref>-vbeln

AND matnr = <input_ref>-matnr.

ENDLOOP.

I have made sure that input_tab and <input_ref> both have valid values in them to search by at the point when it reaches the select statement in the loop, so it is not trying to search for nothing or an invalid value. Why would it search fine in lips but freezes when doing the same thing in vbap?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Because VGBEL is not a key field for VBAP. Try selecting from VAPMA instead. There is a note about performance issue SELECTing from SD tables. Have a look for it. It should help a lot.

Rob

2 REPLIES 2

Former Member
0 Kudos

Because VGBEL is not a key field for VBAP. Try selecting from VAPMA instead. There is a note about performance issue SELECTing from SD tables. Have a look for it. It should help a lot.

Rob

Former Member
0 Kudos

Thanks for the tips. I am new to the ABAP development world so I am still figuring out the data and relationships in SAP. I appreciate your help and suggestions with the notes. I actually realized from your suggestion that I should be SELECTing where vbeln = lips-vgbel, but my code was SELECTing by vgbel = lips-vbeln.