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

To convert outer join into separate queries

Former Member
0 Likes
839

Dear all

Due to some urgent requirement I have to replace an outer join with separate queries.

Kindly help me in replacing an outer join with separate database queries.

I have tried a number of options but I need some experts' advice before proceeding with the changes.

Regards

Dinesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
817

Take 2 itabs itab1, itab2.

itab2 contains fields from both from tab1 and tab2.

Read Data into itab1 from table1 (into corrsponding fields).

Read Data into itab2 from table2 for all entries in itab1 using key (into corrsponding fields).

awrd oints if useful

Bhupal

Dear all

Due to some urgent requirement I have to replace an outer join with separate queries.

Kindly help me in replacing an outer join with separate database queries.

I have tried a number of options but I need some experts' advice before proceeding with the changes.

Regards

Dinesh

7 REPLIES 7
Read only

Former Member
0 Likes
818

Take 2 itabs itab1, itab2.

itab2 contains fields from both from tab1 and tab2.

Read Data into itab1 from table1 (into corrsponding fields).

Read Data into itab2 from table2 for all entries in itab1 using key (into corrsponding fields).

awrd oints if useful

Bhupal

Read only

rajesh_akarte2
Active Participant
0 Likes
817

Hi,

Could u plz post ut outer join query?

or if u know 'FOR ALL ENTRIES' option then u can try.

Regards,

Rajesh Akarte

Read only

Former Member
0 Likes
817

Hi Dinesh,

let us assume there are two database tables say DB1 and DB2 .DB1 contain 6 records and DB2 contain 5 records.And also assume u r having two internal tables say ITAB1 and ITAB2.

First we have to select the records form the DB1 table and place them in ITAB1 OK..

Next we have to apply FOR ALL ENTRIES condition on ITAB1.Then ur problem will be resolved.

i will send sample code check it once..

select * from DB1 INTO CORRESPONIDNG FILEDS OF ITAB1.

select * from DB2 into corresponding fileds of ITAB2

FOR ALL ENTRIES IN ITAB1

where vbeln = ITAB1-VBELN..

U HAVE TO GO FOR UR OWN WHERE CLAUSE OK...

For understanding purpose i will take VBELN filed.

Award points if helpful..

Kiran Kumar.G

Have a Nice Day.

Read only

Former Member
0 Likes
817

Hi,

Consider u r select statement:-

SELECT AMATNR BWERKS FROM MARA AS A OUTERJOIN MARC AS B

INTO ITAB ON MATNR IN S_MATNR.

INSTEAD OF ABOVE:-

SELECT MATNR FROM MARA INTO TABLE ITAB1.

THEN

SELECT MATNR WERKS FROM MARC FOR ALLENTRIES IN ITAB2 INTO TABLE ITAB2 WHERE MATNR = S_MATNR.

THEN

LOOP AT ITAB1 INTO WAITAB1.

WAITAB3-MATNR = WAITAB1-MATNR.

READ TABLE ITAB2 INTO WAITAB2 WHERE MATNR = WAITAB1-MATNR.

IF SY-SUBRC = 0.

WAITAB3-WERKS = WAITAB2-WERKS.

ENDIF.

APPEND WAITAB3 TO ITAB3.

ENDLOOP.

Read only

Former Member
0 Likes
817

It didn't work out as expected.

Edited by: dinesh dhiman on Jan 21, 2008 2:14 PM

Read only

Former Member
0 Likes
817

The answer posted later was a little more helpful. So realligning points

Read only

Former Member
0 Likes
817

Solved on me own.