01-03-2014 12:13 PM
Hi All ;
I want to ask about select statements.I have a table (LT_ITEMS) .
My main table is EBAN and key fields (Banfn-Bnfpo).
Ex. Banfn : 10000212 . In the eban table there are 13 lines,but when I
select fields from Ekpo with the eban-banfn ; I couldnt get some lines.
For ex. In the Eban table there are 13 lines banfn ,but ekpo table there are 14 lines
banfn.How can I select 14 lines banfn in the main loop ? How can I append ?
Codes like below :
select
eban~werks
eban~banfn
eban~bnfpo
eban~bsart
eban~knttp
eban~statu
eban~frgkz
eban~banpr
eban~ekgrp
eban~badat
eban~lfdat
eban~bednr
eban~menge
eban~afnam
eban~loekz
eban~txz01
eban~bsmng
eban~meins
eban~frgzu
eban~repos
eban~wepos
mara~mtart
mara~matkl
mara~matnr
from EBAN
inner join mara on eban~matnr eq mara~matnr
into corresponding fields of table LT_ITEMS
where eban~banfn in s_banfn and
mara~matnr in s_matnr and
mara~mtart in s_mtart and ""Our exp. 10000212
mara~matkl in s_matkl and
eban~bsart in s_bsart and
eban~statu in s_statu and
eban~frgkz in s_frgkz and
eban~banpr in s_banpr and
eban~ekgrp in s_ekgrp and
eban~badat in s_badat and
eban~lfdat in s_lfdat and
eban~bednr in s_bednr and
eban~afnam in s_afnam .
LOOP AT LT_ITEMS.
SELECT SINGLE NETPR PEINH ELIKZ EBELN EBELP FROM EKPO
INTO (LT_ITEMS-NETPR, LT_ITEMS-PEINH, LT_ITEMS-ELIKZ, LT_ITEMS-ebeln, LT_ITEMS-ebelp)
WHERE banfn eq LT_ITEMS-banfn and
bnfpo eq LT_ITEMS-bnfpo .
ENDLOOP.
Thanks for your answers.
Fırtına.
01-03-2014 12:19 PM
01-03-2014 12:19 PM
Hi,
Avoid the select inside the loop. Instead that you can use for all entries in LT_ITEMS.
SELECT banfn bnfpo NETPR PEINH ELIKZ EBELN EBELP FROM EKPO
INTO table it_ekpo for all entries in LT_ITEMS
WHERE banfn eq LT_ITEMS-banfn and
bnfpo eq LT_ITEMS-bnfpo .
Regards,
Fasi
01-03-2014 12:19 PM
01-03-2014 12:46 PM
01-03-2014 12:19 PM
Hi Yiğit,
First of all in the loop you do not modify your table so you wont get what you take from ekpo. And Second for performance do not use loop you can use "for all entries in".
01-03-2014 12:29 PM
01-03-2014 1:11 PM
Hi Yigit,
Please provide some extra field in where condition like matkl.
LOOP AT LT_ITEMS.
SELECT SINGLE NETPR PEINH ELIKZ EBELN EBELP FROM EKPO
INTO (LT_ITEMS-NETPR, LT_ITEMS-PEINH, LT_ITEMS-ELIKZ, LT_ITEMS-ebeln, LT_ITEMS-ebelp)
WHERE banfn eq LT_ITEMS-banfn and
bnfpo eq LT_ITEMS-bnfpo and matkl eq lt_items-matkl .
ENDLOOP.
let me know if again facing same problem.
Regards,
Thangam.P