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

join

Former Member
0 Likes
1,171

Hi all,

how to combine the following two select queries using joins.

  • fetch data from a304 table

  • SELECT kschl vkorg vtweg matnr datbi datab knumh

  • FROM a304

  • INTO TABLE t_a304

  • WHERE kschl = p_kschl

  • AND vkorg = p_vkorg

  • AND vtweg = p_vtweg

  • AND datbi IN s_datbi

  • AND datab IN s_datab.

    • fetch data from KONP table

  • IF NOT t_a304[] IS INITIAL.

  • SELECT knumh kopos kschl konwa kpein kmein

  • FROM konp

  • INTO TABLE t_konp

  • FOR ALL ENTRIES IN t_a304

  • WHERE knumh = t_a304-knumh

  • AND kschl = t_a304-kschl.

  • ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,104

hi



SELECT a~kschl a~vkorg a~vtweg a~matnr a~datbi a~datab a~knumh
             b~knumh b~kopos b~kschl b~konwa b~kpein b~kmein
INTO TABLE t_a304
FROM a304 as a
inner join konp as b
on a~knumh = b~knumh
AND a~kschl = b~kschl.
 WHERE a~kschl = p_kschl
 AND a~vkorg = p_vkorg
 AND a~vtweg = p_vtweg
 AND a~datbi IN s_datbi
 AND a~datab IN s_datab.

pavan

*pls mark for helpful answers

9 REPLIES 9
Read only

Former Member
0 Likes
1,104

u cannt join these 2 tables.

i think KONP is a cluster table.

Regards

Prabhu

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,104
SELECT a~kschl a~vkorg a~vtweg a~matnr a~datbi a~datab a~knumh
        b~knumh b~kopos b~kschl b~konwa b~kpein b~kmein
  FROM a304 as a 
  JOIN konp as b
    ON b~knumh = a~knumh
    AND  b~kschl = a~kschl.
  INTO TABLE <new table>
   WHERE a~kschl = p_kschl
     AND a~vkorg = p_vkorg
     AND a~vtweg = p_vtweg
     AND a~datbi IN s_datbi
     AND a~datab IN s_datab.
Read only

0 Likes
1,104

I'm very new to ABAP dev so sorry if this a lame question. I am trying to use the A304 as suggested above however not all of my materials are in this table. How can this be? Is there some other way I should be getting the info record number so I can look up pricing?

Thanks in advance

Read only

Former Member
0 Likes
1,105

hi



SELECT a~kschl a~vkorg a~vtweg a~matnr a~datbi a~datab a~knumh
             b~knumh b~kopos b~kschl b~konwa b~kpein b~kmein
INTO TABLE t_a304
FROM a304 as a
inner join konp as b
on a~knumh = b~knumh
AND a~kschl = b~kschl.
 WHERE a~kschl = p_kschl
 AND a~vkorg = p_vkorg
 AND a~vtweg = p_vtweg
 AND a~datbi IN s_datbi
 AND a~datab IN s_datab.

pavan

*pls mark for helpful answers

Read only

Former Member
0 Likes
1,104

Hi Shweta

Try this

Select aknumh akschl avkorg avtweg amatnr adatbi adatab bkopos

bkonwa bkpein b~kmein from A304 as a inner join konp as b on

aKNUMH = bKNUMH into internal table

where WHERE kschl = p_kschl

AND vkorg = p_vkorg

AND vtweg = p_vtweg

AND datbi IN s_datbi

AND datab IN s_datab.

Regards

Davinder Singh

Read only

Former Member
0 Likes
1,104

Hi,

Yes you can join them.

Only thing is that you can't join KONV, since it is a cluster table:

SELECT akschl avkorg avtweg amatnr adatbi adatab aknumh bknumh bkopos bkschl bkonwa bkpein b~kmein

INTO TABLE t_a304

FROM a304 as a

inner join konp as b

on aknumh = bknumh

and akappl = bkappl

and akschl = bkschl

WHERE a~kschl = p_kschl

AND a~vkorg = p_vkorg

AND a~vtweg = p_vtweg

AND a~datbi IN s_datbi

AND a~datab IN s_datab.

reward if useful

regards,

ANJI

Message was edited by:

Anji Reddy Vangala

Read only

Former Member
0 Likes
1,104

Hi,

SELECT akschl avkorg avtweg amatnr adatbi adatab aknumh bkopos bkonwa bkpein bkmein FROM a304 as a inner join konp as b INTO( t_a304-kschl,t_a304-vkorg,t_a304-vtweg,t_a304-matnr,t_a304-datbi,t_a304-datab,t_a304-knumh,t_konp-kopos,t_konp-konwa,t_konp-kpein,t_konp-kmein ) WHERE akschl = p_kschl AND avkorg = p_vkorg AND avtweg = p_vtweg AND adatbi IN s_datbi AND adatab IN s_datab.

regards,

bharat.

Read only

Former Member
0 Likes
1,104

hi

use the following query.

SELECT kschl vkorg vtweg matnr datbi datab knumh kopos konwa kpein kmein

into corresponding fields of table itab

from a304 inner join konp on konpkschl = a304kschl

and konpknumh = a304knumh

where konp~kschl = p_kschl

AND vkorg = p_vkorg

AND vtweg = p_vtweg

AND datbi IN s_datbi

AND datab IN s_datab.

hope it will work

regards

ravish

<b>plz reward if helpful</b>

Read only

Former Member
0 Likes
1,104

Hi,

First change the structure of the internal table t_a304 to include all the fields in the select clause.

then try out the following code:

select akschl avkorg avtweg amatnr adatbi adatab a~knumh

bkopos bkonwa bkpein bkmein

into table t_a304

from a304 as a inner join konp as b

on aknumh = bknumh

and akschl = bkschl

where kschl = p_kschl

and vkorg = p_vkorg

and vtweg = p_vtweg

and datbi in s_datbi

and datab in s_datab.