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

inner join problem

Former Member
0 Likes
1,446

hi everyone

1) I have to make a INNERJOIN on "MKPF AND MSEG" table to select the fields from both tables into one "INTERNAL TABLE" but there is no relationship exist between these two tables

plz help how i can do it

Thanks

with regards

surity for points

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,329

Hi,

Select amblnr amjahr bzeile bbwart bebeln bebelp b~erfmg

into table ITAB

from mkpf as a join MSEG as b on

amblnr = bmblnr and

amjahr = bmjahr

where a~mjahr = p_year

b~ebeln in S_ebeln..

reward points if useful

regards,

Anji

12 REPLIES 12
Read only

Former Member
0 Likes
1,329

hi gaurav,

if there is no relation then it is not possible to use inner joins.There should be some relation in between the two tables.

Regards...

Arun.

Read only

Former Member
0 Likes
1,329

Hi,

material Document no and year are the link between these tables. MBLNR and MJAHR.

Regards,

Read only

Former Member
0 Likes
1,330

Hi,

Select amblnr amjahr bzeile bbwart bebeln bebelp b~erfmg

into table ITAB

from mkpf as a join MSEG as b on

amblnr = bmblnr and

amjahr = bmjahr

where a~mjahr = p_year

b~ebeln in S_ebeln..

reward points if useful

regards,

Anji

Read only

Former Member
0 Likes
1,329

Hi,

In both tables MBLNR was common field.U can use this field in inner join to get relationship between these two tables.

pls give reward if it helpful

Thanks

vana

Read only

Former Member
0 Likes
1,329

Hi,

MKPF is the header table for material documents, whereas MSEG is the item table for material documents. You can very well join these two tables.

Please check the key fields in the MKPF table, MBLNR and MJAHR.

These two fields are also the key fields in MSEG table apart from the third field ZEILE(Item number).

Therefore, you can make a join based on the key fields of the MKPF table.

Thank you.

reward all useful answers.

Read only

former_member632991
Active Contributor
0 Likes
1,329

Hi,

there is relation between these 2 tables

select based on the material doc no i.e. MBLNR

select aa1 bb1 from mseg as a inner join mkpf as b

on amblnr = bmblnr.

Regards,

Sonika

Read only

Former Member
0 Likes
1,329

Hi gaurav,

There are field like MBLNR, MJAHR which are common in both the tables.

Even if some of the field names are not same, if there data element or domain is same u can put inner join condition.

Thanks

Sandeep

Award point if benefited

Read only

0 Likes
1,329

only mblnr field is sufficient for the innerjoin

Read only

Former Member
0 Likes
1,329

gaurav,

Query:

select smblnr smjahr sbwart smatnr swerks smenge

appending corresponding fields of table t_mseg

from mseg as s inner join mkpf as k

on smblnr = kmblnr and

smjahr = kmjahr

where

conditions....

PLs. reward if useful..

Read only

Former Member
0 Likes
1,329

use select query like this

select mkpf----


mseg----


into table itab from mkpf inner join mseg on mkpfmblnr = msegmblnr where -


Read only

0 Likes
1,329

thanks to everybody for your help but i got struck in another problem related to "where condition"

1) i have to select mblnr , mjahr and budat from MKPF into itab (internal table) for user input in the selection screen

+++(Inner join)

select zeile,bwart,matnr,werks,lgort,charg,sobkz,erfmg,erfme,kzbew,kzvbr,kzzug,shkzg from MSEG into itab(internal table) for user input in the selection screen

2) now i got confused in "For user input in the selection screen " because at selection screen i have only following fields

matnr , werks , lgort,charg,lifnr,kunnr,bwart,sobkz,usnam,vgart.

and i am using a query like this

select a-mblnr

a-mjahr

a-budat

b-zeile

b-bwart

b-matnr

b-werks

b-lgort

b-charg

b-sobkz

b-erfmg

b-erfme

b-kzbew

b-kzvbr

b-kzzug

b-shkzg into table t_mat_data from mkpf

as a join mseg as b on a-mblnr = b-mblnr

and a-mjahr = b-mjahr

where .....................

so wat should i written in Where condition plz reply

thanks

points will be awarded

Read only

0 Likes
1,329

Hi,

In the where condition

write

where a~matnr in s_matnr(if it is selection screen option)

and in the same way other fileds from select options

Go through the SAP help on select query fot better understanding

Regards,

Sonika