Application Development and Automation 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: 
Read only

about error occured in program by using inner joins

former_member612655
Participant
1,612

Hello AbapExperts,

data : begin of wa_final,
bukrs type t001-bukrs,
butxt type t001-butxt,
lifnr type lfb1-lifnr,
end of wa_final.
data it_final like table of wa_final.
select t001~bukrs t001~butxt lfb1~lifnr into table it_final
from t001 inner join lfb1 on t001~bukrs = lfb1~bukrs.
sort it_final by bukrs.
loop at it_final into wa_final.
write : / wa_t00l-bukrs,
wa_t001-butxt,
wa_lfb1-lifnr,
endloop.

when i compile the above program i got error msg like " field "wa_t001-bukrs" is unknown.It is neither in one of specified tables nor defined by "data" statement". Can you please help me find out the error.

suggestions apreciated.

Thanks.

Hello AbapExperts,

data : begin of wa_final,
bukrs type t001-bukrs,
butxt type t001-butxt,
lifnr type lfb1-lifnr,
end of wa_final.
data it_final like table of wa_final.
select t001~bukrs t001~butxt lfb1~lifnr into table it_final
from t001 inner join lfb1 on t001~bukrs = lfb1~bukrs.
sort it_final by bukrs.
loop at it_final into wa_final.
write : / wa_t00l-bukrs,
wa_t001-butxt,
wa_lfb1-lifnr,
endloop.

when i compile the above program i got error msg like " field "wa_t001-bukrs" is unknown.It is neither in one of specified tables nor defined by "data" statement". Can you please help me find out the error.

suggestions apreciated.

Thanks.

4 REPLIES 4
Read only

former_member596005
Participant
1,302

HI Bhavani ,

loop at it_final into wa_final.
write : / wa_t00l-bukrs,wa_t001-butxt,wa_lfb1-lifnr.
endloop.

In the above code you are looping into one workarea and you are displaying some other workarea data which you didnt even declared.
Read only

1,302

I also see that there's a typo error: wa_t00l <> wa_t001 (l versus 1)

Read only

1,302

And a comma before the endloop.

Read only

matt
Active Contributor
1,302

In future, use the "code" button. It makes your code easier to read if it's formatted nicely.

data : 
  begin of wa_final,
    bukrs type t001-bukrs,
    butxt type t001-butxt,
    lifnr type lfb1-lifnr,
  end of wa_final.
data it_final like table of wa_final.

select t001~bukrs t001~butxt lfb1~lifnr into table it_final
    from t001
    inner join lfb1
            on t001~bukrs = lfb1~bukrs.

sort it_final by bukrs.
loop at it_final into wa_final.
  write : / wa_t00l-bukrs,wa_t001-butxt,wa_lfb1-lifnr.
endloop.

Now, why would you expect it to work, if you've not declared wa_t001?
Also, don't select from the database and then sort. Put ORDER BY in your select.