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

Former Member
0 Likes
1,442

Hello friends,

I have to select data into an itab based on conditions from 2 different itab.

this piece of code wirks fine but i am kind of thinking it wouls take time so is there any simplier process.

SELECT kunnr

name1

regio

INTO TABLE it_kna1

FROM kna1

FOR ALL ENTRIES IN it_vbpa

WHERE kunnr EQ it_vbpa-kunnr.

SELECT kunnr

name1

regio

INTO it_kna1

FROM kna1

FOR ALL ENTRIES IN it_knvp

WHERE kunnr EQ it_knvp-kunnr.

APPEND it_kna1.

ENDSELECT.

Any advice,

Shejal Shetty.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,403

Hi Shejal,

Do this way:

instead of second internal table,

SELECT kunnr

name1

regio

INTO TABLE it_kna1

FROM kna1

FOR ALL ENTRIES IN it_vbpa

WHERE kunnr EQ it_vbpa-kunnr.

SELECT kunnr

name1

regio

<b>INTO table itab_kna1.</b> "declare itab_kna1 as same as it_kna1

FROM kna1

FOR ALL ENTRIES IN it_knvp

WHERE kunnr EQ it_knvp-kunnr.

<b>loop at itab_kna1.

move-corresponding itab_kna1 to it_kna1.

append it_kna1.

endloop.</b>

Regards,

Vivek

10 REPLIES 10
Read only

Former Member
0 Likes
1,403

Collect your customer numbers from it_vbpa and it_knvp into a third internal table and select from KNA1 based on this table.

Read only

Former Member
0 Likes
1,404

Hi Shejal,

Do this way:

instead of second internal table,

SELECT kunnr

name1

regio

INTO TABLE it_kna1

FROM kna1

FOR ALL ENTRIES IN it_vbpa

WHERE kunnr EQ it_vbpa-kunnr.

SELECT kunnr

name1

regio

<b>INTO table itab_kna1.</b> "declare itab_kna1 as same as it_kna1

FROM kna1

FOR ALL ENTRIES IN it_knvp

WHERE kunnr EQ it_knvp-kunnr.

<b>loop at itab_kna1.

move-corresponding itab_kna1 to it_kna1.

append it_kna1.

endloop.</b>

Regards,

Vivek

Read only

Former Member
0 Likes
1,403

hi,

Insert this code before second select. This filters the existing kunnr from it_knvp.


 loop at it_kna1.
   read table it_knvp with key kunnr = it_kna1-kunnr  binary search.
  if sy-usbrc = 0.
      delete it_knvp where kunnr = it_kna1-kunnr.
  endif.
 endloop.

Regards,

Sailaja.

Read only

Former Member
0 Likes
1,403

run the program from se30 and see if the log will notice

about select problem ,

finger rule , in the "net" columne number have to be

under 10 precent above it , its problem.

also you can check total time for running ,

and do test by changing the select .

and not advice one , is add index ,

just in case of no other choice .

2) active st05 and check the log .

replace the append with

appending corresponding fields to table ....

goodlack .

Read only

0 Likes
1,403

Hi Shejal,

U cud combine the KUNNR of IT_KNA1 and IT_KNVP into another internal table and Select frm KNA1 using that itab. That way, u have to fire only one Select query.

Regards,

Johnson

Read only

Former Member
0 Likes
1,403

hi,

Avoid using select .. endselect...

SELECT kunnr
name1
regio
<b>INTO table it_kna11</b>
FROM kna1
FOR ALL ENTRIES IN it_knvp
WHERE kunnr EQ it_knvp-kunnr.

Regards,

Santosh

Read only

Former Member
0 Likes
1,403

Hi Shetty,

Hey first thing first dont go for

SELECT......ENDSELECT.

statement.it will take more time.

better use the first one

SELECT kunnr

name1

regio

INTO TABLE it_kna1

FROM kna1

FOR ALL ENTRIES IN it_vbpa

WHERE kunnr EQ it_vbpa-kunnr.

Thanks

Vikranth Khimavath

Read only

Former Member
0 Likes
1,403

Hi Shejal,

try using only one select from KNA1 table.

You are reading the same data for different set of kunnr.

Try to get all the kunnr in one table and then do a single select to KNA1 table.

Cheers

VJ

Read only

0 Likes
1,403

Thanks everyone.

Shejal Shetty.

Read only

Former Member
0 Likes
1,403

HI

One way to handle you case is using <b>"APPENDING TABLE"</b>.

EG:

  SELECT kunnr name1 regio
      INTO TABLE it_kna1
      FROM kna1
      FOR ALL ENTRIES IN it_vbpa
      WHERE kunnr EQ it_vbpa-kunnr.

  SELECT kunnr name1 regio
      APPENDING CORRESPONDING FIELDS OF TABLE IT_KNA1
      FROM kna1
      FOR ALL ENTRIES IN it_knvp
      WHERE kunnr EQ it_knvp-kunnr.

I sincerely advice you to extract data from KNA1

irrespective of entries in IT_VBPA and IT_KNVP which

will be somewhat less and reduces the number of hits to

database.

Eg:

  SELECT kunnr name1 regio
      INTO TABLE it_kna1
      FROM kna1.

One shot you will have more than required data and

continous hits to database will be avoided.

Kind Regards

Eswar