Regarding join statement
SELECT vbrkvbeln vbfavbelv
vbrkfkdat vbrkkunag
vbrpwerks kna1name1
FROM vbrk
INNER JOIN vbrp ON vbrkvbeln = vbrpvbeln
INNER JOIN vbfa ON vbfavbeln = vbrkvbeln
INNER JOIN kna1 ON kna1kunnr = vbrkkunag
INTO CORRESPONDING FIELDS OF TABLE INVTAB
WHERE vbrp~werks IN s_werks
AND vbrk~fkdat IN s_fkdat
AND vbrk~kunag IN s_kunag
AND vbrk~fkart IN ('ZF2','FVAT')
AND vbrk~fksto <> 'X'
AND vbrk~rfbsk = 'C'
AND vbrk~sfakn = ''
AND vbrk~inco1 = 'TWO'
AND VBRK~VKORG NE '5000'
AND vbfa~vbtyp_n = 'M'
AND vbfa~vbtyp_v = 'J'.
i am writng this join statement
but when displaying i am getting multiple records for a particular entry
say for a particular documnet number if it is having N no. of line itmes and when searching in vbfa thenumber of preeecig documents are M then the resords that it is disp;laying is N*M.
but in some cases it is showing records more than this
can you please help me why it is showing more records.
and in if you can explain me with an example with a dummy no of records how it will fetch record that will be a great help.
Hi Ashish,
please chk the following links for inner and outer join ,
http://help.sap.com/saphelp_erp2004/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm
http://www.sap-img.com/abap/several-nested-inner-join-statements-can-be-inefficient.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_InnerJoinStatement.asp
now how to write join statements
SELECT
a~ebeln
a~ebelp
a~matnr
a~txz01
a~menge
a~meins
a~netpr
a~brtwr
a~netwr
a~mwskz
a~navnw
a~effwr
a~werks
b~eindt
FROM
ekpo AS a
INNER JOIN
eket AS b
ON
aebeln = bebeln
INTO
TABLE t_ekpo
WHERE
a~ebeln = t_ekko_temp-ebeln
AND b~ebeln = t_ekko_temp-ebeln.
Think there are 2 tables . a right hand table and a left hand table.
in inner join : only those fields having coresponding values in the left hand side table are selected.
in outer join all the fields on the left hand side table are selected and the fields which have no corresponding values in the right hand side table are displayed as null values..
Reward points if helpful
Regards ,
Amber S
Similar Messages
-
Query based on "NATURAL JOIN" statement of Oracle9i
I have created following 4 tables
create table CUST_MASTER
(CUST_NO NUMBER(3),CUST_NAME VARCHAR2(20),CUST_CITY VARCHAR2(20));
create table ITEM_MASTER
(ITEM_NO NUMBER(2),ITEM_NAME VARCHAR2(20),
PRICE NUMBER(4));
create table ORDER_HEADER
( ORDER_NO NUMBER(4), CUST_NO NUMBER(3));
create table ORDER_ITEMS
( ORDER_NO NUMBER(4), ITEM_NO NUMBER(2), QTY NUMBER(3));
Based on the above 4 table I have executed the following query.
select c.cust_no, c.cust_name, c.cust_city, oh.order_no, i.item_no, i.item_name, i.price, oi.qty
from cust_master c, item_master i, order_header oh, order_items oi
where c.cust_no = oh.cust_no and oh.order_no = oi.order_no and oi.item_no = i.item_no;
How should I build similar query in Oracle9i making use of "NATURAL JOIN" statement?Hallo,
yes you are correct.
From SQL Reference
NATURAL JOIN The NATURAL keyword indicates that a natural join is being performed. A natural join is based on all columns in the two tables that have the same name. It selects rows from the two tables that have equal values in the relevant columns
Nothing about foreign keys.
Test:
select * from scott.emp natural join scott.dept
DEPTNO EMPNO ENAME JOB MGR HIREDATE SAL COMM DNAME LOC
20 7369 SMITH CLERK 7902 17.12.1980 800 RESEARCH DALLAS
30 7499 ALLEN SALESMAN 7698 20.02.1981 1600 300 SALES CHICAGO
30 7521 WARD SALESMAN 7698 22.02.1981 1250 500 SALES CHICAGO
20 7566 JONES MANAGER 7839 02.04.1981 2975 RESEARCH DALLAS
30 7654 MARTIN SALESMAN 7698 28.09.1981 1250 1400 SALES CHICAGO
30 7698 BLAKE MANAGER 7839 01.05.1981 2850 SALES CHICAGO
10 7782 CLARK MANAGER 7839 09.06.1981 2450 ACCOUNTING NEW YORK
20 7788 SCOTT ANALYST 7566 19.04.1987 3000 RESEARCH DALLAS
10 7839 KING PRESIDENT 17.11.1981 5000 ACCOUNTING NEW YORK
30 7844 TURNER SALESMAN 7698 08.09.1981 1500 0 SALES CHICAGO
20 7876 ADAMS CLERK 7788 23.05.1987 1100 RESEARCH DALLAS
30 7900 JAMES CLERK 7698 03.12.1981 950 SALES CHICAGO
20 7902 FORD ANALYST 7566 03.12.1981 3000 RESEARCH DALLAS
10 7934 MILLER CLERK 7782 23.01.1982 1300 ACCOUNTING NEW YORK
alter table scott.emp drop constraint fk_deptno
select * from scott.emp natural join scott.dept
DEPTNO EMPNO ENAME JOB MGR HIREDATE SAL COMM DNAME LOC
20 7369 SMITH CLERK 7902 17.12.1980 800 RESEARCH DALLAS
30 7499 ALLEN SALESMAN 7698 20.02.1981 1600 300 SALES CHICAGO
30 7521 WARD SALESMAN 7698 22.02.1981 1250 500 SALES CHICAGO
20 7566 JONES MANAGER 7839 02.04.1981 2975 RESEARCH DALLAS
30 7654 MARTIN SALESMAN 7698 28.09.1981 1250 1400 SALES CHICAGO
30 7698 BLAKE MANAGER 7839 01.05.1981 2850 SALES CHICAGO
10 7782 CLARK MANAGER 7839 09.06.1981 2450 ACCOUNTING NEW YORK
20 7788 SCOTT ANALYST 7566 19.04.1987 3000 RESEARCH DALLAS
10 7839 KING PRESIDENT 17.11.1981 5000 ACCOUNTING NEW YORK
30 7844 TURNER SALESMAN 7698 08.09.1981 1500 0 SALES CHICAGO
20 7876 ADAMS CLERK 7788 23.05.1987 1100 RESEARCH DALLAS
30 7900 JAMES CLERK 7698 03.12.1981 950 SALES CHICAGO
20 7902 FORD ANALYST 7566 03.12.1981 3000 RESEARCH DALLAS
10 7934 MILLER CLERK 7782 23.01.1982 1300 ACCOUNTING NEW YORK
ALTER TABLE scott.emp
ADD CONSTRAINT fk_deptno FOREIGN KEY (deptno)
REFERENCES SCOTT.dept (deptno)
ENABLE NOVALIDATE
/Regards
Dmytro Dekhtyaryuk -
Urgent: Regarding Join Syntax in Oracle 9i and 10g
Dear Members
Please help me by providing me the synatx of following Join statements for Oracle 9i and 10g:
1.Inner Join
2.Left Outer Join
3.Right Outer Join
4.Self Join
5.Cross Join
6.Full Outer Join
N.B. I NEED THIS HELP URGENTLY
Regards
Praveen Kumar PandeyInner join
SELECT *
FROM a,
b
WHERE a.<<column>> = b.<<column>>Left Outer Join
SELECT *
FROM a LEFT OUTER JOIN b
ON a.<<column>> = b.<<column>>Right Outer Join
SELECT *
FROM a RIGHT OUTER JOIN b
ON a.<<column>> = b.<<column>>Full Outer Join
SELECT *
FROM a FULL OUTER JOIN b
ON a.<<column>> = b.<<column>>Self Join
SELECT *
FROM a a1,
a a2
WHERE a1.<<column>> = a2.<<column>>Cartesian Join
SELECT *
FROM a,
bJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Does 'For All Entries in itab' work exactly like 'Join' statement?
Hi,
I would like to know that if 'For All Entries in itab' work exactly like 'Join' statement?
If yes, then when I use 'For All Entries in itab' and a 'Join' statement seperately with the same logical conditions for both, the number of records returned by the two methods are not same. Ideally, they should both return the same number of recs.
Can somebody help?
With regards.Hi,
for all entries will not work in the same way unless untill it should satisfy some conditions,
it has some pre-requisests...
like in the select clause or in where clause or in both the cluases, there should be entire key..
then only it will behave like the join statement..
hope i am clear.
please revert back if u have any quiries.
Regards,
Sunil Kumar Mutyala. -
Hi All,
I am using this inner Join Statement
SELECT *
FROM vbap AS a INNER JOIN vbak AS b
ON avbeln = bvbeln
AND amandt = bmandt
WHERE a~vbeln IN lr_vbeln AND
a~posnr IN lr_posnr AND
a~aedat IN lr_aedat AND
( b~vbtyp EQ 'A' OR
b~vbtyp EQ 'B' OR
b~vbtyp EQ 'G' ).
But when i see the Output, One of the field ERDAT is geeting picked up from VBAK table instead of VBAP table.
Any pointers on how can we select the ERDAT from VBAP using this inner Join.
I dont want to use 2 select stetements.
Regards,
MayankIn Inner join, it is always advisable to put the header table as First table and secondly, it should be advisable to fetch only the requried fields. I believe that you might not required all the fields of VBAP table.
Select A~Vbeln
A~vbtyp
B~posnr
B~erdat
into table I_VBAP
from vbak as A innner Join VBAP as B
on a~vbeln = b~vbeln
where a~vbeln IN lr_vbeln AND
b~posnr IN lr_posnr AND
b~aedat IN lr_aedat AND
( a~vbtyp EQ 'A' OR
a~vbtyp EQ 'B' OR
a~vbtyp EQ 'G' ). -
Using offset in join statement
hi,
i wanted to use offset in join statement. but it is giving error.
select a~kunnr
a~vkorg
from knvv as inner join zcust
on knvv-kunnr+5(5) = zcust-refid.hi neha,
try this code i tested it.
types: begin of ty_knvv,
INCLUDE type knvv,
kunid type i, " For u type is zcust-refid
end of ty_knvv.
data: it_knvv type STANDARD TABLE OF ty_knvv INITIAL SIZE 0,
wa_knvv type ty_knvv.
select *
from knvv
into table it_knvv.
loop at it_knvv into wa_knvv.
kunid = wa_knvv-kunnr+5(5).
wa_knvv-kunid = kunid.
MOdify it_knvv TRANSPORTING kunid.
read table zcust into wa_zcust with key resid = wa_knvv-kunid.
endloop. -
Regarding case statement and decode function
Hi Experts,
I have question.....regarding case statement and decode statement....
Can you please explain me that which one will be efficient,to place in insert statement...
insert statement(
(case when ........then
case when ....then
else
end)
else
end)
or
insert statement(
case when.....then
decode(....)
else
end)
Can you people explain me which one is more efficient method?
Thanks in advance.......The are major differences to talk about in case of CASE vs DECODE, but performance wise both are pretty much the same.
Have a look at Tom's thread
Ask Tom &quot;better performance - case or decode&quot;
I would suggest to use CASE whenever possible. Don't worry about the performance part. -
Updateable scrollable result sets with join statement
I am writing a generic GUI fronend for any database that has a JDBC2.0 driver available.
I have been using scrollable updateable result sets. These work well for individual tables but as soon as two tables are linked either implicitly or explicitly with a join statement the result set meta data isDefinitelyWriteable is set to false thus preventing the result set from being updated.
Assuming I am using the JDBC-ODBC driver with java sdk1.4.0 and MS Access (although I have used other databases and JDBCs I assume that the one mentioned will be a common combination and needs to work) is there any way of getting linked tables to be updateable with scollable result sets.
I am using scrollable result sets since this prevents the necessity of putting the data in a secondary data store.
I am able to link tables programmatically by requerying the linked table with a new where clause each time the cursor moves in the linked table but this seems rather wasteful. This method is not vey satisfactory when attempting to display data from more than one table which have more than one linked level (i.e. cascaded links).
Is there a simple solution to this problem or do I have to do a rewrite using an update statement instead of having an updateable result set. I assume this method would also require the result set to be reloaded after the update.
Any suggestions much appreciated.I am trying to make the GUI as flexible as possible by constructing "views" which if necessary link tables on one field in each table. This is fine for two tables but when linking to several tables the information thats produced cannot be read easily because as it stands the information from each table is displayed on a separate tabbed page. This mechanism allows me to keep each record set for each table separate and updateable.
Since I could see that this was not very user friendly in the way that it displayed the data I decided to try and introduce a join on two or more tables and hence the introduction of the current problem.
I mentioned that the objective was to be flexible and therefore I also allow queries to be written by the user to facilitate for any shortfalls of the automatic query construction produced by using the "views" mechanism.
So the answer to your question is yes I do control the SQL selections with one mechanism but ultimately no I do not because I provide a fail safe which allows the user to enter arbitary SQL.
I only really want a solution for the controlled SQL construction mechanism where I create the link between two or more tables. As mentioned earlier these are linked on one field only but I wish to provide the option of displaying the result in a single table (tabbed page) rather than spread across multiple tabbed pages. -
AP name is not consistent in APs Join Stats.
hi all,
i have strange issue in my controller (WISM2) AP name is not consistent in APs Join Stats page while the naming is consistent in Wireless status page.as shown below.Thanks,
The problem solved after i cleared the access point from join AP stats. then restart it after that will join with normal name. -
I have been seraching for reference material that show
an illustration of ER Diagrams and SQL join statements.
I am usually developing queries from looking at an ER diagram and no other documentation. The books I am finding only have simple easy SQL join examples. I can no find a book that shows difficult join queries or relate join queries with ER diagrams. I am stuck in one case
where I have a table that relates to two other tables but there is a third table in common with both of them.
How should this join statement look?
Sometime I code the join logic correct but the parentheses
are in the wrong place. Can you help on this one as well?NLV,
Is this still an issue?
If so, please read Visakh16's last
response. We need more information.
[Personal Site] [Blog] [Facebook] -
Replicas stuck in join state 0
After a partition merge, all replicas are stuck in join state 0. Have been this way for about a week.
Any Help would be appreciated.
Thanks.Well, if you have a server in your tree which is down ( e.g. s server you shut off 5 years ago, but neglected to delete its NCP server object ) that will cause the issue, as well as a time sync issue. So these issues you can check and fix. Have you? If its not that, then you have a stuck partition operation. Something is preventing it from transitioning. That could be corruption or one of a number of preconditions have fallen apart. Do you see any errors showing up when you SET DSTRACE = ON and SET DSTRACE = +SYNC +PART You can use the "cancel partition operation" and hope that work, which it may well not. But if it does not, you will have a broken directory and have burnt all your bridges - especially if you 5 minutes later discover that 5 year old dead server object I spoke of.
What can Novell do that you cannot? A lot. And the guy you will be deal with sees 10 totally messed up beyond all comprehension eDir systems a day and can likely fix your issue in his sleep. IF you "followed the directions" and made a backup of eDir on each server and done a health check prior to the Merge, Novell can use the backups to restore the masters. They have the ability to edit the databases underneath to force things.
We've all been where you are now. Looking for the Easy Button. But you need to rapidly go through the stages of grieving an get to the acceptance stage an call Novell.
-- Bob -
Can someone explain me, why result of this query:
select * from sys.v_$sql
where hash_value in
(select hash_value from sys.v_$sql_plan
where options = 'CARTESIAN' and operation LIKE '%JOIN%' )
order by hash_value; is that statement:
select count(1) from all_objects where object_name = :1;My point to run this query is find all cartesian join statements.I am not sure but may it has something to do with multiple tables used through the view "all_objects" ...
Regards -
Hi All,
I need some assistance creating a sophisticated join statement. Please find below my sample data tables:
Table 1 (Region Product)
Region
Product Code
Product Desc
Dubai
Prod A
Prod A Desc
Dubai
Prod B
Prod B Desc
Dubai
Prod C
Prod C Desc
Sharjah
Prod B
Prod B Desc
Sharjah
Prod C
Prod C Desc
Abu Dhabi
Prod A
Prod A Desc
Abu Dhabi
Prod C
Prod C Desc
Table 2 (Region Locations)
Region
Location
Location Desc
Dubai
Loc 1
Dubai Mall
Dubai
Loc 2
MOE
Dubai
Loc 3
DCC
Dubai
Loc 4
MCC
Sharjah
Loc 11
Sahara Center
Sharjah
Loc 12
Mega Mall
Abu Dhabi
Loc 21
Marina Mall
Final Joined Table (Regions Locations Products)
Region
Location
Location Desc
Product Code
Product Desc
Dubai
Loc 1
Dubai Mall
Prod A
Prod A Desc
Dubai
Loc 1
Dubai Mall
Prod B
Prod B Desc
Dubai
Loc 1
Dubai Mall
Prod C
Prod C Desc
Dubai
Loc 2
MOE
Prod A
Prod A Desc
Dubai
Loc 2
MOE
Prod B
Prod B Desc
Dubai
Loc 2
MOE
Prod C
Prod C Desc
Dubai
Loc 3
DCC
Prod A
Prod A Desc
Dubai
Loc 3
DCC
Prod B
Prod B Desc
Dubai
Loc 3
DCC
Prod C
Prod C Desc
Dubai
Loc 4
MCC
Prod A
Prod A Desc
Dubai
Loc 4
MCC
Prod B
Prod B Desc
Dubai
Loc 4
MCC
Prod C
Prod C Desc
Sharjah
Loc 11
Sahara Center
Prod B
Prod B Desc
Sharjah
Loc 11
Sahara Center
Prod C
Prod C Desc
Sharjah
Loc 12
Mega Mall
Prod B
Prod B Desc
Sharjah
Loc 12
Mega Mall
Prod C
Prod C Desc
Abu Dhabi
Loc 21
Marina Mall
Prod A
Prod A Desc
Abu Dhabi
Loc 21
Marina Mall
Prod C
Prod C Desc
Here is the description:
We have a table of products available to be sold in each region
We have a table of locations in each region
We want to get a final table of which product is available in each location (region being the common factor)
I can do it manually, let’s say first for Dubai, then for Sharjah and then for Abu Dhabi and then take a union. But it's quite cumbersome and manual process, as I’ve more than 30-40 regions (1,000+ locations and 10,000+ products).
Your help will be highly appreciated.
ThanksTry this
DECLARE @Product TABLE (Region VARCHAR(50), ProductCode VARCHAR(50));
DECLARE @Location TABLE (Region VARCHAR(50), Location VARCHAR(50));
INSERT INTO @Product VALUES
('Dubai', 'Prod A'),
('Dubai', 'Prod B'),
('Dubai', 'Prod C'),
('Sharjah', 'Prod B'),
('Sharjah', 'Prod C'),
('Abu Dhabi', 'Prod A'),
('Abu Dhabi', 'Prod C')
INSERT INTO @Location VALUES
('Dubai', 'Loc 1'),
('Dubai', 'Loc 2'),
('Dubai', 'Loc 3'),
('Dubai', 'Loc 4'),
('Sharjah', 'Loc 11'),
('Sharjah', 'Loc 12'),
('Abu Dhabi', 'Loc 21')
SELECT
P.Region, L.Location, P.ProductCode
FROM @Product P
INNER JOIN @Location L
ON P.Region = L.Region
ORDER BY P.Region, L.Location
Krishnakumar S -
Printing the header of a report and checking the join statement...
Hi All,
This report of mne is working fine but there are things that i want to include: when i print this report i want it to display heading of which is in the html_top_of_page but it does not print it, i am not familiar with smart forms so i won't be able to use smart forms.If anyone can help me out i will really appreciated and will immediately reward points......please help me guys as the due date is very close...and please check the joins on the select statement, not sure whether i've joined the tables properly!
REPORT Z_ORDER_AUDIT_NEW.
TYPE-POOLS: SLIS.
LIST OF TABLES
Tables: vbak, likp, vbrk, kna1, vbrp, nast.
DEFINITION OF FIELDS *
DATA: itb_fieldcat TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
w_fieldcat TYPE slis_fieldcat_alv.
DATA: w_cnt LIKE sy-tabix.
DATA: lv_layout TYPE slis_layout_alv,
lv_tab_group TYPE slis_t_sp_group_alv,
lv_repid LIKE sy-repid,
lv_events TYPE slis_t_event,
lv_print TYPE slis_print_alv,
lv_user TYPE slis_formname VALUE 'USER_COMMAND'.
SELECTION SCREEN *
SELECT-OPTIONS:
s_lfdat FOR likp-lfdat,
s_imwrk FOR likp-imwrk.
DEFINITION OF AN INTERNAL TABLE *
DATA: Begin of i_ordertab occurs 0,
audat LIKE vbak-audat,
vbeln LIKE vbak-vbeln,
lfdat LIKE likp-lfdat,
erdat LIKE likp-erdat,
vbeln1 LIKE likp-vbeln,
vbeln2 LIKE vbrk-vbeln,
erdat1 LIKE vbrk-erdat,
kunrg LIKE vbrk-kunrg,
name1 LIKE kna1-name1,
regio LIKE vbrk-regio,
inco1 LIKE vbrk-inco1,
vrkme LIKE vbrp-vrkme,
ntgew LIKE vbrp-ntgew,
gewei LIKE vbrp-gewei,
volum LIKE vbrp-volum,
voleh LIKE vbrp-voleh,
netwr LIKE vbrk-netwr,
End of i_ordertab.
READ THE DATA *
SELECT vbakaudat vbakvbeln likplfdat likperdat likpvbeln vbrkvbeln
vbrkerdat vbrkkunrg kna1name1 vbrkregio vbrkinco1 vbrpvrkme
vbrpntgew vbrpgewei vbrpvolum vbrpvoleh vbrk~netwr
FROM likp join kna1 on likpkunnr EQ kna1kunnr
join vbrk on kna1kunnr EQ vbrkkunrg
join vbrp on vbrkvbeln EQ vbrpvbeln
join vbak on kna1kunnr EQ vbakkunnr
INTO i_ordertab
WHERE likp~lfdat IN s_lfdat
AND likp~imwrk IN s_imwrk.
APPEND i_ordertab.
ENDSELECT.
PERFORM STATEMENTS *
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_event.
PERFORM build_print.
PERFORM display_alv_report.
FORM build_fieldcatalog.
w_cnt = 1.
itb_fieldcat-fieldname = 'AUDAT'.
itb_fieldcat-seltext_m = 'Document date'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
itb_fieldcat-key = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'VBELN'.
itb_fieldcat-seltext_m = 'S/O number'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'LFDAT'.
itb_fieldcat-seltext_m = 'Deliv. date'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'ERDAT'.
itb_fieldcat-seltext_m = 'Del. Crt Date'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'VBELN1'.
itb_fieldcat-seltext_m = 'Delivery No.'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'VBELN2'.
itb_fieldcat-seltext_m = 'Invoice No.'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'ERDAT1'.
itb_fieldcat-seltext_m = 'Invoice Date'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'KUNRG'.
itb_fieldcat-seltext_m = 'Payer'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'NAME1'.
itb_fieldcat-seltext_m = 'Payer-Description'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'REGIO'.
itb_fieldcat-seltext_m = 'Region'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'INCO1'.
itb_fieldcat-seltext_m = 'Incoterms'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'VRKME'.
itb_fieldcat-seltext_m = 'Billed Quantity'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'NTGEW'.
itb_fieldcat-seltext_m = 'Net weight'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'GEWEI'.
itb_fieldcat-seltext_m = 'Weight Unit'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'VOLUM'.
itb_fieldcat-seltext_m = 'Volume'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'VOLEH'.
itb_fieldcat-seltext_m = 'VOLUME UNIT'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
w_cnt = w_cnt + 1.
itb_fieldcat-fieldname = 'NETWR'.
itb_fieldcat-seltext_m = 'Net Value'.
itb_fieldcat-col_pos = w_cnt.
itb_fieldcat-emphasize = 'X'.
itb_fieldcat-ref_tabname = 'VBRK' .
itb_fieldcat-ref_fieldname = 'NETWR' .
itb_fieldcat-do_sum = 'X' .
APPEND itb_fieldcat TO itb_fieldcat.
CLEAR itb_fieldcat.
ENDFORM.
FORM build_layout.
lv_layout-no_input = 'X'.
lv_layout-colwidth_optimize = 'X'.
lv_layout-totals_text = 'Totals'(201).
lv_layout-detail_popup = 'X'.
ENDFORM.
FORM build_event.
DATA i_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = lv_events[].
READ TABLE lv_events WITH KEY name = slis_ev_user_command
INTO i_event.
if sy-subrc = 0.
MOVE lv_user TO i_event-form.
APPEND i_event TO lv_events.
endif.
ENDFORM.
FORM build_print.
lv_print-reserve_lines = '2'.
lv_print-no_coverpage = 'X'.
ENDFORM.
*& FUNCTION ALV DISPLAY
FORM display_alv_report.
lv_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = lv_repid
I_CALLBACK_USER_COMMAND = slis_ev_user_command
I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE' " see FORM
I_CALLBACK_HTML_END_OF_LIST = 'END_OF_LIST_HTML' "see FORM
IS_LAYOUT = lv_layout
IT_FIELDCAT = itb_fieldcat[]
IT_SPECIAL_GROUPS = lv_tab_group
I_SAVE = 'X'
IT_EVENTS = lv_events
IS_PRINT = lv_print
TABLES
t_outtab = i_ordertab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
*& Form html_top_of_page
FORM html_top_of_page USING document TYPE REF TO cl_dd_document.
DATA: text TYPE sdydo_text_element.
CALL METHOD document->add_gap
EXPORTING
width = 100.
text = 'Cadbury: Daily Audit of Orders'.
CALL METHOD document->add_text
EXPORTING
text = text
sap_style = 'HEADING'.
CALL METHOD document->new_line.
CALL METHOD document->new_line.
CALL METHOD document->new_line.
text = 'User Name : '.
CALL METHOD document->add_text
EXPORTING
text = text
sap_emphasis = 'Strong'.
CALL METHOD document->add_gap
EXPORTING
width = 6.
text = sy-uname.
CALL METHOD document->add_text
EXPORTING
text = text
sap_style = 'Key'.
CALL METHOD document->add_gap
EXPORTING
width = 50.
text = 'Date : '.
CALL METHOD document->add_text
EXPORTING
text = text
sap_emphasis = 'Strong'.
CALL METHOD document->add_gap
EXPORTING
width = 6.
text = sy-datum.
CALL METHOD document->add_text
EXPORTING
text = text
sap_style = 'Key'.
CALL METHOD document->add_gap
EXPORTING
width = 50.
text = 'Time : '.
CALL METHOD document->add_text
EXPORTING
text = text
sap_emphasis = 'Strong'.
CALL METHOD document->add_gap
EXPORTING
width = 6.
text = sy-uzeit.
CALL METHOD document->add_text
EXPORTING
text = text
sap_style = 'Key'.
ENDFORM.
FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
DATA: ls_text TYPE sdydo_text_element,
l_grid TYPE REF TO cl_gui_alv_grid,
f(14) TYPE c VALUE 'SET_ROW_HEIGHT',
w_lines type i,
w_lines1(9) type n.
DESCRIBE TABLE i_ordertab LINES w_lines.
w_lines1 = w_lines.
concatenate: 'TOTAL NUMBER OF RECORDS SELECTED: ' w_lines1 INTO ls_text
SEPARATED BY space.
adds test (via variable)
CALL METHOD end->add_text
EXPORTING
text = ls_text
sap_emphasis = 'strong'.
adds new line (start new line)
CALL METHOD end->new_line.
*set height of this section
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->parent->parent->(f)
EXPORTING
id = 3
height = 14.
ENDFORM. "end_of_list_html.
--END OF THE REPORT--Hi
1. first remove the ENDSELECT..use INTO table itab or INTO CORRESPONDING fields, Since you are joining the more tables this will take lot of time.
2. You are just using two fields from LIKP as selection screen fields to fetch the so much data.
see the table linkings apartfrom KUNNR between the tables
LIKP-VBELN = LIPS-VBELN
LIPS-VGBEL = VBAK-VBELN and LIPS-VGPOS = VBAP-POSNR
and
VBRP-AUBEL = VBAK-VBELN and VBRP-AUPOS = VBAP-POSNR and
VBRP-VGBEL = LIKP-VBELN and VBRP-VGPOS = LIPS-POSNR
use the above links and code again.
<b>Reward points for useful Answers</b>
Regards
Anji -
The mara table in join statement takes 6 min...
hi all, i want to reduce the runtime for this statement...
it is taking nearly 6 min in the mara table itself...
plz help...
SELECT mara~matnr mara~mfrpn mara~prdha mchb~werks mchb~charg
mchb~lgort mchb~ersda mchb~clabs mchb~ceinm mchb~cspem
mchb~cretm
APPENDING CORRESPONDING FIELDS OF TABLE i_initstk FROM
( mara AS mara INNER JOIN mchb AS mchb
ON mara~matnr = mchb~matnr )
WHERE mara~prdha IN prodhier AND
mara~matnr IN partnbr AND
mchb~werks IN werks AND
( mchb~clabs GT 0 OR
mchb~cspem GT 0 OR
mchb~ceinm GT 0 OR
mchb~cretm GT 0 ) AND
mchb~lgort IN stloc AND
mchb~ersda < chkdate.
thanks a lot.Hi,
>
sakthi sri wrote:
> it is taking nearly 6 min in the mara table itself...
> thanks a lot.
how did you confirm that the time is spent on MARA and not on MCHB?
in order to help you we need more information:
mara~matnr IN partnbr AND
what is the content of partnbr?
With default indexes the matnr field from MARA is the only indexed field in your
where conditin that could be reached without gaps and equal conditions.
So the question is what is the content of this field?
The other ones are interesting as well, what is the content of these?
mchb~werks IN werks AND
mchb~lgort IN stloc AND
Kind regards,
Hermann
Maybe you are looking for
-
How to get a single row column from a viewobject in java?
I have a class file that goes out and gets a viewobject and sets its where clause this is it: vcRow = vc.createViewCriteriaRow(); vcRow.setAttribute("LogonId", "='" + strPcis_Login.toUpperCase() + "'"); vc.addElement(vcRow); vo.applyViewCriteria(vc);
-
Mail seems to add certain contacts to Address Book automatically
I'm not sure how it happens as I can't seem to find the option in Mail to turn it off, but it seems as though Mail wants to automatically add contacts into my Address Book. At least I think it's Mail. I don't think iPhone would do that, would it? Any
-
Discoverer Must Have Features...
How about just making the the date select / calander tool available for parameters in Viewer similar to the way it works in Plus??? That this near the top of complaints I get from my users... The other big category is steamlining the security managem
-
'Rocky' video playback in Slideshow mode (update does not help)
After importing a video clip in Aperture everything is ok. I can play it back etc and everything goes smooth. However as soon as I add this clip in a slideshow and try to play it, it's goes very rocky/jumpy skipping frames. What I want is the followi
-
Since upgrading to os x 10.9.2 i can't receive my email
since upgraging to os x 10.9.2 i cant receive my email, it was working fine before upgrade now says my user id or password is wrong