Application Development 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: 

help needed in rewriting the code using inner joins

Former Member
0 Kudos

Hi all,

I need help in rewriting this code

DATA : FLD LIKE ZTABLE-ZFLD,

FLD1 LIKE ZTABLE2-ZFLD2.

select single ZFLD from zTABLE1 into FLD

where MATNR = '123' and

werks = 'ABC'.

select single ZFLD1 from zTABLE2 into FLD1

where zFLD = FLD.

iS there way that we can write this with inner joins

Thanks

6 REPLIES 6

Former Member
0 Kudos

ONLY if there is any common field in both the dtabase tables. like as below

SELECT aZFLB bZFLD1 from ZTABLE1 As a

INNER JOIN ZTABLE2 AS b ON aFIELDNAME EQ bFIELDNME.

otherwise he query u have written is correct.

hope this will help

Thanks

Ashwani

Former Member
0 Kudos

Hello,

Do like this


SELECT SINGLE A~ZFLD B~ZFLD1 INTO ( FLD,FLD1) from ZTABLE1 AS A 
INNER JOIN ZTABLE2 AS B on A~FLD EQ B~FLD
WHERE MATNR EQ 123
and         WERKS EQ ABC

If useful reward

0 Kudos

Hi,

help me out

TABLE 1 HAS

MATNR , WERKS , FLD1.

TABLE 2 HAS

FLD1, FLD2.

I KNOW MATNR AND WERKS BASED ON THAT I HAVE TO GET FLD2

I WANT IT BE WRITTEN WITH INNEWR JOINS

WITH FOLLOWING COD E I GET AN ERROR MESSAGE SAYING

comma without preccing colon (after select?)

data : FLD1 like zTABLE1-ZFLD1.

data : FLD2 like ZTABLE2-ZFLD2.

SELECT FZFLD1 BZFLD2

INTO ( FLD1, FLD2)

FROM ZTABLE1 AS F INNER JOIN ZTABLE2 AS B

ON FZFLD1 = BFLD2

WHERE F~MATNR = '123'

AND F~WERKS = 'ABC' .

Thanks

0 Kudos

use

SELECT FZFLD1 BZFLD2

INTO (FLD1, FLD2)

FROM ZTABLE1 AS F INNER JOIN ZTABLE2 AS B

ON FZFLD1 = BFLD2

WHERE F~MATNR = '123'

AND F~WERKS = 'ABC' .

~Suresh

0 Kudos

Hi Deepthi,

You need to give a comma after field by giving a space.

Try with this code.

SELECT FZFLD1 BZFLD2

INTO<b> ( FLD1 , FLD2 )</b>

FROM ZTABLE1 AS F INNER JOIN ZTABLE2 AS B

ON FZFLD1 = BFLD2

WHERE F~MATNR = '123'

AND F~WERKS = 'ABC' .

Thanks,

Vinay

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.

SELECT FZFLD1 BZFLD2

<b>INTO (FLD1, FLD2)</b>

FROM ZTABLE1 AS F INNER JOIN ZTABLE2 AS B

ON FZFLD1 = BFLD2

WHERE F~MATNR = '123'

AND F~WERKS = 'ABC' .

Regards,

Ferry Lianto