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: 

SELECT STATEMENTS

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

Try to use a LEFT OUTER JOIN on EKPO

Regards,

Raymond

6 REPLIES 6

Former Member
0 Kudos

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

raymond_giuseppi
Active Contributor
0 Kudos

Try to use a LEFT OUTER JOIN on EKPO

Regards,

Raymond

0 Kudos

Thanks Raymond ,

Regards.

asim_isik
Active Participant
0 Kudos

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".

former_member187748
Active Contributor
0 Kudos

This message was moderated.

thangam_perumal
Contributor
0 Kudos

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