Skip to Content
0
Former Member
Dec 24, 2007 at 01:45 PM

Regarding select statement

16 Views

Hi,

I have two tables LFA1 and EKKO,

from LFA1 I fetch LIFNR and NAME1

from EKKO I have to fetch EBELN basing on lfa1-lifnr,

here for one lifnr I have 4 EBELN.

MY C0DE

types: begin of t_lifnr,

lifnr type lfa1-lifnr,

name1 type lfa1-name1,

end of t_lifnr,

begin of t_ekko,

lifnr type ekko-lifne,

ebeln type ekko-ebeln,

end of t_ekko,

begin of t_final,

lifnr type lfa1-lifnr,

name1 type lfa1-name1,

ebeln type ekko-ebeln,

end of t_final.

data: itab type standard table of t_lfa1,

w_itab type t_lfa1,

jtab type standard table of t_ekko,

w_jtab type t_ekko,

i_final type standard table of t_final,

w_final type t_final

select lifnr name1 into table itab from lfa1.

if not itab is initial.

select lifnr ebeln into table jtab

for all entries in itab

where lifnr = itab-lifnr.

loop at itab into w_itab.

w_final-lifnr = w_itab-lifnr.

w_final-name1 = w_itab-name1.

read table jtab into w_jatb with key lifnr = w_itab-lifnr.

w_final-ebeln = w_jtab-ebeln.

enloop.

loop at i_final into w_final.

write:/ w_final-lifnr,w_final-name1,w_final-ebeln.

enloop.

here for lifnr = 1

I have 4 ebeln but after display of write statement I can see only one ebeln for lifnr = 1, but actually it has to be 4

so how can I overcome this problem.

my output should be like this

lifnr name1 ebeln

1 abc 101

102

103

104

but I see it as

lifnr name1 ebeln

1 abc 101

Edited by: shilpa shilpa on Dec 24, 2007 2:45 PM

Edited by: shilpa shilpa on Dec 24, 2007 2:48 PM