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

Join condition

Former Member
0 Likes
797

Hi Gurus,

I have a database table dbstatora with fields

TNAME --> Table Name

ANDAT --> Analyzing Date

AMETH --> Analysis method for collecting Statistics

NROWS --> No of rows in a table

OCCBL --> Used blk(size) of table in KB

EMPBL --> Empty blk(size) of table in KB

AFREE --> Avg Freespace in a used db block

INDBS --> Used Blk(size) of an index kb

And another table RSTSODS

The fields of this table is

ODSNAME

VERSION

ODSNAME_TECH

etc

I want to join these two tables and display the result with these fields,

ODSNAME, TNAME(/BIC/A%, /BI0/A% ,/BIC/B%, /BI0/B%) and all the fields of DBSTATTORA,

The common field for these two TABLES is

TNAME in DBSTATTORA = /BIC/B% OR /BI0/B%

ODSNAME_TECH in RSTSODS = /BIC/B% /BI0/B%

I tried inner join it doesn't work, which join should i use to display my result as specified above.

Any help will be of great help.

Thanks,

Prab

5 REPLIES 5
Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
595

Hi Prabhakaran

It depends on your requirement whihjoin type you should use. However, I guess you require LEFT OUTER JOIN where DBSTATORA is the left side table.

For more information on JOIN, you can visit <a href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm">here</a>.

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Read only

0 Likes
595

Hi Serder,

Thanks it really helped me, but still i am not able to display the results as how i wanted.

Regards,

Prabhu.

Read only

0 Likes
595

Hi,

Try selecting the records using 'For all entries' of first table with the common fields in the where condition, this might work.

Rgds,

Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
595

Hi Prabhakaran

I did not try at the system but you can try:

SELECT a~tname a~andat a~ameth
       a~nrows a~occbl a~empbl
       a~afree a~indbs b~odsname
       FROM dbstatora AS a
       LEFT OUTER JOIN rstsods
         ON a~tname = b~odsname_tech
       INTO TABLE gt_itab .

If this does not give the output you require, are you sure about the result you expect can be gathered via the join condition?

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Read only

0 Likes
595

Hi,

I tried the way u sent but it displays all the tables names of ods i.e only the change log tables but i also want to display the tables names of active data and new data tables of ods. So what i did is i created a view based on DBSTATTORA and RSTSODS. This view displays all the change log table names of ods for that particular ods. Now i am using this view and the table DBSTATTORA joining it so that i can display all the tables of ods object. In the join condition if i do left outer join of

SELECT DTNAME DANDAT DNROWS DOCCBL DEMPBL DAFREE D~INDBS

V~ODSNAME UP TO 30 ROWS

INTO (WD-TNAME, WD-ANDAT, WD-NROWS, WD-OCCBL, WD-EMPBL, WD-AFREE,

WD-INDBS, WV-ODSNAME)

FROM DBSTATTORA AS D LEFT JOIN ZOBTODS_VW AS V

ON DTNAME = VTNAME

WHERE D~NROWS > 50000

AND DTNAME LIKE '/BIC/A%' OR DTNAME LIKE '/BI0/A%' OR

DTNAME LIKE '/BIC/B%' OR DTNAME LIKE '/BI0/B%'.

This displays only the /bic/A* and /bio/a* tables,

I think by seeing this code u would have got it. Any suggestions or help will be of great help.

Thanks,

Prabhu