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

Concatenate two select query

Former Member
0 Likes
1,026

Hi ABAPers,

Can you please tell me how to concatenate this two select qureies.



select  ebeln knumv from ekko  INTO
TABLE  tt_knumv
where ebeln = p_ebeln.

select ebeln knumv from eslh INTO TABLE
tt_knumv  FOR ALL ENTRIES IN tt_esll
where  packno = tt_esll-sub_packno.

Regards

Abhinab Mishra

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
932

HI

Use the inner join for the two select statment based on the fied knumv.

8 REPLIES 8
Read only

Former Member
0 Likes
932

Hi,

Use this.

CONCATENATE ITAB1-FIELD1 ITAB2-FIELD2 INTO <REQUIRED FIELD>

Regards,

Shamma

Read only

0 Likes
932

Brother this is a select qurey. I am not talking about concatenating two fields.

Read only

Former Member
0 Likes
933

HI

Use the inner join for the two select statment based on the fied knumv.

Read only

Former Member
0 Likes
932

Hi,

I dont think inner join is possible in this case since you are selecting the same fields from the two different tables into the single internal table vertically. It can be used to collect the data into the internal table horizontally but that would make no sense in this case. May be you can try something like this



data: t_temp type table of tt_knumv.

select ebeln knumv 
from eslh 
INTO TABLE tt_knumv 
 FOR ALL ENTRIES IN tt_esll
where  packno = tt_esll-sub_packno.

select  ebeln knumv 
from ekko 
 INTO TABLE  t_temp
where ebeln = p_ebeln.

loop at t_temp.
move-corresponding t_temp to tt_knumv.
append tt_knumv.
endloop.

Regards,

Vik

Read only

Former Member
0 Likes
932

Hi,

You can use Inner join instead using two select queries on the common field.

That is:



Select all fields(from the two tables) into internal table
from table 1 as a inner join table 2 as b on
a~common field name = b~common field name.

Hope it helps

Regards

Mansi

Read only

Former Member
0 Likes
932

Hello,

Unless I misunderstand your question, why not simply use APPENDING TABLE:

>


> 
> select  ebeln knumv from ekko  INTO
> TABLE  tt_knumv
> where ebeln = p_ebeln.
> 
> select ebeln knumv from eslh APPENDING TABLE
> tt_knumv  FOR ALL ENTRIES IN tt_esll
> where  packno = tt_esll-sub_packno.
> 
> 

Regards,

Mark

Read only

Former Member
0 Likes
932

Hello,

Try this way:

select aebeln aknumv from ekko as a join eslh as b on aebeln = bebeln and aknumv = bknumv

INTO TABLE tt_knumv

where a~ebeln = p_ebeln

and b~packno = tt_esll-sub_packno .

You may fine tune it more for your use.

Check if this can help!

Thanks,

Augustin.

Read only

Former Member
0 Likes
932

Thank you all for your replies.