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
732

Hi all,

i need to do join between

mkpf and mseg instead of select,

any help will be appreciated.

dana.

my code is:

SELECT MBLNR BLDAT FROM MKPF

into CORRESPONDING FIELDS OF TABLE ITAB_mkpf

WHERE BLDAT >= date. "itab_ekko-bedat.

SELECT MBLNR MJAHR ZEILE BWART MATNR menge LGORT SHKZG EBELN

KOSTL FROM MSEG

into CORRESPONDING FIELDS OF TABLE ITAB_mseg

for all entries in itab_mkpf

WHERE MBLNR = itab_mkpf-mblnr

and ( ( bwart = '351' or bwart = '352'

and ebeln > ebeln )

or ( bwart = '201' or bwart = '202' ) )

and kostl = p_kostl

and lgort = itab_ekko-UNSEZ.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
696

my answer is:

SELECT a~MBLNR

a~BLDAT

b~MBLNR

b~MJAHR

b~ZEILE

b~BWART

b~MATNR

b~menge

b~LGORT

b~SHKZG

b~EBELN

b~KOSTL

FROM MKPF as a

inner join mseg as b

on amblnr = bmblnr

into CORRESPONDING FIELDS OF TABLE ITAB_mkpf_mseg

WHERE a~BLDAT >= date "itab_ekko-bedat.

and ( ( bbwart = '351' or bbwart = '352'

and bebeln > bebeln )

or ( bbwart = '201' or bbwart = '202' ) )

and b~kostl = p_kostl

and b~lgort = itab_ekko-UNSEZ.

Please let me know for anymmore queries

5 REPLIES 5
Read only

Former Member
0 Likes
697

my answer is:

SELECT a~MBLNR

a~BLDAT

b~MBLNR

b~MJAHR

b~ZEILE

b~BWART

b~MATNR

b~menge

b~LGORT

b~SHKZG

b~EBELN

b~KOSTL

FROM MKPF as a

inner join mseg as b

on amblnr = bmblnr

into CORRESPONDING FIELDS OF TABLE ITAB_mkpf_mseg

WHERE a~BLDAT >= date "itab_ekko-bedat.

and ( ( bbwart = '351' or bbwart = '352'

and bebeln > bebeln )

or ( bbwart = '201' or bbwart = '202' ) )

and b~kostl = p_kostl

and b~lgort = itab_ekko-UNSEZ.

Please let me know for anymmore queries

Read only

0 Likes
696

thank you very much,

you help me alot.

Read only

Former Member
0 Likes
696

SELECT MKMBLNR MKBLDAT MSMJAHR MSZEILE MSBWART MSMATNR MSmenge MSLGORT MSSHKZG MSEBELN MSKOSTL FROM MKPF AS MK INNER JOIN MSEG AS KS WHERE MKMBLNR = MS~MBLNR

and ( ( MSbwart = '351' or MSbwart = '352' )

or ( MSbwart = '201' or MSbwart = '202' ) )

and MS~kostl = p_kostl

and MS~lgort = itab_ekko-UNSEZ.

BTW, i did not under stand the condition:

and ebeln > ebeln in your second select statement.

~thomas

null

Read only

Former Member
0 Likes
696

Hi,

You can try ur code in the following way:

Select AMBLNR ABLDAT BMJAHR BZEILE BBWART BMATNR Bmenge BLGORT BSHKZG BEBELN BKOSTL FROM MKPF as A inner join MSEG as B on AMBLNR = B~MBLNR into table itab

where ( ( Bbwart = '351' or Bbwart = '352' )

and B~EBELN > ebeln )

or ( ( BBWART = '201' or BBWART = '202' )

and B~KOSTL = p_kostl )

and B~LGORT = itab_ekko-UNSEZ.

Reward useful answers...

Read only

Former Member
0 Likes
696

hi dana,

select mkpfblnr mkpfbldat msegMJAHR msegZEILE msegBWART msegMATNR msegmenge msegLGORT msegSHKZG msegEBELN

mseg~KOSTL into table itab from mkpf inner join mseg

on mkpfblnr = msegblnr

WHERE BLDAT >= date

MBLNR = itab_mkpf-mblnr

and ( ( bwart = '351' or bwart = '352'

and ebeln > ebeln )

or ( bwart = '201' or bwart = '202' ) )

and kostl = p_kostl

and lgort = itab_ekko-UNSEZ.

regards,

keerthi