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

regarding fetching data from diff tables

Former Member
0 Likes
666

hi experts,

i wan to know how cud i fetch data from more than one table.should i use views for this..

regards

raman

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
650

hi

as per requirement u can access more than one table through join commands

there is 2 types of join, one inner join and another is outer join. this will solve the problem. if u need I can send the code also.

thanks

Roopesh

6 REPLIES 6
Read only

Former Member
0 Likes
650

Hi,

U can fetch the data from more than one dbtable using select statement or creating a view.

Views are logical views on more than one table..

Check this link...

http://help.sap.com/saphelp_webas620/helpdata/en/cf/21ec5d446011d189700000e8322d00/content.htm

Look at the below link to create the Database view

http://help.sap.com/saphelp_40b/helpdata/en/cf/21ed06446011d189700000e8322d00/content.htm

Regards,

Priyanka.

Read only

Former Member
0 Likes
650

thanx priyanka,

tell me how can i declare views in my program.

regards,

raman.

Read only

0 Likes
650

Hi Raman,

In the first link they have shown a example.Pls go through it, if doesn't help, reply back.

Best Regards

Kusum

PS: Reward all helpful answers.

Read only

Former Member
0 Likes
650

Hi

You can fetch data from more than one table using JOINS

you join the table using key fields and fetch data

select amatnr amtart bwerks clgort

into table itab

from mara as a Join marc as b

on amatnr = bmatnr join MARD as d

on bmatnr = cmatnr and

bwerks = cwerks

where matnr in s_matnr.

Again You can create database View with more than one table and write a select to that view, again in that view tables are to be linked with key fields.

- Database View (SE11)

Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.

In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
651

hi

as per requirement u can access more than one table through join commands

there is 2 types of join, one inner join and another is outer join. this will solve the problem. if u need I can send the code also.

thanks

Roopesh

Read only

Former Member
0 Likes
650

hi,

can u plz send me the code if possible.

regards,

raman