‎2007 Sep 27 3:39 AM
Hi,
I am having some problem with my inner join, trying to link two tables MSEG and MKPF.
The problem is that I don't know what to link the Tables with,
please help me.
DATA:
t_Sloc TYPE MSEG-LGORT,
t_MvT TYPE MSEG-BWART,
t_MatD TYPE MKPF-MBLNR,
t_Item TYPE MSEG-ZEILE,
t_Post TYPE MKPF-BUDAT,
t_Q TYPE MSEG-MENGE,
t_Bun TYPE MSEG-MEINS,
TotalQ TYPE i.
START-OF-SELECTION.
SELECT MSEGLGORT MSEGBWART MSEGZEILE MSEGMENGE MSEG~MEINS
FROM MSEG
INNER JOIN MKPF ON MSEGBWART = MKPFBUDAT
INTO (t_Sloc, t_MvT, t_Item, t_Q, t_Bun)
WHERE MSEG~MATNR = INPUT.
‎2007 Sep 27 3:52 AM
Hi John,
See this below:
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 s~matnr in s_matnr
and s~werks in s_werks_full
and ( sbwart eq lit_101 or sbwart eq lit_102 )
and k~budat between s_budat-low and s_budat-high
and s~bukrs = p_bukrs.
or u can also use view WB2_V_MKPF_MSEG2 .
Sri
‎2007 Sep 27 3:52 AM
Hi John,
See this below:
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 s~matnr in s_matnr
and s~werks in s_werks_full
and ( sbwart eq lit_101 or sbwart eq lit_102 )
and k~budat between s_budat-low and s_budat-high
and s~bukrs = p_bukrs.
or u can also use view WB2_V_MKPF_MSEG2 .
Sri
‎2007 Sep 27 4:42 AM
Thank you so much I can now join MSEG and MKPF you made my day/night
But Sri,
what does this do in you answer:
and s~werks in s_werks_full
and ( sbwart eq lit_101 or sbwart eq lit_102 )
and k~budat between s_budat-low and s_budat-high
and s~bukrs = p_bukrs.
‎2007 Sep 27 4:32 AM
hi
good
you can use tha MBLNR as the key field to join both the table,bcz this is the key field which i present in both the table.
thanks
mrutyun^
‎2007 Sep 27 6:47 AM
hi john,
It is better change ur code as following .. it works
TYPES: BEGIN OF ty_itab,
lgort TYPE lgort_d,
bwart TYPE bwart,
mblnr TYPE mblnr,
zeile TYPE mblpo,
budat TYPE budat,
menge TYPE menge_d,
meins TYPE meins,
totalq TYPE i,
END OF ty_itab.
DATA: wa_itab TYPE ty_itab,
it_itab TYPE STANDARD TABLE OF ty_itab.
START-OF-SELECTION.
SELECT mseglgort msegbwart msegzeile msegmenge mseg~meins
FROM mseg
INNER JOIN mkpf ON msegbwart = mkpfbudat
INTO CORRESPONDING FIELDS OF TABLE IT_ITAB.
WHERE mseg~matnr = input.
rewards if useful
regards
sree