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 joins

Former Member
0 Likes
1,017

hi

i am looping at mchb and i need to join on the following conditions

i. Read table MKPF and retrieve MAX (MKPF-CPUDT) inner join MSEG based on MSEG-WERKS = MCHB-WERKS and MSEG-LGORT = MCHB-LGORT and MSEG-MATNR = MCHB-MATNR and MSEG-CHARG = MCHB-CHARG

ii. Read table MKPF and retrieve MKPF-BDATU MAX (MKPF-CPUTM) inner join MSEG WHERE MSEG-WERKS = MCHB-WERKS, and MSEG-LGORT = MCHB-LGORT and MSEG-MATNR = MCHB-MATNR and MSEG-CHARG = MCHB-CHARG and MKPF-CPUDT = above retrieved date

DETERMINE latest material doc for movement type (MSEG-BWART) 531 using above logic to get latest doc and get MSEG-AUFNR DETERMINE protein contact (AFKO-PLNBEZ) using MSEG-AUFNR

can any one help me out. its very urgent

raju

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
929

SELECT MAX(MKPF-CPUDT) MAX(MKPF-CPUTM) into (ldate, ltime)

from mkpf inner join mseg on

mkpfmblnr = msegmblnr and mkpfmjahr = msegmjahr

where msegwerks = mchbwerks and

mseglgort = mchblgort and

msegmatnr = mchbmatnr and

msegcharg = mchbcharg.

hi

i am looping at mchb and i need to join on the following conditions

i. Read table MKPF and retrieve MAX (MKPF-CPUDT) inner join MSEG based on MSEG-WERKS = MCHB-WERKS and MSEG-LGORT = MCHB-LGORT and MSEG-MATNR = MCHB-MATNR and MSEG-CHARG = MCHB-CHARG

ii. Read table MKPF and retrieve MKPF-BDATU MAX (MKPF-CPUTM) inner join MSEG WHERE MSEG-WERKS = MCHB-WERKS, and MSEG-LGORT = MCHB-LGORT and MSEG-MATNR = MCHB-MATNR and MSEG-CHARG = MCHB-CHARG and MKPF-CPUDT = above retrieved date

DETERMINE latest material doc for movement type (MSEG-BWART) 531 using above logic to get latest doc and get MSEG-AUFNR DETERMINE protein contact (AFKO-PLNBEZ) using MSEG-AUFNR

can any one help me out. its very urgent

raju

5 REPLIES 5
Read only

Former Member
0 Likes
929

Check the sample code:

data: begin of i_data occurs 0,

MBLNR type MKPF-MBLNR,

MJAHR type MKPF-MJAHR,

CPUDT type mkpf-cpudt,

ZEILE type MSEG-zeile,

end of i_data.

select amblnr amjahr acpudt bzeile

into table i_data

from mkpf as a inner join mseg as b

on aMBLNR = bMBLNR

<b> for all entries in i_mchb </b>

where b~WERKS = i_mchb-werks

and b~lgort = i_mchb-lgort

and b~matnr = i_mcbh-matnr

and b~charg = i_mcbh-charg.

Sort i_data by CPUDT Descending.

*U will get the latest record

*Follow the same step 2 select query also.

Regards,

Prakash.

Read only

Former Member
0 Likes
930

SELECT MAX(MKPF-CPUDT) MAX(MKPF-CPUTM) into (ldate, ltime)

from mkpf inner join mseg on

mkpfmblnr = msegmblnr and mkpfmjahr = msegmjahr

where msegwerks = mchbwerks and

mseglgort = mchblgort and

msegmatnr = mchbmatnr and

msegcharg = mchbcharg.

Read only

0 Likes
929

hi bankley,

thanks for ur answer but have seen it the second point should be based on above retrived data( from point 1).

look at it once again

Read only

0 Likes
929

Raju,

No need to give 2 sepaerate select queries u can do that in a single query as said by anurag.

Regards,

Prakash.

Read only

0 Likes
929

DETERMINE latest material doc for movement type (MSEG-BWART) 531 using above logic to get latest doc and get MSEG-AUFNR DETERMINE protein contact (AFKO-PLNBEZ) using MSEG-AUFNR

I am not 100% certain about your requirement whether you require all three information max-cpudt and time as well as docno for movement type 531 or it is just the docno for 531 movt type ??

select max(mblnr) into ldocno

from mblnr inner join mseg

on (same as above)

where mseg~bwart = '531'.

select afko~plnbez into lplnbez

from afko inner join mseg on

afkoaufnr = msegaufnr

where mseg~mblnr = ldocno.

Please award points to all helpful answers!!

Message was edited by: Anurag Bankley