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: 

Help on fetching STO

Former Member
0 Kudos
192

Hi i have select select like this

SELECT likp~vbeln

lips~posnr

likp~kunnr

lips~lfimg

lips~uecha

lips~matnr

lips~lgort

lips~charg

lips~vgbel

lips~arktx

lips~werks

likp~wadat_ist

kna1~name1

FROM likp INNER JOIN lips ON lipsvbeln = likpvbeln

INNER JOIN kna1 ON kna1kunnr = likpkunnr

INNER JOIN ekko ON ekkoebeln = lipsvgbel

INNER JOIN vbup ON vbupvbeln = lipsvbeln

AND vbupposnr = lipsposnr

APPENDING corresponding fields of table itab

FOR ALL ENTRIES IN i

WHERE likp~vbeln = i-vbeln

AND likp~wadat_ist IN s_wadat

AND ( likplfart = 'NL' OR likplfart = 'NLCC')

AND kna1~land1 IN s_land1

AND vbup~wbsta IN r_wbsta.

here s_land1 is Ship to country code

r_wbsta is delivery status (range)

s_wadat is Goods Issue Date from selection screen

and table i is the following

SELECT vbeln FROM vlkpa INTO TABLE i

WHERE vkorg IN s_vkorg "Sales org from selection screen

AND lfart IN r_lfart. "this is a range of delivery types passed

I need help in breaking down that select statement as it is going for time out.

any suggesstions?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
75

Hello,

My first go at breaking this down would be.

Your main selection is on LIKP, LIPS and VBUP all joined on VBELN and POSNR. The other tables are secondary. Do your main selection and then as you go through each record you check or retrieve information against the other tables. The other tables can be set up as internal sorted tables to speed up access.

data:

ls_ekko type ekko,

lt_ekko type sorted table of ekko with header line with unique key ebeln,

ls_kna type kna,

lt_kna1 type sorted table of kna1 with header line with unique key kunnr.

select ebeln

into corresponding fields of lt_ekko

from ekko

where ebeln in i_ebeln.

select kunnr name1

into corresponding fields of table lt_kna1

from kna1

where land1 in s_land1.

SELECT likp~vbeln

lips~posnr

likp~kunnr

lips~lfimg

lips~uecha

lips~matnr

lips~lgort

lips~charg

lips~vgbel

lips~arktx

lips~werks

likp~wadat_ist

FROM likp

INNER JOIN lips ON lipsvbeln = likpvbeln

INNER JOIN vbup ON vbupvbeln = lipsvbeln

AND vbupposnr = lipsposnr

APPENDING corresponding fields of table itab

FOR ALL ENTRIES IN i

WHERE likp~vbeln = i-vbeln

AND likp~wadat_ist IN s_wadat

AND ( likplfart = 'NL' OR likplfart = 'NLCC')

AND vbup~wbsta IN r_wbsta.

  • now loop through extracted records checking against lt_ekko and lt_kna1.

loop at itab assigning <itab>.

  • check against EKKO

read table lt_ekko where ebeln = <item>-vgbel.

check sy-subrc = 0.

read table lt_kna1 into ls_kna1 where kunnr = <itab>-kunnr.

check sy-subrc = 0.

clear ls_itab2.

move corresponding <itab> to ls_itab2.

ls_itab2-name1 = ls_kna1-name1.

append ls_itab2 to lt_itab2.

endloop.

There may be errors in the above code as I did write it off the top of my head without any testing but it should give you the picture.

John.

1 REPLY 1

Former Member
0 Kudos
76

Hello,

My first go at breaking this down would be.

Your main selection is on LIKP, LIPS and VBUP all joined on VBELN and POSNR. The other tables are secondary. Do your main selection and then as you go through each record you check or retrieve information against the other tables. The other tables can be set up as internal sorted tables to speed up access.

data:

ls_ekko type ekko,

lt_ekko type sorted table of ekko with header line with unique key ebeln,

ls_kna type kna,

lt_kna1 type sorted table of kna1 with header line with unique key kunnr.

select ebeln

into corresponding fields of lt_ekko

from ekko

where ebeln in i_ebeln.

select kunnr name1

into corresponding fields of table lt_kna1

from kna1

where land1 in s_land1.

SELECT likp~vbeln

lips~posnr

likp~kunnr

lips~lfimg

lips~uecha

lips~matnr

lips~lgort

lips~charg

lips~vgbel

lips~arktx

lips~werks

likp~wadat_ist

FROM likp

INNER JOIN lips ON lipsvbeln = likpvbeln

INNER JOIN vbup ON vbupvbeln = lipsvbeln

AND vbupposnr = lipsposnr

APPENDING corresponding fields of table itab

FOR ALL ENTRIES IN i

WHERE likp~vbeln = i-vbeln

AND likp~wadat_ist IN s_wadat

AND ( likplfart = 'NL' OR likplfart = 'NLCC')

AND vbup~wbsta IN r_wbsta.

  • now loop through extracted records checking against lt_ekko and lt_kna1.

loop at itab assigning <itab>.

  • check against EKKO

read table lt_ekko where ebeln = <item>-vgbel.

check sy-subrc = 0.

read table lt_kna1 into ls_kna1 where kunnr = <itab>-kunnr.

check sy-subrc = 0.

clear ls_itab2.

move corresponding <itab> to ls_itab2.

ls_itab2-name1 = ls_kna1-name1.

append ls_itab2 to lt_itab2.

endloop.

There may be errors in the above code as I did write it off the top of my head without any testing but it should give you the picture.

John.