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: 

select no common fields.

Former Member
0 Kudos
158

Hello, my problem is that I don't know how retrieve the not common fields between two tables.

EG:

TABA

field1 field2 field3 field4

TABB

field1 field2 field4

I only want retrieve the field "field3", how can I do it?

Any adding with LEFT OUTER JOIN?

Thanks in advance.

1 ACCEPTED SOLUTION

anversha_s
Active Contributor
0 Kudos
115

hi,

chk this ample.

table : emp

empno name

a sasi

b xxx

c yyy

table : sal

empno salary

a 1000

b 2000

Inner join

****************

select eempno ename

s~sal

into table int_table

from emp as e

inner join sal

on

eempno = sempno.

if you made inner join between table a and b by emp no

the selection retrives only if the condition satisfy the output will be

a sasi 1000

b xxx 2000

Outer join

*************************

select eempno ename

s~sal into table int_table

from emp as e

LEFT OUTER JOIN sal

on

eempno = sempno.

if you made outer join (left /right ) the left table kept as it is the

if the condition satisfy the right table entries will fetch else leave it blank

the output will be

a sasi a 1000

b xxx b 2000

c yyy

rgds

Anver

7 REPLIES 7

anversha_s
Active Contributor
0 Kudos
116

hi,

chk this ample.

table : emp

empno name

a sasi

b xxx

c yyy

table : sal

empno salary

a 1000

b 2000

Inner join

****************

select eempno ename

s~sal

into table int_table

from emp as e

inner join sal

on

eempno = sempno.

if you made inner join between table a and b by emp no

the selection retrives only if the condition satisfy the output will be

a sasi 1000

b xxx 2000

Outer join

*************************

select eempno ename

s~sal into table int_table

from emp as e

LEFT OUTER JOIN sal

on

eempno = sempno.

if you made outer join (left /right ) the left table kept as it is the

if the condition satisfy the right table entries will fetch else leave it blank

the output will be

a sasi a 1000

b xxx b 2000

c yyy

rgds

Anver

Former Member
0 Kudos
115

select a~field3 into itab from taba inner join tabb where taba-field = tabb-field and (other key options).

Former Member
0 Kudos
115

Hi,

U may create another ITAB for the uncommon fields and try the following.

Loop at TABA into LW_TABA.

read table TABB with key LW_TABA -field1 = field1

LW_TABA -field2 = field2.

IF sy-subrc <> 0. "If not found then move

move TABA-field3 to ITABC-field3.

append ITABC.

ENDIF.

Endloop.

If helpful pl reward.

Cheers.

Former Member
0 Kudos
115

table : emp

empno name

a sasi

b xxx

c yyy

table : sal

empno salary

a 1000

b 2000

I don't want this output, I only want de different register.

a sasi a 1000

b xxx b 2000

c yyy

I want mean this:

c yyy

Thanks for your help.

anversha_s
Active Contributor
0 Kudos
115

hi,

try this.

[code]

1. pick all data from taba to itab1

2. pick all data from tabb to itab2.

3. loop at itab1.

read table itab2 with ur key.

if sy-subrc <> 0. "not found

append to a final itab

endif.

4. in final itab u will get required data

code]

rgds

Anver

0 Kudos
115

try this.

1. pick all data from taba to itab1

2. pick all data from tabb to itab2.

3. loop at itab1.

read table itab2 with ur key.

if sy-subrc <> 0. "not found

append to a final itab

endif.

4. in final itab u will get required data

Former Member
0 Kudos
115

Thank you, answered.