‎2006 Sep 13 3:18 PM
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.
‎2006 Sep 13 3:24 PM
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
‎2006 Sep 13 3:23 PM
Collect your customer numbers from it_vbpa and it_knvp into a third internal table and select from KNA1 based on this table.
‎2006 Sep 13 3:24 PM
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
‎2006 Sep 13 3:27 PM
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.
‎2006 Sep 13 3:27 PM
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 .
‎2006 Sep 13 3:28 PM
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
‎2006 Sep 13 3:28 PM
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
‎2006 Sep 13 3:29 PM
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
‎2006 Sep 13 3:32 PM
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
‎2006 Sep 13 3:39 PM
‎2006 Sep 13 3:45 PM
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