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

retrieving data from 2 tables

Former Member
0 Likes
683

Hi,

I have to develop a report in which I have to retrieve data from 2 tables knvv((loevm) and knvp(kunnr,vkorg,parvw,kunn2).Without joining these 2 tables how can I retrieve data from these 2 tables?

Regards,

Hema

5 REPLIES 5
Read only

Former Member
0 Likes
661

select *

into table itab_KNVV

from KNVV.

select *

into table itab_KNVP

for all entries in itab_KNVV

where XXXXX = itab_KNVV-XXXX

and XXXXX = itab_KNVV-XXXXX.

Loop itab_KNVP.

READ TABLE itab_KNVV with key XXXXX = XXXXX.

itab_KNVP-xxxxx = itab_KNVV-xxxx.

MODIFY itab_KNVP.

ENDLOOP.

Read only

Former Member
0 Likes
661

u can use the views to combine data from differen tables..

Read only

Former Member
0 Likes
661

Retrieve data form knvv and use for all enteries of knvv to retrieve datta from knvp

Read only

Former Member
0 Likes
661

if u dont want to go for join..U can use this code..

select kunnr loevm

into (itab-kunnr, itab-loevm)

from KNVV.

select single kunnr vkorg parvw kunn2

into (itab-kunnr, itab-vkorg, itab-parvw,itab-kunn2)

from KNVP

where KUNNR= itab-KUNNR.

append itab.

clear itab.

endselect.

Read only

Former Member
0 Likes
661

Hi

by using FOR ALL ENTRIES YOU CAN GET THE DATA FROM 2 TABLES WITH OUT USEING JOINS

AND THE PERFORMANCE IS ALSO BETTERCOMPARED TO JOINS

FOR ALL ENTRIES CAN BE WROTE LIKE THIS

SELECT DATA FROM TABLE INTO TABLE ITAB WHERE CONDITION

SELECT DATA FROM TABLE2 INTO TABLE ITAB2 FOR ALL ENTRIES WHERE CONDITION ( PRIMARY FILED = ITAB - PRIMARY FIELD)

REWARD IF USEFULL