Skip to Content
author's profile photo Former Member
Former Member

SELECT STATEMENTS

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Jan 03, 2014 at 12:19 PM

    Try to use a LEFT OUTER JOIN on EKPO

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 12:29 PM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 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".

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.