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

Select query join problem

Former Member
0 Likes
1,974

hey guys,

i've used a select query to get details from KNA1, KNVV, ADRC, KNVP, pa0002. tables by joining. but i'm getting only about 170 records. there are more than 3000 records in the database. for each tables. here is my select query

SELECT KNA1KUNNR KNA1NAME1 KNA1NAME2 ADRCSTR_SUPPL1 ADRCSTR_SUPPL2 ADRCSTR_SUPPL3 ADRCCITY1 KNVVVWERK KNVPPERNR PA0002VORNA PA0002NACHN KNVVVKBUR KNVVKDGRP KNA1STCD1 KNA1~STCEG

INTO CORRESPONDING FIELDS OF TABLE IT_FINAL FROM KNA1

INNER JOIN KNVV ON KNA1KUNNR = KNVVKUNNR

INNER JOIN ADRC ON KNA1ADRNR = ADRCADDRNUMBER

INNER JOIN KNVP ON KNA1KUNNR = KNVPKUNNR

INNER JOIN PA0002 ON KNVPPERNR = PA0002PERNR

WHERE KNA1KUNNR IN S_KUNNR AND KNVVVWERK in P_VWERK AND PA0002PERNR IN S_PERNR AND KNVVVKBUR IN S_VKBUR AND KNVV~KDGRP IN S_KDGRP.

can anyone tell me the problem in the above query.

thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,541

Hi

you are using tables KNA1, KNVV, ADRC, KNVP, pa0002.

Create internal table for each table mentioned above with all the primary keys and find the links between them

then select data in one table and select data from another table into your internal table for all the entries exists in firs internal table.

go for below links.

http://www.sapdev.co.uk/abap/commands/select_forallentries.htm

http://wiki.sdn.sap.com/wiki/display/ABAP/FORALLENTRIES-Home+page

http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_ITAB.htm

Thanks

lalit

6 REPLIES 6
Read only

Former Member
0 Likes
1,541

please help me someone..

Read only

0 Likes
1,541

Hi

First avoid joining more than 3 table

instead you can use for all entries.

search on for all entries

it will surely resolve your issue.

thanks

Lalit Gupta

Read only

0 Likes
1,541

how to search on for all entries? can u explain it further more?

Read only

Former Member
0 Likes
1,541

HI,

don't know why your join is not working but you can analyse that.

Use SQVI (Quick viewer) and join the first 2 tables and view the result with a data record that is veryfied to be ok.

Now add always one additional table to the join and check which join causes and why you loose the data record.

Best regards, Christian

Read only

0 Likes
1,541

Dear Christian ,

Could you please tell me , how to check the entries in the Transaction 'SQVI' by using the Data record.

Thanking You All.

Read only

Former Member
0 Likes
1,542

Hi

you are using tables KNA1, KNVV, ADRC, KNVP, pa0002.

Create internal table for each table mentioned above with all the primary keys and find the links between them

then select data in one table and select data from another table into your internal table for all the entries exists in firs internal table.

go for below links.

http://www.sapdev.co.uk/abap/commands/select_forallentries.htm

http://wiki.sdn.sap.com/wiki/display/ABAP/FORALLENTRIES-Home+page

http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_ITAB.htm

Thanks

lalit