INNER JOIN Where to Use
hi,
is there any criteria determining the usage of <b>inner join</b>, i.e no. of rows to be retrieved from the tables... can we avoid using <b>inner joins</b>...
i hope i have cleared my query.....
thanx in advance
abhishek suppal
Abhishek,
Inner joins (when used correctly) are a GOOD thing.
The criteria as to when to use an inner join is that the tables must have common values. For example let's look at VBAK and VBAP. The both share VBELN as their common link. And becasue VBELN is part of their keys it is very good to use an inner join if you need data from both tables.
eg. We want to get sales Order data into TBL_SALESORDER from VBAK / VBAP
Without Inner Join you can do it something like this:
data: begin of tbl_vbak occurs 0,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
audat like vbak-audat,
end of tbl_vbak.
data: begin of tbl_vbap occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
zmeng like vbap-zmeng,
end of tbl_vbap.
data: begin of tbl_salesorder occurs 0,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
audat like vbak-audat,
posnr like vbap-posnr,
matnr like vbap-matnr,
zmeng like vbap-zmeng,
end of tbl_salesorder.
data: l_index like st-tabix.
select vbeln kunnr audat
into table tbl_vbak
from vbak.
check sy-subrc eq 0.
select vbeln posnr matnr zmeng
into table tbl_vbap
from vbap
for all entries in tbl_vbak
where vbeln = tbl_vbak-vbeln.
check sy-subrc eq 0.
sort tbl_vbap by vbeln posnr.
loop at tbl_vbak.
read table tbl_vbap with key vbeln = tbl_vbak-vbeln
binary search.
if sy-subrc eq 0.
l_index = sy-tabix.
loop at tbl_vbap from l_index.
if tbl_vbak-vbeln ne tbl_vbap-vbeln.
exit.
endif.
clear tbl_salesorder.
move-corresponding tbl_vbak to tbl_salesorder.
move-corresponding tbl_vbap to tbl_salesorder.
append tbl_salesorder.
endloop.
endif.
endloop.
With an inner join you can do it like this:
data: begin of tbl_salesorder occurs 0,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
audat like vbak-audat,
posnr like vbap-posnr,
matnr like vbap-matnr,
zmeng like vbap-zmeng,
end of tbl_salesorder.
select vbak~vbeln vbak~kunnr vbak~audat
vbap~posnr vbap~matnr vbap~zmeng
into table tbl_salesorder
from vbak
inner join vbap
on vbak~vbeln = vbap~vbeln.
In the above example it is more efficient to use the inner join because we hit the database once. Without the inner join we hit the database twice (once for the VBAK info and the other time for the VBAP info).
If you want to restrict the data you canuse a select option or parameter like any other SELECT statement. What you probably would not do is use the "UP TO X ROWS" clause as this will essentially limit the data from VBAP not VBAK.
I know that this example is a very simple one and we were luck to be able to "join" the tables using their primary keys. If the "join" between the tables are not by their primary keys or by an index then you may need to reconsider using an inner join and this will cause performance problems.
I hope this makes some sense. Let me know if you need more info, alternatively take a look at the SAP Help (F1) for SELECT.
Cheers,
Pat.
PS. Kindly assign Reward Points to the posts you find helpful.
Similar Messages
-
Iam not getting output for inner join where condition
the condition i have give
TYPES:BEGIN OF TY_TAB,
WERKS TYPE WERKS_D,
LGORT TYPE LGORT_D,
LGOBE TYPE LGOBE,
NAME1 TYPE NAME1,
END OF TY_TAB.
DATA WA_TAB TYPE TY_TAB.
DATA IT_TAB TYPE TABLE OF TY_TAB.
SELECT T001L~WERKS
T001L~LGORT
T001L~LGOBE
T001W~NAME1
INTO TABLE IT_TAB FROM T001L INNER JOIN T001W ON T001LWERKS = T001WWERKS
WHERE T001L~WERKS = 'amjt' and
T001L~WERKS = 'bimi' and
T001L~WERKS = 'biml'.
LOOP AT IT_TAB INTO WA_TAB.
WRITE: / WA_TAB-WERKS,WA_TAB-LGORT,WA_TAB-LGOBE,WA_TAB-NAME1.
ENDLOOP.
iam not getting output for thisWell, re-read carefully your code
WHERE T001L~WERKS = 'amjt' and
T001L~WERKS = 'bimi' and
T001L~WERKS = 'biml'
- WERKS cannot be simultaneously equal to three different values, replace AND with OR ([Boolean algebra|http://en.wikipedia.org/wiki/Boolean_algebra])
- WERKS domain does not allow lowercase, so use uppercase ([Creating Domains|http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21edf2446011d189700000e8322d00/frameset.htm])
Regards,
Raymond -
Inner join where condition?
hi all this i wrote inner join but i want for particular purchase order
what shall i add in where condtion
SELECT SINGLE
a~ernam
b~persnumber
b~addrnumber
c~smtp_addr
INTO (l_ernam, l_persnumber,l_addrnumber,l_smtp_addr)
FROM ( ( usr21 AS b INNER JOIN ekko AS a ON b~bname = a~ernam )
INNER JOIN adr6 AS c ON b~addrnumber = c~addrnumber
AND b~persnumber = c~persnumber ).Hi Oorvi,
just do as following.
SELECT SINGLE
a~ernam
b~persnumber
b~addrnumber
c~smtp_addr
INTO (l_ernam, l_persnumber,l_addrnumber,l_smtp_addr)
FROM ( ( usr21 AS b
INNER JOIN ekko AS a ON a~bname = b~ernam )
INNER JOIN adr6 AS c ON c~addrnumber = b~addrnumber
AND c~persnumber = b~persnumber )
*WHERE a~ebeln = p_ebeln*. "p_ebeln is your selection screen parameter -
Regarding : What is used in place of inner join
hi,
i want to know that we use to have inner joins in our reports and i want to know is there anything which can be used in place of it?Hi,
In place of inner join you can use FOR ALL ENTRIES.
reward point if useful.
Regards
Kumar M -
Are inner join and equijoin are same....?
are inner join and equijoin are same....?
WhiteHat wrote:
interesting it says that - an equi join is a type of inner join but you can't really say they are the same thing.Simply said it it like this:
Equi join means compare two tables where a value is in each table using an equal sign.
An inner join means: We use the INNER JOIN keyword and have a join condition between the two tables.
example1
select *
from emp
inner join dept on emp.dept_no = dept.dept_no;This example is an inner join and also an equi join.
example2
select *
from emp
inner join dept on emp.dept_no >= dept.dept_no;This example is an inner join which is NOT an equi join.
How to interpret the outcome is a different story (in this case it doesn't make much sense). However the syntax is correct and it is an inner join. But since it doesn't use the equal operator it is an non-equi join. -
hi friends,
can we use where clause in select statement with inner join.
i am using following code which gives error (The column name "WERKS" has two meanings . .).
SELECT AMATNR ACHARG AERSDA BMENGE B~MEINS
FROM MCHA AS A INNER JOIN CHVW AS B
ON ACHARG = BCHARG
INTO TABLE T_OUTPUT1
WHERE WERKS = PLANT AND CHARG = P_CHARG.
thanks.Yes u can use where clause in select statement with inner join.
SELECT AMATNR ACHARG AERSDA BMENGE B~MEINS
FROM MCHA AS A INNER JOIN CHVW AS B
ON ACHARG = BCHARG
INTO TABLE T_OUTPUT1
WHERE WERKS = PLANT AND CHARG = P_CHARG.
" mention the table name in where condition also like awerks or bwerks.
egards
Rajendra -
Hi experts,
I want to join the following fields balm, comh, comhr, balhdr, edidc.
I don't have common fields comhr and balhdr.
I have written an SQL query like this, will it work? what about performance
Please let me know.
select comh~msid
comh~mscla
comh~sedat
comh~seuzt
comhr~bid
balhdr~extnumber
balm~lognumber
balm~msgid
balm~msgv1
balm~msgv2
balm~msgv4
into corresponding fields of
table i_comhr
from comh
inner join comhr on comhmsid = comhrmsid
inner join balhdr on comhmsid = balhdrextnumber
inner join balm on balhdrlognumber = balmlognumber
where comh~sedat in credatc
and comh~seuzt in cretimc
and comh~werk in werk
and comh~source in source
and comh~mscla in mscla
and comh~errkz = errkz
and comh~tstkz in tstkz.
thanx,
jeevi.Hi,
Inner join can be used on matching keys only then it will display relevent data otherwise if keys are not matching it will not select the data.
Performance wise it is not at all recommeded to join mistmatch keys.
inseead u can do one thing , select data from comh and comhr into one itab using inner join and balhdr balm in other itab using inner join then u can read both itabs and can update data, anyway there u may need one link bet itabs that u can use for select stmt.
Hope following program will help u ...
Check this program,similar requirement.On click it is leading to transaction and bdc prcoess goes on.
* INCLUDE Z48M_KB11N_MAN_POST_F01 *
*& Form GET_DATA
* text
* --> p1 text
* <-- p2 text
FORM GET_DATA.
DATA : L_AMOUNT LIKE EKPO-MENGE.
DATA : LV_POSID TYPE PRPS-PSPNR.
DATA : LV_POSID_OLD TYPE PS_POSID.
DATA : LV_POSID_NEW TYPE PS_POSID.
DATA : LV_EBELN TYPE EKPO-EBELN,
LV_EBELP TYPE EKPO-EBELP,
LV_MESG_ID(20) TYPE C,
LV_MESG_NO(3) TYPE C.
CLEAR : G_T_BALHDR,G_T_BALHDR_FINAL.
REFRESH : G_T_BALHDR,G_T_BALHDR_FINAL.
*To get the PO num,item,mesg id,mesg no and text of mesg.
SELECT *
FROM BALHDR
INTO CORRESPONDING FIELDS OF TABLE G_T_BALHDR
WHERE OBJECT EQ 'Z48MMIGO' AND
SUBOBJECT EQ 'ZKB11N'.
IF NOT G_T_BALHDR[] IS INITIAL.
LOOP AT G_T_BALHDR.
CLEAR : G_T_T100.
REFRESH : G_T_T100.
CLEAR : LV_EBELN,LV_EBELP,LV_MESG_ID,LV_MESG_NO.
LV_EBELN = G_T_BALHDR-EXTNUMBER(10).
LV_EBELP = G_T_BALHDR-EXTNUMBER+13(5).
LV_MESG_ID = G_T_BALHDR-EXTNUMBER+19(2).
LV_MESG_NO = G_T_BALHDR-EXTNUMBER+22(3).
SELECT SINGLE *
FROM T100
INTO CORRESPONDING FIELDS OF G_T_T100
WHERE SPRSL = SY-LANGU AND
ARBGB = LV_MESG_ID AND
MSGNR = LV_MESG_NO.
IF SY-SUBRC = 0.
G_T_BALHDR_FINAL-LOGNUM = G_T_BALHDR-LOGNUMBER.
G_T_BALHDR_FINAL-OBJECT = G_T_BALHDR-OBJECT.
G_T_BALHDR_FINAL-SUBOBJECT = G_T_BALHDR-SUBOBJECT.
G_T_BALHDR_FINAL-EBELN = LV_EBELN.
G_T_BALHDR_FINAL-EBELP = LV_EBELP.
G_T_BALHDR_FINAL-MESG = G_T_T100-TEXT.
APPEND G_T_BALHDR_FINAL.
ENDIF.
ENDLOOP.
ENDIF.
IF NOT G_T_BALHDR_FINAL[] IS INITIAL.
CLEAR : G_T_EKPO.
REFRESH : G_T_EKPO.
*To get the amount,currency and new a/c assignment.
SELECT A~EBELN A~LIFNR A~WAERS B~EBELP B~NETPR B~MENGE B~MEINS
C~PS_PSP_PNR
INTO CORRESPONDING FIELDS OF TABLE G_T_EKPO
FROM ( EKKO AS A INNER JOIN EKPO AS B
ON A~EBELN = B~EBELN
INNER JOIN EKKN AS C
ON B~EBELN = C~EBELN AND
B~EBELP = C~EBELP )
FOR ALL ENTRIES IN G_T_BALHDR_FINAL
WHERE A~EBELN = G_T_BALHDR_FINAL-EBELN AND
B~EBELP = G_T_BALHDR_FINAL-EBELP.
ENDIF.
IF NOT G_T_EKPO[] IS INITIAL.
CLEAR : G_T_PO_LIFNR.
REFRESH : G_T_PO_LIFNR.
*To get the Cost element.
SELECT *
FROM Z48M_IN_PO_LIFNR
INTO CORRESPONDING FIELDS OF TABLE G_T_PO_LIFNR
FOR ALL ENTRIES IN G_T_EKPO
WHERE LIFNR = G_T_EKPO-LIFNR AND
PRJKT = 'X'.
ENDIF.
SORT G_T_BALHDR_FINAL BY EBELN EBELP.
CLEAR : G_T_FINAL.
REFRESH : G_T_FINAL.
LOOP AT G_T_BALHDR_FINAL.
SORT G_T_EKPO BY EBELN EBELP.
READ TABLE G_T_EKPO WITH KEY EBELN = G_T_BALHDR_FINAL-EBELN
EBELP = G_T_BALHDR_FINAL-EBELP
BINARY SEARCH.
IF SY-SUBRC = 0.
CLEAR : L_AMOUNT.
L_AMOUNT = G_T_EKPO-NETPR * G_T_EKPO-MENGE.
CLEAR : LV_POSID_NEW.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
INPUT = G_T_EKPO-PS_PSP_PNR
IMPORTING
OUTPUT = LV_POSID_NEW.
READ TABLE G_T_PO_LIFNR WITH KEY LIFNR = G_T_EKPO-LIFNR
PRJKT = 'X'
BINARY SEARCH.
IF SY-SUBRC = 0.
CLEAR : LV_POSID.
*To get the old a/c assignment.
SELECT SINGLE PSPNR
INTO LV_POSID
FROM PRPS
WHERE PSPHI EQ G_T_PO_LIFNR-PSPNR AND
STUFE EQ 1.
IF SY-SUBRC = 0.
CLEAR : LV_POSID_OLD.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
INPUT = LV_POSID
IMPORTING
OUTPUT = LV_POSID_OLD.
*Fill the final tab.
G_T_FINAL-LOGNUM = G_T_BALHDR_FINAL-LOGNUM.
G_T_FINAL-OBJECT = G_T_BALHDR_FINAL-OBJECT.
G_T_FINAL-SUBOBJECT = G_T_BALHDR_FINAL-SUBOBJECT.
G_T_FINAL-EBELN = G_T_EKPO-EBELN.
G_T_FINAL-EBELP = G_T_EKPO-EBELP.
G_T_FINAL-NETPR = G_T_EKPO-NETPR.
G_T_FINAL-MENGE = G_T_EKPO-MENGE.
WRITE L_AMOUNT UNIT G_T_EKPO-MEINS TO G_T_FINAL-AMOUNT.
G_T_FINAL-WAERS = G_T_EKPO-WAERS.
G_T_FINAL-KSTAR = G_T_PO_LIFNR-KSTAR.
G_T_FINAL-POSID_OLD = LV_POSID_OLD.
G_T_FINAL-POSID_NEW = LV_POSID_NEW.
G_T_FINAL-MESG = G_T_BALHDR_FINAL-MESG.
APPEND G_T_FINAL.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DATA
*& Form DISPLAY_DATA
* text
* --> p1 text
* <-- p2 text
FORM DISPLAY_DATA.
IF G_T_FINAL[] IS INITIAL.
MESSAGE S114(KB).
EXIT.
ENDIF.
* Populating the field catalog to the alv list
PERFORM FIELDCAT_POPULATION.
* Displaying report in ALV list format
PERFORM ALV_DISPLAY.
ENDFORM. " DISPLAY_DATA
*& Form FIELDCAT_POPULATION
* text
* --> p1 text
* <-- p2 text
FORM FIELDCAT_POPULATION.
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV. " For column heading
CLEAR : G_T_FIELDCAT,
G_T_FIELDCAT[].
* PO Number
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'G_T_FINAL'.
L_FIELDCAT-FIELDNAME = 'EBELN'.
L_FIELDCAT-SELTEXT_M = TEXT-001.
L_FIELDCAT-COL_POS = 1.
L_FIELDCAT-KEY = 'X'.
L_FIELDCAT-OUTPUTLEN = 15.
L_FIELDCAT-HOTSPOT = 'X'.
APPEND L_FIELDCAT TO G_T_FIELDCAT.
CLEAR L_FIELDCAT.
* PO item
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'G_T_FINAL'.
L_FIELDCAT-FIELDNAME = 'EBELP'.
L_FIELDCAT-SELTEXT_M = TEXT-002.
L_FIELDCAT-COL_POS = 2.
L_FIELDCAT-OUTPUTLEN = 10.
APPEND L_FIELDCAT TO G_T_FIELDCAT.
CLEAR L_FIELDCAT.
* Message
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'G_T_FINAL'.
L_FIELDCAT-FIELDNAME = 'MESG'.
L_FIELDCAT-SELTEXT_M = TEXT-003.
L_FIELDCAT-COL_POS = 3.
L_FIELDCAT-OUTPUTLEN = 80.
APPEND L_FIELDCAT TO G_T_FIELDCAT.
CLEAR L_FIELDCAT.
ENDFORM. " FIELDCAT_POPULATION
*& Form ALV_DISPLAY
* text
* --> p1 text
* <-- p2 text
FORM ALV_DISPLAY.
* Assign Report ID
CALL_BACK_PRG = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = CALL_BACK_PRG
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = G_T_FIELDCAT
TABLES
T_OUTTAB = G_T_FINAL[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ALV_DISPLAY
*& Form USER_COMMAND
* text
* --> p1 text
* <-- p2 text
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_DATE1 TYPE SY-DATUM,
L_DATE2 TYPE SY-DATUM,
L_YEAR(4),
L_MONTH(2),
L_DATE(2).
CLEAR : L_DATE,L_DATE1,L_DATE2,L_YEAR,L_MONTH.
L_DATE1 = SY-DATUM.
L_YEAR = L_DATE1(4).
L_MONTH = L_DATE1+4(2).
L_DATE = L_DATE1+6(2).
CONCATENATE L_DATE L_MONTH L_YEAR INTO L_DATE2 .
CASE R_UCOMM.
WHEN '&IC1'. "doubleclick
CHECK RS_SELFIELD-FIELDNAME = 'EBELN'.
READ TABLE G_T_FINAL INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
READ TABLE G_T_TEMP WITH KEY LOGNUM = G_T_FINAL-LOGNUM.
IF SY-SUBRC = 0.
MESSAGE I899(KB) WITH TEXT-004.
ELSE.
SET PARAMETER ID 'BES' FIELD G_T_FINAL-EBELN.
PERFORM BDC_DYNPRO USING 'SAPLK23F1' '1220'.
PERFORM BDC_FIELD USING 'COHEADER-SEND_REC_REL'
'05SAP'.
PERFORM BDC_FIELD USING 'RK23F-STATUS'
'S'.
PERFORM BDC_FIELD USING 'COHEADER-BLDAT'
L_DATE2.
PERFORM BDC_FIELD USING 'COHEADER-BUDAT'
L_DATE2.
PERFORM BDC_FIELD USING 'COHEADER-PERIO'
L_MONTH.
PERFORM BDC_FIELD USING 'RK23F-KSTAR'
G_T_FINAL-KSTAR.
PERFORM BDC_FIELD USING 'RK23F-WTGBTR'
G_T_FINAL-AMOUNT.
PERFORM BDC_FIELD USING 'RK23F-WAERS'
G_T_FINAL-WAERS.
PERFORM BDC_FIELD USING 'RK23F-SPSPNR'
G_T_FINAL-POSID_OLD.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RK23F-EPSPNR'.
PERFORM BDC_FIELD USING 'RK23F-EPSPNR'
G_T_FINAL-POSID_NEW.
PERFORM BDC_DYNPRO USING 'SAPLK23F1' '1220'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'COHEADER-SEND_REC_REL'
'05SAP'.
PERFORM BDC_FIELD USING 'RK23F-STATUS'
'S'.
PERFORM BDC_FIELD USING 'COHEADER-BLDAT'
L_DATE2.
PERFORM BDC_FIELD USING 'COHEADER-BUDAT'
L_DATE2.
PERFORM BDC_FIELD USING 'COHEADER-PERIO'
L_MONTH.
PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=NO'.
PERFORM BDC_DYNPRO USING 'SAPLK23F1' '1220'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RK23F-KSTAR'.
PERFORM BDC_FIELD USING 'RK23F-WAERS'
G_T_FINAL-WAERS.
*perform bdc_dynpro using 'SAPLK23F1' '1200'.
*perform bdc_field using 'BDC_CURSOR'
* 'COHEADER-SEND_REC_REL'.
*perform bdc_field using 'BDC_OKCODE'
* '=PVAR'.
*perform bdc_field using 'COHEADER-SEND_REC_REL'
* '05SAP'.
*perform bdc_field using 'RK23F-STATUS'
* 'L'.
*perform bdc_field using 'COHEADER-BLDAT'
* l_date2.
*perform bdc_field using 'COHEADER-BUDAT'
* l_date2.
*perform bdc_field using 'COHEADER-PERIO'
* l_month.
*perform bdc_dynpro using 'SAPLK23F1' '1200'.
*perform bdc_field using 'BDC_CURSOR'
* 'RK23F-STATUS'.
*perform bdc_field using 'BDC_OKCODE'
* '=LISI'.
*perform bdc_field using 'COHEADER-SEND_REC_REL'
* '05SAP'.
*perform bdc_field using 'RK23F-STATUS'
* 'S'.
*perform bdc_field using 'COHEADER-BLDAT'
* l_date2.
*perform bdc_field using 'COHEADER-BUDAT'
* l_date2.
*perform bdc_field using 'COHEADER-PERIO'
* l_month.
*perform bdc_dynpro using 'SAPLK23F1' '1220'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_field using 'COHEADER-SEND_REC_REL'
* '05SAP'.
*perform bdc_field using 'RK23F-STATUS'
* 'S'.
*perform bdc_field using 'COHEADER-BLDAT'
* l_date2.
*perform bdc_field using 'COHEADER-BUDAT'
* l_date2.
*perform bdc_field using 'COHEADER-PERIO'
* l_month.
*perform bdc_field using 'RK23F-KSTAR'
* g_t_final-kstar.
*perform bdc_field using 'RK23F-WTGBTR'
* g_t_final-amount.
*perform bdc_field using 'RK23F-WAERS'
* g_t_final-waers.
*perform bdc_field using 'RK23F-SPSPNR'
* g_t_final-posid_old.
*perform bdc_field using 'BDC_CURSOR'
* 'RK23F-EPSPNR'.
*perform bdc_field using 'RK23F-EPSPNR'
* g_t_final-posid_new.
*perform bdc_dynpro using 'SAPLK23F1' '1220'.
*perform bdc_field using 'BDC_OKCODE'
* '=BACK'.
*perform bdc_field using 'COHEADER-SEND_REC_REL'
* '05SAP'.
*perform bdc_field using 'RK23F-STATUS'
* 'S'.
*perform bdc_field using 'COHEADER-BLDAT'
* l_date2.
*perform bdc_field using 'COHEADER-BUDAT'
* l_date2.
*perform bdc_field using 'COHEADER-PERIO'
* l_month.
*perform bdc_dynpro using 'SAPLSPO1' '0100'.
*perform bdc_field using 'BDC_OKCODE'
* '=NO'.
*perform bdc_dynpro using 'SAPLK23F1' '1220'.
*perform bdc_field using 'BDC_CURSOR'
* 'RK23F-KSTAR'.
*perform bdc_field using 'RK23F-WAERS'
* g_t_final-waers.
CALL TRANSACTION 'KB11N' USING G_T_BDC MODE 'A' MESSAGES
INTO G_T_MESSAGE.
IF NOT G_T_MESSAGE[] IS INITIAL.
READ TABLE G_T_MESSAGE WITH KEY MSGTYP = 'S'.
IF SY-SUBRC = 0.
DELETE FROM BALHDR WHERE LOGNUMBER = G_T_FINAL-LOGNUM AND
OBJECT = G_T_FINAL-OBJECT AND
SUBOBJECT = G_T_FINAL-SUBOBJECT.
COMMIT WORK.
G_T_TEMP = G_T_FINAL.
APPEND G_T_TEMP.
ENDIF.
ENDIF.
*refresh g_t_bdc.
CLEAR G_T_BDC.
REFRESH G_T_BDC.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " USER_COMMAND
*& Form bdc_dynpro
* text
* -->P_0510 text
* -->P_0511 text
FORM BDC_DYNPRO USING PROGRAM
DYNPRO.
CLEAR G_T_BDC.
G_T_BDC-PROGRAM = PROGRAM.
G_T_BDC-DYNPRO = DYNPRO.
G_T_BDC-DYNBEGIN = 'X'.
APPEND G_T_BDC.
ENDFORM. " bdc_dynpro
*& Form bdc_field
* text
* -->P_0555 text
* -->P_G_T_FINAL_WAERS text
FORM BDC_FIELD USING FNAM
FVAL.
IF FVAL <> SPACE.
CLEAR G_T_BDC.
G_T_BDC-FNAM = FNAM.
G_T_BDC-FVAL = FVAL.
APPEND G_T_BDC.
ENDIF.
ENDFORM. " bdc_field
Jogdand M B -
Inner Join performance problem.
Hi,
I wrote a select statement using inner join on table VBRK , VBUK, VBAP and VBRP.
This select statement is working fine from last two years, but suddenly to execute this select statement
taking lot of time and program going to dump.
But same select statement is working in development and quality systems and not working in production system. Based on given selection we check the tables in production we found only 10 records, but to fetch these 10 records also it will taking lot of time and going to dump.
can anyone please advise on the same.
Thanks in advance.Hi,
Please:
1. Create DB view instead of inner join
2. Use the primary key of the base table (the first or main table in your view) in your where clause
3. If not possible, then you need to create secondary index in your base table that match with your where clause fields.
4. Try to use positive relationship operator, like EQ instead NE, GT, etc.
Hope it helps.
Lim... -
Drag-n-n-drop query joins uses WHERE, not INNER JOIN syntax
When I highlight a few tables and drag them onto the sql worksheet, it will build a select statement for me and join the tables by their foreign keys.
That's a nice feature, thanks!
Three questions. Is it possible to:
1. get it to use the INNER JOIN and LEFT OUTER JOIN syntax instead of joining the tables in the WHERE clause?
2. control the table aliases so that it will automatically use the "standard alias" for the table instead of A, B, C, etc.?
3. get it to not put the schema name into the query?
Thanks!
Edited by: David Wendelken on Nov 22, 2008 1:48 PM. Grammar mistake.Hi Gopi,
Your code is Good.
But try to avoid Inner join with more number of Tables ...because this is a performance issue..
try to use..
select (primary key fields mainly,other fields) from LIKP into itab where bolnr in p_bolnr(paramater).
next try to use for all entries option..
select (primary key fields mainly,other fields) from VBFA for all entries in itab where (give the condition)....
simillarly do for the other select ....ok this will try to reduce the performance issue....
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo -
Relationship between tables while using inner joins.
Hi,
I had a few clarifications on "inner joins", and as i was going through the forum, i came across two points,
1. In one of the threads it said " inner joins is applicable for tables that have a parent child relationship.
2. In another thread it said " inner join is established from master table (the table on the left) to the transcation table (the table on the right)".
I have two clarifications based on the above points.
1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
2. Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>.
Edited by: Narayananchandran on Dec 27, 2010 12:31 PMhave two clarifications based on the above points.
1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
2. Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>
1) NO
2) NO -
How to use Inner join of table as Source in Merge statement in SQL
Hi All,
I am trying to make source as multiple tables output using Join while coding there is no any syntax error but when i am executing this statement is giving following error
Following is the query
Merge Into EmpDept Target
Using (select E.Address,e.Design,e.EmailId,e.EmpId,e.Ename,e.ManagerId, e.Salary,D.DeptId,D.DeptName,D.Location from Employee E Inner join Dept D on E.DeptId=D.DeptId )As Source (Address,Design,EmailId,EmpId,EName,ManagerId,Salary,DeptId,DeptName,Location)
On Source.EmpId=Target.EmpId
when not matched then
Insert (Target.Address,Target.Design,Target.EmailId,Target.EmpId,Target.Ename,Target.ManagerId, Target.Salary,Target.DeptId,Target.DeptName,Target.Location)
values
(Address,Design,EmailId,EmpId,EName,ManagerId, Salary,DeptId,DeptName,Location)
When matched then
Update set Target.Address = Source.Address ,Target.Design = Source.Design,Target.EmailId = Source.EmailId ,Target.Ename = Source.Ename ,Target.ManagerId = Source.ManagerId , Target.Salary = Source.Salary ,Target.DeptId = Source.DeptId ,Target.DeptName = Source.DeptName ,Target.Location = Source.Location;
This is error while executing the above merge statement
The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.
Please suggest me where i am wrong..
Niraj SevalkarMERGE INTO EmpDept Target
Using (SELECT E.Address,
e.Design,
e.EmailId,
e.EmpId,
e.Ename,
e.ManagerId,
e.Salary,
D.DeptId,
D.DeptName,
D.Location
FROM Employee E
INNER JOIN Dept D
ON E.DeptId = D.DeptId) AS Source (Address, Design, EmailId, EmpId, EName, ManagerId, Salary, DeptId, DeptName, Location)
ON Source.EmpId = Target.EmpId
WHEN NOT matched THEN
INSERT (Address,
Design,
EmailId,
EmpId,
Ename,
ManagerId,
Salary,
DeptId,
DeptName,
Location)
VALUES (Address,
Design,
EmailId,
EmpId,
EName,
ManagerId,
Salary,
DeptId,
DeptName,
Location)
WHEN matched THEN
UPDATE SET Address = Source.Address,
Design = Source.Design,
EmailId = Source.EmailId,
Ename = Source.Ename,
ManagerId = Source.ManagerId,
Salary = Source.Salary,
DeptId = Source.DeptId,
DeptName = Source.DeptName,
Location = Source.Location; -
What is joins?where we use it. is it DD concept? abap
hi abapers,
what is joins?where we use it. is it DD concept?
regards,
anjanhi srinivas.
chk this simple example.
u will get good idea.
table emp
empno name
a sasi
b xxx
c yyy
table sal
empno salary
a 1000
b 2000
Inner join
select eempno ename
s~sal
into table int_table
from emp as e
inner join sal
on
eempno = sempno.
if you made inner join between table a and b by emp no
the selection retrives only if the condition satisfy the output will be
a sasi 1000
b xxx 2000
Outer join
select eempno ename
s~sal into table int_table
from emp as e
LEFT OUTER JOIN sal
on
eempno = sempno.
if you made outer join (left /right ) the left table kept as it is the
if the condition satisfy the right table entries will fetch else leave it blank
the output will be
a sasi a 1000
b xxx b 2000
c yyy
rgds
anver
if helped mark points -
How to use INNER JOIN in such case
when i program as below[CASE1]. the code is able to active.
CASE1:
==========================
DATA: WK_BUKRS LIKE T001-BUKRS,
WK_BUTXT LIKE T001-BUTXT,
WK_TABLE(4) TYPE C VALUE 'T001'.
START-OF-SELECTION.
WK_BUKRS = 'DECN'.
PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
CHANGING WK_BUTXT.
WRITE: WK_BUTXT.
FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
I_TABLE
CHANGING O_BUTXT LIKE T001-BUTXT.
SELECT SINGLE BUTXT
INTO O_BUTXT
FROM (I_TABLE)
WHERE BUKRS = I_BUKRS.
ENDFORM.
===========================
but when I need to INNER JOIN another table [CASE2]
CASE2:
=======================
DATA: WK_BUKRS LIKE T001-BUKRS,
WK_BUTXT LIKE T001-BUTXT,
WK_TABLE(4) TYPE C VALUE 'T001'.
START-OF-SELECTION.
WK_BUKRS = 'DECN'.
PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
CHANGING WK_BUTXT.
WRITE: WK_BUTXT.
FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
I_TABLE
CHANGING O_BUTXT LIKE T001-BUTXT.
SELECT SINGLE BUTXT
INTO O_BUTXT
FROM (I_TABLE) AS G INNER JOIN BKPF AS H
ON GBUKRS = HBUKRS
WHERE G~BUKRS = I_BUKRS.
ENDFORM.
=================================
Syntax error:
Wrong expression "INNER" in FROM clause. WHERE condition.
Can anybody help me to solve the problem.
My requirement is to use INNER JOIN with variable tablehi slam,
chk this sample code.
hi,
table emp
empno name
a sasi
b xxx
c yyy
table sal
empno salary
a 1000
b 2000
Inner join
select eempno ename
s~sal
into table int_table
from emp as e
inner join sal as s
on
eempno = sempno.
if you made inner join between table a and b by emp no
the selection retrives only if the condition satisfy the output will be
a sasi 1000
b xxx 2000
rgds
anver
if hlped mark points
Message was edited by: Anversha s -
The process time between INNER JOIN and join in WHERE clause
as u know, there are 2 kind of join
SELECT *
FROM tableA
INNER JOIN tableB
ON tableA.ID= tableB.ID
WHERE ....
and
SELECT *
FROM tableA, tableA
WHERE tableA.ID = tableB.ID
AND ....
I find the first one is faster in MS SQL Server.
But i test them in oracle and i find that it is the same. Is it correct?Who knows why SQL Server shows different timings. Perhaps it's just cos it's not good at knowing that the two things are the same.
The only difference in timing as far as Oracle is concerned is the time it takes to parse the syntax of the query, which will be nanoseconds. The execution time of two equivalent queries will not differ based on the factor of the syntax used. -
About a question using Update ... inner join ?
select *
FROM a
INNER JOIN b ON a.ProductID=b.ProductID
WHERE a.HeadID='000246'
this statement is ok ;
But the following statement does not work ! Why ?
UPDATE a SET
a.Quantity=a.PurchaseQuantity/b.ConversionGene
FROM a
INNER JOIN b ON a.ProductID=b.ProductID
WHERE a.HeadID='000246'"Because Oracle syntactically does not support that type of construct..." Is a correct statement, but not because "It expects only one table in UPDATE statement". The synatax for an updateable join in Oracle requires a "proper" in-line view to be updated.
As long as the table joined (in my example t1) has a declared unique constraint on the columns used to join by (in my example id), you can do it like:
SQL> SELECT * FROM t;
ID DESCR
1 One
2 Two
3 Three
SQL> SELECT * FROM t1;
ID DESCR2
1 Un
2 Deux
SQL> UPDATE (SELECT t.descr, t1.descr2
2 FROM t
3 JOIN t1 ON t.id = t1.id)
4 SET descr = descr2;
2 rows updated.
SQL> SELECT * FROM t;
ID DESCR
1 Un
2 Deux
3 ThreeTTFN
John
Maybe you are looking for
-
Problem with xcompmgr and i3 window manager
Hey guys, Had a hard time trying to search for this problem. and nothing came up for the exact problem I was having. Anyways this is my problem. with xcompmgr is that it doesn't seem to be refreshing or something. it leaves trails of previous windows
-
Heap Error during Windows OCIEnvCreate() call
During a call to: OCIEnvCreate(&m_handles.m_pOCIEnv, OCI_THREADED | OCI_OBJECT, NULL, NULL, NULL, NULL, 0, (dvoid **)0); A crash occurs which reports
-
if i open an extra tab, an extra firefox icon gets added to the taskbar (stacked icons turned on) If i close a tab, an icon disappears.
-
How do I get the icons back on my Reading List sidebar?
Since updating to Yosemite, I no longer have icons on the items on my Reading List Sidebar. Has anyone else encountered this issue and is there a fix that I can do to get them back.
-
DTW error (Journal Entry)
Hi, Please help me to know what is wrong to import Journal Entry by DTW; Reason is "You are not allowed to edit posting date by row Application-defined or object-defined error 65171" Version is 2005B SP00 PL41 I create the header file as below; Recor