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

Former Member
0 Likes
1,017

Hi all,

I need to inner join two tables A B on material number.

Table A has three fields:

MaterialNum Description Type

1 A I

2 B I

3 C I

Table B has two fields:

MaterialNum UOM

1 EA

1 PA

The result I want is

MaterialNum Description UOM

1 A EA

1 A PA

The code I wrote is:

DATA: BEGIN OF I_ITABOCCURS 0,

MANUM TYPE ***,

DESC TYPE ***,

UOM TYPE ***,

END OF ITEM_DITAB.

SELECT aMANUM aDESC b~UOM

INTO CORRESPONDING FIELDS OF TABLE I_ITAB

FROM B AS b

INNER JOIN A AS a

ON aMANUM = bMANUM

WHERE a~TYPE = 'I'

The result I got was only one line:

1 A EA

Can you give me some advise? Thanks!

Linda

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
991

Hi,

Even if you do

SELECT * FROM TABLE B

INTO CORRESPONDING FIELDS OF TABLE I_ITAB.

You are getting only one record....

I am not sure why???

Check if you doing SE16 and program execution in the same client..

Meaning..You might be running the program in development client and doing the SE16 in testing client..

Thanks,

Naren

11 REPLIES 11
Read only

Former Member
0 Likes
991

User left inner join and try.

Thanks,

Santosh

Read only

0 Likes
991

thanks for reply.

I tried left inner join, but I got sydex error.

I wrote this code in BW system. Would that be the problem? I do not think so, but...

Read only

Former Member
0 Likes
991

Hi,

Did you check if the table B has both the records..The sql seems to look fine..

Thanks,

Naren

Read only

0 Likes
991

I check the table from SE16. I can see those records.

I just tried the code

select * from B

into corresponding fields of table I_ITAB.

I only got one record back too.

Then why I can see those records from SE16?

Read only

Former Member
0 Likes
992

Hi,

Even if you do

SELECT * FROM TABLE B

INTO CORRESPONDING FIELDS OF TABLE I_ITAB.

You are getting only one record....

I am not sure why???

Check if you doing SE16 and program execution in the same client..

Meaning..You might be running the program in development client and doing the SE16 in testing client..

Thanks,

Naren

Read only

0 Likes
991

I am very sure I am doing those two things on the same client. Any idea?

Read only

0 Likes
991

Why dont you try without WHERE clause and check?

Read only

0 Likes
991

My mistake,

I got two records back when I use Select * from B.....

Read only

0 Likes
991

HI,

Can you try this, removing the corresponding fields of...

SELECT aMANUM aDESC b~UOM

INTO TABLE I_ITAB

FROM B AS b

INNER JOIN A AS a

ON aMANUM = bMANUM

WHERE a~TYPE = 'I'.

Thanks,

-Venkat.

Read only

Former Member
0 Likes
991

Hi,

Check this example ...

PARAMETERS: P_MATNR TYPE MATNR.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

MAKTX TYPE MAKTX,

END OF ITAB.

SELECT BMATNR BMAKTX

INTO TABLE ITAB

FROM MARA AS A INNER JOIN MAKT AS B

ON AMATNR = BMATNR

WHERE A~MATNR = P_MATNR.

WRITE: / SY-DBCNT.

Thanks,

Naren

Read only

0 Likes
991

THANKS A LOT.

it is the problem in where clause.

Linda