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

Reg : Select of Non corresponding data using Join statement

Former Member
0 Likes
708

Hi all,

I have 2 custom tables. Now i want to select the non corresponding data (Sales Orders) from the this 2 tables. I am using the below code.

SELECT a~mandt

a~account

a~store

a~purch_no

a~dist_id

a~purch_date

a~order_no

a~line_no

a~sched_dt

a~bk_ord_dt

a~last_shp_dt

a~order_qty

a~sched_qty

a~bk_ord_qty

a~shipd_qty

a~uom

a~status

a~shpfrm_loc

a~shpfrm_city

a~shpfrm_reg

a~last_req_id

a~last_req_dt

a~last_req_tm

a~last_resp_id

a~last_resp_dt

a~last_resp_tm

a~mod_user

FROM ztab1 AS a

INNER JOIN ztab2 AS b

ON aorder_no NE border_no

INTO TABLE it_eorditmstat.

ztab1 have 27 records. ztab2 have 313. I am getting 8345 records into table it_eorditmstat which should not . Please help me to overcome this scenario.

Thanks in advance.

Regards,

Srinivas

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
683

In case of inner JOIN your are getting the result as A X B.

What do you mean by non corresponding data?

Clarify your requirement please.

Hi all,

I have 2 custom tables. Now i want to select the non corresponding data (Sales Orders) from the this 2 tables. I am using the below code.

SELECT a~mandt

a~account

a~store

a~purch_no

a~dist_id

a~purch_date

a~order_no

a~line_no

a~sched_dt

a~bk_ord_dt

a~last_shp_dt

a~order_qty

a~sched_qty

a~bk_ord_qty

a~shipd_qty

a~uom

a~status

a~shpfrm_loc

a~shpfrm_city

a~shpfrm_reg

a~last_req_id

a~last_req_dt

a~last_req_tm

a~last_resp_id

a~last_resp_dt

a~last_resp_tm

a~mod_user

FROM ztab1 AS a

INNER JOIN ztab2 AS b

ON aorder_no NE border_no

INTO TABLE it_eorditmstat.

ztab1 have 27 records. ztab2 have 313. I am getting 8345 records into table it_eorditmstat which should not . Please help me to overcome this scenario.

Thanks in advance.

Regards,

Srinivas

4 REPLIES 4
Read only

Former Member
0 Likes
684

In case of inner JOIN your are getting the result as A X B.

What do you mean by non corresponding data?

Clarify your requirement please.

Read only

0 Likes
683

Hi,

Thanks for your reply.

Non corresponding means I want Not matching records between both the tables.

For example.

I have an Order 100004550 in table ZTAB1 if this order is not available in ZTAB2 then record should be selected in the final internal table.

Please reply for any clarification.

Thanks in advance.

Read only

0 Likes
683

Try this approach if possible.


SELECT data from both tables independently.

LOOP AT it_ztab1. 
READ it_ztab2. 
IF sy-subrc <> 0. 
APPEND it_eorditmstat. 
ENDIF.
ENDLOOP.

Read only

Former Member
0 Likes
683

Hi ,

Using inner join will affect Performance and can cause issues in Production .

Try to use Views instead of inner join and select data accordingly

OR

Use FOR ALL ENTRIES .

First select all data from one DBTAble into Internal table and then select corresponding entries as per your KEY

Select*from DBtable FOR ALL ENTRIES IN <itab> WHERE field <> itab-field .