2007 Sep 14 6:47 AM
Hi,
Can anybody please explain the following, if possible with an example:
1. None of the fields in the table on the right can apear in the WHERE conditions of the LEFT OUTER JOIN.
2. SELECT <fieldlist> INTO <target>
FROM <dbtab1> AS <alias1>
INNER JOIN <dbtab2> AS <alias2>
ON <alaias1><dbtab1-field1> = <alials2><dbtab2-field1>.
Please explain the about code specially the alaising involved.
Regards,
Dhiraj Mehta
2007 Sep 14 6:58 AM
Hi dhiraj,
for outer joins go thro this document.
http://help.sap.com/saphelp_47x200/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm
2) it is just giving another name to the dbtable in the select query.
take an example:
select amatnr bwerks into corresponding fields of table itab from mara as a inner join marc as b on amatnr = bmatnr.
Regards....
Arun.
Reward points if useful.
Hi dhiraj,
for outer joins go thro this document.
http://help.sap.com/saphelp_47x200/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm
2) it is just giving another name to the dbtable in the select query.
take an example:
select amatnr bwerks into corresponding fields of table itab from mara as a inner join marc as b on amatnr = bmatnr.
Regards....
Arun.
Reward points if useful.
2007 Sep 14 6:58 AM
Hi dhiraj,
for outer joins go thro this document.
http://help.sap.com/saphelp_47x200/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm
2) it is just giving another name to the dbtable in the select query.
take an example:
select amatnr bwerks into corresponding fields of table itab from mara as a inner join marc as b on amatnr = bmatnr.
Regards....
Arun.
Reward points if useful.
2007 Sep 14 7:03 AM
Hi Dhiraj
I have attached a sample code for your reference.
SELECT aaufnr aauart aerdat aaenam a~ktext
akostv akostl aobjnr akdauf a~kdpos
aadrnra apspel aernam azzact_cde
bpriok bequnr bbautl biloan
bgewrk baddat bqmnum bilart
carbpl cwerks
dgltrp dgstrp dgluzp dgsuzp dmaufnr daufpl
etplnr eabckz eeqfnr ebeber e~proid
f~bstkd
ggroes ginbdt geqart geqtyp
i~ktsch
INTO TABLE i_order
FROM aufk AS a INNER JOIN afih AS b ON aaufnr = baufnr
INNER JOIN crhd AS c ON cobjid = bgewrk
INNER JOIN afko AS d ON aaufnr = daufnr
INNER JOIN iloa AS e ON biloan = eiloan
INNER JOIN pmsdo AS f ON fobjnr = aobjnr
LEFT OUTER JOIN equi AS g ON gequnr = bequnr
INNER JOIN afvc AS i ON iaufpl = daufpl
WHERE a~aufnr IN s_aufnr
AND a~auart IN p_auart
AND a~kostv IN s_kostv
AND a~kdauf IN s_kdauf
AND b~ilart IN s_ilart
AND b~equnr IN s_equi
AND b~addat IN s_period
AND b~iphas IN r_iphas
AND b~priok IN s_proik
AND c~arbpl IN s_arbpl
AND c~werks IN s_werks
AND d~maufnr IN s_maufnr
AND d~gstrp IN s_gstrp
AND d~gltrp IN s_gltrp
AND e~beber IN s_beber
AND e~stort IN s_stort
AND e~tplnr IN s_tplnr
AND f~bstkd IN s_bstkd
AND i~loekz NE 'X'.
You can see that I have used so many inner joins.
The method of alaising comes when you have two tables with the same fieldname and you have distinguish between them.
For example in this sample code you have AUFNR in AUFK and AFIH table as well. But we are interested to pick only AUFNR from AUFK table and not from AFIH.
Therefore we write a~aufk in the select query < field list>.
I have also used the left outer join. But u can check that I have not used the fileds of the left outer join table equi. That is the way the syntax of a select query using joins are defined.
Similarly you can verify the other fields in the select query.
Hope its clear now.
Please award points if the answer is satisfactory.
Regards,
Bhanu
2007 Sep 14 7:12 AM
Hi dhiraj
1. No you can't , For outter join , you need the same field between two table that you join but there is no need for the same data between there.
2. SELECT <fieldlist> INTO <target> FROM <dbtab1> AS <alias1>
meaning is Selecting data of field from table and keep into variable and name the table as a.
example
select bukrs into v_bukrs from bsid as a
bukrs is field in table
v_bukrs is variable that you declare
you name the table as a , next time you can mention this table as a .
SELECT <fieldlist> INTO <target>
FROM <dbtab1> AS <alias1>
INNER JOIN <dbtab2> AS <alias2>
ON <alaias1><dbtab1-field1> = <alials2><dbtab2-field1>.
you have two table and two table have relationship , you select the data from two table by condition that link between two table.
Example
select a.bukrs b.xxx into (v_bukrs,v_xxx)
from bsid as a
inner join bsad as b
on amandt = bmandt
you select data in field bukrs from table bsid and xxx from table bsad and keep into variable v_bukrs and v_xxx which condition that field mandt in the two table are the same.
Regards
Wiboon
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |