Reading data from BSEG table with Non-key fields in where clause
Hi All,
I have to read data from BSEG table based on WBS element field (PROJK). As I'm not passing key fields to WHERE clause system couldnt run the select statement. Since BSEG is a cluster table I cant even create secondary index on PROJK field.
Could you please tell me, how to improve its performance.
Regards
Jaker.
SELECT bukrs
belnr
gjahr
shkzg
dmbtr
hkont
lifnr
matnr
werks
menge
meins
ebeln
FROM bseg
INTO TABLE it_bseg
PACKAGE SIZE 10
FOR ALL ENTRIES IN it_final
WHERE bukrs EQ it_final-bukrs
AND belnr EQ it_final-belnr
AND gjahr EQ it_final-gjahr
AND buzei EQ it_final-buzei
AND hkont EQ it_final-hkont
AND werks IN s_werks.
By using package and fetch from BSEG table. gathering all other information to a final internal table.This will reduce the hit to database.And also try to put that data in hashed internal table which is it_bseg....then definetly improve the performance.
<REMOVED BY MODERATOR>
Dara.
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 12:47 PM
Similar Messages
-
Data from two tables with no key fields
Hi Friends,
I want to retrieve data from mara and mseg tables,matnr from mara and menge from mseg but problem is there is no key fields
from these two tables how can i retrieve the data from these two tables?
regards,
bikashHi,
You need to have a common field between 2 tables if you want to put a join between them.
Or otherwise,
Find the check table of the primary keys of the tables.
Try to find the common fields from one of the check tables of the primary keys.
Example,
If you want to join tables A and B.
Both tables don't contain common fields.
A has primary key fields X and Y.
go to check table of X or Y.
Let check table of X is C.
check any field in C which are exist in table B.
Join tables A and C.
Based on this pick the data from B.
Regards,
Prashant -
Reading Data from a Table With an Expert
Hi all - I'm trying to write an Expert in OWB that would read data from a table and create a new table based on that information. I have the table creation part down, but how can I read data from a table with an Expert? From what I've read, Experts only deal with metadata, and there is no mechanism in Experts to actually read data in the tables. Does OraTcl work in Experts? Has anyone ever came across this problem, and if so, how did you solve it? Thanks in advance for your time! - Don
Hi Don
Can also use Java and JDBC from within Tcl, see the routines in this file below, take modify or whatever;
http://blogs.oracle.com/warehousebuilder/ombora.tcl
source <dir>\ombora.tcl
set g_user scott
set g_upwd zzzzzz
set g_hostname localhost
set g_port 1521
set g_srvname ora111
oraconnect $g_user $g_upwd $g_hostname:$g_port:$g_srvname
oraselect "select * from emp" ""
As well as dumping the results to stdout (you probably want to comment that part out and change any other part you don't like), g_res is a ResultSet object you can use to do whatever.
Cheers
David -
Hi,
I met a problem.
How to read data from cluster tables using:
b2-key-pernr = 20.
b2-key-pabrj = 2006.
b2-key-pabrp = 09.
b2-key-cltyp = '1'.
import saldo from database pcl2(b2) id b2-key.
the problem is that the sy-subrc is always 4, could anyone help me?
thank you very much!Hi,
Import and export to database is used in two programs and not in the same program.
<b>ZPROGRAM1.</b>
tables : indx.
Data : SALDO type i,
indxkey LIKE indx-srtfd VALUE 'ZAB1'.
indx-aedat = sy-datum.
indx-usera = sy-uname.
indx-pgmid = sy-repid.
EXPORT SALDO TO DATABASE indx(zc) ID indxkey.
In another program,
<b>ZPROGRAM2.</b>
tables : indx.
Data : SALDO type i,
indxkey LIKE indx-srtfd VALUE 'ZAB1'.
indx-aedat = sy-datum.
indx-usera = sy-uname.
indx-pgmid = sy-repid.
IMPORT SALDO FROM DATABASE indx(zc) ID indxkey.
Best regards,
Prashant -
How to read Data from ZL table
Can someone give me function module or sample code to read data from ZL table in B2 cluster
Edited by: Saurabh Desai on Jan 13, 2010 9:13 PMYou wanted to extract data, ZL table to precise, from B2 cluster, is that right?
For this the snipped I gave you can be used.
First you need an inlcude with appropriate declarations
INCLUDE rpc2b201. "-> here b2 structure, ZL table are declared
Now you provide key for the cluster which is what below does
b2-key-pernr = "ee number
b2-key-pabrj = "year to extract data for
b2-key-pabrp = "month to extract data for
b2-key-cltyp = 1.
Now all you need is to extract ZL table form B2 cluster
IMPORT zl "get ZL table
FROM DATABASE pcl2(b2) "from cluster B2
ID b2-key. "for this key
That's it. Now you have correct data in ZL table which you can process further.
Hope now it is clear.
Regards
Marcin -
Hi,
I never read data from Cluster table like BSEG, is there any precautions to be taken while reading data from it? as it contains voluminous data
please suggest.
regards,
Pra<b>Cluster Tables (BSEG,BSEC)</b>
Should be accessed via primary key - very fast retrieval otherwise very slow
No secondary indexes
Select * is Ok because all columns retrieved anyway. Performing an operation on multiple rows is more efficient than single row operations. Therefore you still want to select into an internal table. If many rows are being selected into the internal table, you might still like to retrieve specific columns to cut down on the memory required.
Statistical SQL functions (SUM, AVG, MIN, MAX, etc) not supported
Can not be buffered
SELECT bukrs belnr gjahr blart budat monat
tcode bvorg waers kursf hwaer
FROM bkpf
INTO TABLE it_bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr
AND monat IN s_monat
AND tcode IN ('CO88', 'KO88', 'KK87')
AND awtyp EQ c_ref_pro. "'AUAK'
Pick up the corresponding line items from BSEG
SELECT bukrs belnr gjahr dmbtr wrbtr ktosl
zuonr hkont matnr werks menge
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
AND belnr = it_bkpf-belnr
AND gjahr = it_bkpf-gjahr
AND werks IN s_werks
AND ktosl = c_tr_key. "'PRD'
<b>BSEG Access</b>
BSAD Accounting: Secondary index for customers (cleared items)
BSAK Accounting: Secondary index for vendors (cleared items)
BSAS Accounting: Secondary index for G/L accounts (cleared items)
BSID Accounting: Secondary index for customers
BSIK Accounting: Secondary index for vendors
BSIM Secondary Index, Documents for Material
BSIS Accounting: Secondary index for G/L accounts -
Cartesian of data from two tables with no matching columns
Hello,
I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
I am thinking about something like:
for $COUNTRY in ns0: COUNTRY ()
for $PROD in ns1:PROD()
return <Results>
<COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
<PROD> {fn:data($PROD/PROD_NAME)} </PROD>
</Results>
And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
What I’ve noticed also is that when I add something like:
where COUNTRY_NAME != PROD_NAME
everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
So the question is – what’s the suggested approach for such queries?
Thanks,
Leszek
Edited by xnts at 11/19/2007 10:54 AMWhich in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so. -
Reading Data from Internal Table
Hi,
Can anyone please tell me how to read data from Internal Tables in the Event Handler without using the Select statement OnInitialization?
Thanks,
GauravHi Siddhartha,
Can you tell me the problem in my code. I tried to work on the way you suggested. Though I have not finished with the coding, I just wanted to know whether I am going in the direction or not.
I have declared the the structure in Type Defination as
TYPES: BEGIN OF TEST_STRUC,
BEGDA TYPE BEGDA,
ENDDA TYPE ENDDA,
END OF TEST_STRUC.
TYPES: TEST_TAB_TYPE TYPE TABLE OF TEST_STRUC.
In the Event Handler, I have added the following code on OnInputProcessing:
event handler for checking and processing user input and
for defining navigation
DATA TEST_INFO LIKE LINE OF TEST_TAB.
DATA: MYTAB6 TYPE TABLE OF PA0006,
MYTAB6_WA LIKE LINE OF MYTAB6.
REFRESH TEST_TAB.
CLEAR TEST_INFO.
MYTAB6_WA-BEGDA = REQUEST->GET_FORM_FIELD( STARTDATE ).
MYTAB6_WA-ENDDA = REQUEST->GET_FORM_FIELD( ENDDATE ).
IF EVENT->NAME EQ 'button'
AND EVENT->SERVER_EVENT EQ 'click'.
LOOP AT MYTAB6 INTO MYTAB6_WA.
TEST_INFO-BEGDA = MYTAB6_WA-BEGDA.
TEST_INFO-ENDDA = MYTAB6_WA-ENDDA.
ENDLOOP.
APPEND TEST_INFO TO TEST_TAB.
CLEAR TEST_INFO.
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'begda' ).
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'endda' ).
NAVIGATION->GOTO_PAGE( 'MyBSP2.htm').
ENDIF.
P.S. MyBSP2.htm is my next page.
Thanks,
Gaurav -
Do I have to use lock when I am reading data from a table
Hi,
When i am reading data from a table , do I have to set a lock on that table .
Is it necessary for us to set the lock on a table when I am reading data from the table.
When I am updating the table , do I have to set a lock on the table ?
If yes, then what sort of lock-read lock,write lock or shared lock?
Regards,
Sushanth H.S.check it out,
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
You have to use these function module in your program.
check this link for example.
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
if sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
1. enque_lockobject
1. deque_lockobject
before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Reward if helpful -
Select max date from a table with multiple records
I need help writing an SQL to select max date from a table with multiple records.
Here's the scenario. There are multiple SA_IDs repeated with various EFFDT (dates). I want to retrieve the most recent effective date so that the SA_ID is unique. Looks simple, but I can't figure this out. Please help.
SA_ID CHAR_TYPE_CD EFFDT CHAR_VAL
0000651005 BASE 15-AUG-07 YES
0000651005 BASE 13-NOV-09 NO
0010973671 BASE 20-MAR-08 YES
0010973671 BASE 18-JUN-10 NOHi,
Welcome to the forum!
Whenever you have a question, post a little sample data in a form that people can use to re-create the problem and test their ideas.
For example:
CREATE TABLE table_x
( sa_id NUMBER (10)
, char_type VARCHAR2 (10)
, effdt DATE
, char_val VARCHAR2 (10)
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0000651005, 'BASE', TO_DATE ('15-AUG-2007', 'DD-MON-YYYY'), 'YES');
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0000651005, 'BASE', TO_DATE ('13-NOV-2009', 'DD-MON-YYYY'), 'NO');
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0010973671, 'BASE', TO_DATE ('20-MAR-2008', 'DD-MON-YYYY'), 'YES');
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0010973671, 'BASE', TO_DATE ('18-JUN-2010', 'DD-MON-YYYY'), 'NO');
COMMIT;Also, post the results that you want from that data. I'm not certain, but I think you want these results:
` SA_ID LAST_EFFD
651005 13-NOV-09
10973671 18-JUN-10That is, the latest effdt for each distinct sa_id.
Here's how to get those results:
SELECT sa_id
, MAX (effdt) AS last_effdt
FROM table_x
GROUP BY sa_id
; -
hi gurus;
I want to read data from VBFA table nd pass its VBELV to VBAK table to get VBAK values, Iam using FM SD_DOCUMENT_FLOW_GET ND RV_ORDER_FLOW_INFORMATION, BUT i am not getting desire result. WHEN iam using FM SD_DOCUMENT_FLOW_GET, it will give result only for last row of data, its not considering body part, so tell me how to used this FM properly.
data: l_docflow type tdt_docflow.
data lw_docflow type tds_docflow OCCURS 1 WITH HEADER LINE .
SELECT VBELN KNUMV BUKRS KUNRG REGIO NETWR FKSTO FKDAT FKART INTO CORRESPONDING FIELDS OF TABLE T_VBRK
FROM VBRK WHERE BUKRS IN P_BUKRS AND FKDAT IN P_FKDAT AND VKORG IN P_VKORG AND REGIO = '07'
ORDER BY VBELN KNUMV.
SORT T_VBRK BY vbeln.
LOOP AT T_VBRK.
IF T_VBRK-FKART = 'F2' OR T_VBRK-FKART = 'YF2' OR T_VBRK-FKART = 'ZF2' OR
T_VBRK-FKART = 'ZG2' OR T_VBRK-FKART = 'ZL2' OR T_VBRK-FKART = 'YG2' OR T_VBRK-FKART = 'YL2' .
IF T_VBRK-FKSTO IS INITIAL.
CALL FUNCTION 'SD_DOCUMENT_FLOW_GET'
EXPORTING
IV_DOCNUM = T_VBRK-vbelN
IV_ITEMNUM =
IV_ALL_ITEMS =
IV_SELF_IF_EMPTY = ' '
IMPORTING
ET_DOCFLOW = l_docflow
LOOP AT l_docflow INTO lw_docflow .
IF lw_docflow-vbtyp_V = 'C' OR lw_docflow-vbtyp_V = 'K' OR lw_docflow-vbtyp_V = 'L' OR lw_docflow-vbtyp_V = 'E'.
T_VBFA-vbelv = lW_docflow-vbelv.
T_VBFA-VBELN = lW_docflow-VBELN.
T_VBFA-vbtyp_V = lW_docflow-vbtyp_V.
APPEND t_vbfa.
endif.
endloop.
ENDIF.
endloop.
loop at t_vbfa.
if t_vbfa-vbtyp_V = 'C' OR t_vbfa-vbtyp_V = 'K' OR t_vbfa-vbtyp_V = 'L' OR t_vbfa-vbtyp_V = 'E' .
SELECT VBELN BSTNK BSTDK FROM VBAK INTO CORRESPONDING FIELDS OF TABLE T_VBAK FOR ALL ENTRIES IN T_VBFA
WHERE VBELN = T_VBFA-VBELV .
endif.
ENDLOOP.Hello
Use the below function module
RV_ORDER_FLOW_INFORMATION pass the type as C and pass the number.You will get all the flow.
SELECT VBELN KNUMV BUKRS KUNRG REGIO NETWR FKSTO FKDAT FKART INTO CORRESPONDING FIELDS OF TABLE T_VBRK FROM VBRK WHERE BUKRS IN P_BUKRS AND FKDAT IN P_FKDAT AND VKORG IN P_VKORG AND REGIO = '07'
ORDER BY VBELN KNUMV.
SORT T_VBRK BY vbeln.
LOOP AT T_VBRK.
IF T_VBRK-FKART = 'F2' OR T_VBRK-FKART = 'YF2' OR T_VBRK-FKART = 'ZF2' OR
T_VBRK-FKART = 'ZG2' OR T_VBRK-FKART = 'ZL2' OR T_VBRK-FKART = 'YG2' OR T_VBRK-FKART = 'YL2' .
IF T_VBRK-FKSTO IS INITIAL.
i_vbco6-vbeln = t_vbrk-vbeln.
CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION'
EXPORTING
AUFBEREITUNG = '2'
BELEGTYP = ' '
COMWA = i_vbco6
NACHFOLGER = 'X'
N_STUFEN = '50'
VORGAENGER = 'X'
V_STUFEN = '50'
IMPORTING
BELEGTYP_BACK =
TABLES
VBFA_TAB = t_vbfa
EXCEPTIONS
NO_VBFA = 1
NO_VBUK_FOUND = 2
OTHERS = 3
endif.
ENDIF.
endloop.
loop at t_vbfa.
if t_vbfa-vbtyp_V = 'C' OR t_vbfa-vbtyp_V = 'K' OR t_vbfa-vbtyp_V = 'L' OR t_vbfa-vbtyp_V = 'E' .
*clear t_vbfa.
SELECT VBELN BSTNK BSTDK FROM VBAK INTO CORRESPONDING FIELDS OF TABLE T_VBAK FOR ALL ENTRIES IN T_VBFA WHERE VBELN = T_VBFA-VBELV .
endif.
ENDLOOP.
In case of any more help is required do let me know
Regards,
Nabheet Madan -
Read data from 2 tables.
Hello everyone,
I created a SQL database in phpMyAdmin. It contains 2 tables.
'Woninginformatie' and 'Makelaars'.
I use the next SQL query in my PHP file to read from the
database:
SELECT DISTINCT * FROM Woninginformatie
INNER JOIN Makelaars ON Woninginformatie.ID_mk =
Makelaars.ID_mk
WHERE Huiscode = $huiscode"
The query works correct and I get all the fields from both
tables. Anyway, in Flash I can only read out the information in the
table 'Woninginformatie'.
I use these kind of codes to read from the database:
eigendomssituatie =
gegevens.childNodes[0].childNodes[24].firstChild.nodeValue;
How can I also read data from the second table?you can't read data from the 2nd table because because you
have a table issue, php issue or you can read data from the table
but are having trouble getting those data into flash? are you using
echo to return data to flash? -
Failed to read data from Lock tables
Hi,
When i trying to update data using T_CODE j1i8. I am getting message (Failed to read data from Lock tables ) but where as my database tables are not been locked. can anyone plz help me out.
Regards,
AnaveerHi
Probably some other transation is modifying the Database table you are using & it may have locke the table using FOR UPDATE stmt.
Using Deque_all FM module you can remove the locks
Thanks
Sandeep
Reward if helpful -
Read data from ODS table using value mapping
hi all;
can anyone help on how to read data from ODS table using value mappingMudit,
Take a look at this blog,
<a href="/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler">DB Lookup in Mapping</a>
Regards,
Bhavesh -
How to read from an internal table with multiple key fields.
Hi All!!
I want to read from an internal table having keys as k1,k2,k3.
How can I use read statement to read an entry having this as the key fields.
Thanks in adavance..
Prabhas Jhahi there
use:
sort itab by K1 K2 K3.
read table itab into wa with key K1 = value 1
K2 = value2
K3 = value 3
BINARY SEARCH.
where:
itab is ur internal table
wa is the work area with the same line type as the itab
cheers
shivika
Maybe you are looking for
-
Error message when trying to sign on mac
I sent a digitally signed contract to a client for her electronic signature. I created the document on a PC and am able to sign it electronically (as a different user) on a PC. When she tries to sign it on a mac, she gets an error message. Since I
-
Error in ESS Personal information on deployment of ess/per.ear
Dear Gurus, we have configure NWDI on our development server. we successfully checkout ess/in/bank application and made changes to a lable UI element to notice it on our server. since it refers to ess/per application, we check-out that too and deploy
-
Who's trying to break into my account?
Is anyone else getting responses from iTunes, when you did not send in a request, for help resetting your password. I got several responses, and today I received one that whoever wasn't able to answer my security questions. Someone's really trying to
-
Counting rule doesnot exist.
Hello, When I try to enter time I'm getting thefollowing error after I press enter "counting rule 08/2/00/.. doesnot exist". In Data Entry Area I'm entering the details for Activity type, Rec. order, Attendance/Absence Type and the hours for the week
-
My iPad stop charging today and I don't know why. It's not my plug or cord because it charges my iPad. I've even tried turning it off and resetting it but it still won't charge. What wrong with it? When I plug it to the computer it doesn't get detect