Fetch the data from two tables
hell all
i want to fetch the data from two tables, one is from internal table and another one is data base table. what syntax i have to use either FOR ALL ENTRIES or INNER JOIN?
hi
Use FOR ALL ENTRIES.
see the sample code
select * into table tvbrk from vbrk
where fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM' , 'ZVED',
'S1')
and erdat in so_erdat
and kunag in s_kunag.
erdat in so_erdat
and fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM').
if not tvbrk is initial.
select * into table t_zregion from zregion
for all entries in tvbrk
where country = tvbrk-land1
and region = s_regio.
endif.
thanks
sitaram
Similar Messages
-
To Select the data from two table one is transp table and onther is cluster
Hi All,
I want to select the data from two tables
Here i am giving with an example.
Fileds: kunnr belnr from bseg. table bseg
fields: adrnr from kna1 table: kna1.
Know i want to put these into one internal table based on kunnr and belnr.
Thanks in advance.
RameshHi,
U cant use joins on cluster table and BSEG is a cluster table so use FOR ALL ENTRIES for taht
refer this code
*& Form sub_read_bsak
text
--> p1 text
<-- p2 text
FORM sub_read_bsak.
*--Select data from BSAK Table
SELECT lifnr
augdt
augbl
gjahr
belnr
xblnr
blart
dmbtr
mwskz
mwsts
sgtxt
FROM bsak
INTO CORRESPONDING FIELDS OF TABLE it_bsak
WHERE belnr IN s_belnr
AND augdt IN s_augdt.
IF sy-subrc EQ 0.
*--Sort table by accounting document and vendor number
SORT it_bsak BY belnr lifnr.
ENDIF.
ENDFORM. " sub_read_bsak
*& Form sub_read_bseg
text
--> p1 text
<-- p2 text
FORM sub_read_bseg.
IF NOT it_bsak[] IS INITIAL.
*--Select data from BSEG table
SELECT belnr
gjahr
shkzg
kostl
hkont
ebeln
ebelp
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bsak
WHERE belnr EQ it_bsak-belnr
AND gjahr EQ it_bsak-gjahr
AND shkzg EQ 'S'.
IF sy-subrc EQ 0.
*--Sort table by accounting document
SORT it_bseg BY belnr.
ENDIF.
ENDIF.
ENDFORM. " sub_read_bseg -
How to fetch the data from databse table and get the required output
Hi,
I have made a project that connects CEP to database table but i m getting some problem in fetching the data from database.
From the following code :
If the where condition is removed then the application runs fine but i am still not able to fetch the data from the table because it is not showing any output.
Can anyone please suggest me that how to write WHERE statement correctly and how i will be able to see the output.
Following is the config.xml for processor:
======================================
<?xml version="1.0" encoding="UTF-8"?>
<wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
xmlns:jdbc="http://www.oracle.com/ns/ocep/config/jdbc">
<processor>
<name>JDBC_Processor</name>
<rules>
<query id="q1"><![CDATA[
SELECT STOCK.SYMBOL as symbol, STOCK.EXCHANGE as exchange
FROM ExchangeStream [Now] as datastream, STOCK
WHERE datastream.SYMBOL = datastream.SYMBOL ]]></query>
</rules>
</processor>
<jms-adapter>
<name>JMS_IN_Adapter</name>
<jndi-provider-url>t3://CHDSEZ135400D:7001</jndi-provider-url>
<destination-jndi-name>jms.TestKanikaQueue</destination-jndi-name>
<user>weblogic</user>
<password>welcome1</password>
</jms-adapter>
</wlevs:config>
Following is the assembly file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:wlevs="http://www.bea.com/ns/wlevs/spring" xmlns:jdbc="http://www.oracle.com/ns/ocep/jdbc"
xmlns:spatial="http://www.oracle.com/ns/ocep/spatial"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.bea.com/ns/wlevs/spring
http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd
http://www.oracle.com/ns/ocep/jdbc
http://www.oracle.com/ns/ocep/jdbc/ocep-jdbc.xsd
http://www.oracle.com/ns/ocep/spatial
http://www.oracle.com/ns/ocep/spatial/ocep-spatial.xsd">
<wlevs:event-type-repository>
<wlevs:event-type type-name="StockEvent">
<wlevs:properties>
<wlevs:property name="SYMBOL" type="byte[]" length="16" />
<wlevs:property name="EXCHANGE" type="byte[]" length="16" />
</wlevs:properties>
</wlevs:event-type>
<wlevs:event-type type-name="ExchangeEvent">
<wlevs:class>com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent</wlevs:class>
</wlevs:event-type>
<wlevs:event-type type-name="StockExchangeEvent">
<wlevs:properties>
<wlevs:property name="symbol" type="byte[]" length="16" />
<wlevs:property name="price" type="byte[]" length="16" />
<wlevs:property name="exchange" type="byte[]" length="16" />
</wlevs:properties>
</wlevs:event-type>
</wlevs:event-type-repository>
<bean id="readConverter" class="com.bea.wlevs.adapter.example.JDBC_CEP.Adapter_JDBC" />
<bean id="outputJDBCBean" class="com.bea.wlevs.bean.example.JDBC_CEP.OutputBean_JDBC">
</bean>
<wlevs:adapter id="JMS_IN_Adapter" provider="jms-inbound">
<wlevs:listener ref="ExchangeStream" />
<wlevs:instance-property name="converterBean"
ref="readConverter" />
</wlevs:adapter>
<wlevs:processor id="JDBC_Processor" advertise="true">
<wlevs:listener ref="OutputChannel" />
<wlevs:table-source ref="STOCK" />
</wlevs:processor>
<wlevs:channel id="ExchangeStream" event-type="ExchangeEvent" advertise="true">
<wlevs:listener ref="JDBC_Processor" />
</wlevs:channel>
<wlevs:channel id="OutputChannel" event-type="StockExchangeEvent"
advertise="true">
<wlevs:listener ref="outputJDBCBean" />
</wlevs:channel>
<wlevs:table id="STOCK" event-type="StockEvent"
data-source="StockDs" table-name="STOCK" />
<wlevs:table id="STOCK_EXCHANGE" event-type="StockExchangeEvent"
data-source="StockDs" table-name="STOCK_EXCHANGE" />
</beans>
ExchangeEvent.java:
package com.bea.wlevs.event.example.JDBC_CEP;
public class ExchangeEvent {
public String SYMBOL;
public String symbol;
public String exchange;
public ExchangeEvent() {
public String getSYMBOL() {
return SYMBOL;
public void setSYMBOL(String sYMBOL) {
SYMBOL = sYMBOL;
public String getSymbol() {
return symbol;
public void setSymbol(String symbol) {
this.symbol = symbol;
public String getExchange() {
return exchange;
public void setExchange(String price) {
this.exchange = price;
Adapter Class:
package com.bea.wlevs.adapter.example.JDBC_CEP;
import com.bea.wlevs.adapter.example.JDBC_CEP.MyLogger;
import com.bea.wlevs.adapters.jms.api.InboundMessageConverter;
import java.text.DateFormat;
import java.util.Date;
import com.bea.wlevs.adapters.jms.api.MessageConverterException;
import com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Adapter_JDBC implements InboundMessageConverter{
@SuppressWarnings("unchecked")
public List convert(Message message) throws MessageConverterException, JMSException {
Random rand = new Random();
int unique_id = rand.nextInt();
DateFormat dateFormat;
dateFormat = DateFormat.getTimeInstance();
dateFormat.format(new Date());
MyLogger.info(unique_id + " CEP Start Time is: " + dateFormat.format(new Date()));
System.out.println("Message from the Queue is :"+ message);
TextMessage textMessage = (TextMessage) message;
String stringMessage = textMessage.getText().toString();
System.out.println("Message after getting converted into String is :"+ stringMessage);
String[] results = stringMessage.split(",\\s*"); // split on commas
ExchangeEvent event1 = new ExchangeEvent();
event1.setSYMBOL(results[0]);
List events = new ArrayList(2);
events.add(event1);
return events;
Output Bean Class :
package com.bea.wlevs.bean.example.JDBC_CEP;
import com.bea.wlevs.ede.api.StreamSink;
import com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent;
import com.bea.core.datasource.DataSourceService;
public class OutputBean_JDBC implements StreamSink{
public void onInsertEvent(Object event) {
if (event instanceof ExchangeEvent) {
ExchangeEvent cacheEvent = (ExchangeEvent) event;
System.out.println("Symbol is: " + cacheEvent.getSymbol());
System.out.println("Exchange is: " + cacheEvent.getExchange());
System.out.println(DataSourceService.class.getClass());
Kindly let me know if you need further info.Do you have StockDs configured in your server config.xml?
I think the query should look more like this:
SELECT stocks.SYMBOL, stocks.EXCHANGE
FROM STOCK as stocks, ExchangeStream [Now] as datastream WHERE stocks.SYMBOL = datastream.SYMBOL
Thanks
andy -
Joining the data from two Tables
I create a table with six months date from Jan to Jun. Another table with July trough Sept.
Now I want one table in which I am going to at the end of the year have all 2007 fiscal data.
I do not want to restore them ever back to the components. How do I do this?If I understand you correctly, I think you merely want to enlarge the first table enough to accommodate the data from the second table. Then select the cells in the second table and copy and paste them into the newly created space in the first table. Ask if you need more detail instructions on how to do this.
-
Hi how can i fetch the data from tree table
Hi i am designing a UI in which i am creating a java tree table as on sun java site http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html now i have to fetch the perticular column value on the mouse click.I have implemented mouse listener and on mouse clicked event I tried :
Object obj=tableInputOutputEntities.getValueAt(tableInputOutputEntities.getSelectedRow(),tableInputOutputEntities.getSelectedColumn());
as we usually do in case on JTable but it is also throwing null exception. Again after going through forum i found some code to get the current row and current column selected values and tried with getValueAt(int,int) method but still it is throwing nulll pointer exception. Please help me out.
public void mouseClicked(MouseEvent e)
Point p = e.getPoint();
int row = treeTable.rowAtPoint(p);
int column = treeTable.columnAtPoint(p);
Object obj=treeTable.getValueAt(row,column);
System.out.println("Object value: "+obj.toString());
}Regards
NaxyHello Kevin,
The question to use which method depend on your detail requirements. If you use BAPI, you need to find which Bapi can provide the data you want. Bapi normally use as a function called by external system. So you need to develop an external program like VB/Java to call this Bapi and move it to SQL. LSMW is use when you want to upload data from an external system to SAP. So it does not serve your requirement. Idoc can be use to export data to an external system. Again like Bapi, you need to find what Idoc can provide the data you want. However, it does not any programming from the external system. If I were you, based on your requirements, I think writing an Abap program that read the data you want and download it to NT/SQL server will be faster and easier. -
Fetch the data from three tables
hi
i have three table HR,plan ,voidplan
HR table
rep_id name
1111 shyam
2222 kavi
3333 snaga
PLAN table
id rep_id name status
1 1111 shyam approved
2 2222 kavi pending
VOID PLAN table
id rep_id name status
1 1111 shaym approved
i got the row which is same in two table(HR and PLAN) using the query
select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
so the output is
rep_id
1111
now i need the solution to retrieve the rep from voidplan+plan table
the result should be like this
rep_id
1111(from plan and hr)
1111(void plan)
please help me to solve this problem
regards,
vally.show about UNION ALL
select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
union all
select rep_id from void_plan
this will get only the rows that join and then ALL rows from void_plan (but I suspect this isn't what you want?)
maybe you only want rows from void_plan that are returned from the first query
select rep_id from void_plan v
where v.rep_id in (select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
) -
From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?
Hi,
Use NVL or COALESCE:
NVL (col_a, col_b)
Returns col_a if col_a is not NULL; otherwise, it returns col_b.
Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Data from two tables in the same row in XML transformation
Hi,
I am using XML transformation for generating excel file which is to besent as email attachment.
Here I want to display the data from two internal tables in the same row in the excel. .I am using <tt:loop ref=".<table name>"> ... </tt:loop> for looping through the table. Can I loop two table simultaneously ? In that case how will I specify the fields in each table . Some of the fields in two tables are of same name and type.
Please help...
Thanks,
JissaHello Brian,
Thank you for your answer. It is approach I will use, I think. However let me ask: Would it be possible to have a Version in this layout, too? I mean to see, which value comes from Version A and which comes from Version B? Something like this:
Calendar Month Version Sales Amount
2011.01 B 200
2011.02 B 300
2011.03 A 260
2011.04 A 230
2011.05 A 200
A -
Fetch the data from the tables in the SQL 2005 server to sap R/3.
Hi Experts,
We need to fetch the data from the tables in the SQL 2005 server to sap R/3.
Please explain which will be the best approach to fetch the same and how to do it. Sample program can greatly help.
<< Please do not offer points >>
Regards,
Shobana K
Edited by: Rob Burbank on Sep 21, 2010 2:36 PMHi,
Try NATIVE SQL statements in your abap code otherwise you can try to establish jdbc connection from ABAP program.
search in SDN for samples!
Suresh -
Populate ADF Rich Table taking data from two tables of database
Hi,
Can anyone please guide me as to how I can populate ADF Rich Table taking data from two tables A and B of a database.
The condition is
I want to fetch row 1 from table A and populate into ADF Rich Table at row 1
then
I want to fetch row 1 from table B and populate into ADF Rich Table at row 2
and so on....
Many thanks for your help..
Regards,
RohitThe better place where you will learn:
http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcquerying.htm -
Fetch the values from internal table inside an internal table (urgent!!)
data : BEGIN OF PITB2_ZLINFO occurs 0,
BEGDA LIKE SY-DATUM,
ENDDA LIKE SY-DATUM,
PABRJ(4) TYPE N, "Payroll Year
PABRP(2) TYPE N, "Pay. Period
ZL LIKE PC2BF OCCURS 0,
END OF PITB2_ZLINFO.
I have a internal table like this,
How to Fetch the values from internal table inside an internal table.
Kindly Help me on this..
Regards,
Ram.Hi,
Try this....
Loop at PITB2_ZLINF0.
Loop at PITB2_ZLINF0-ZL.
endloop.
Endloop.
Thanks...
Preetham S -
Insert the data into two tables at a time.
Hi ,
i have these two tables
create table [dbo].[test1](
[test1_id] [int] identity(1,1) primary key,
[test2_id] [int] not null
create table [dbo].[test2](
[test2_id] [int] identity(1,1) primary key,
[test1_id] [int] not null
alter table [dbo].[test1]
add constraint [fk_test1_test2_id] foreign key([test2_id])
references [dbo].[test2] ([test2_id])
alter table [dbo].[test2] add constraint [fk_test2_test2_id] foreign key([test1_id])
references [dbo].[test1] ([test1_id])
I want to insert the data into two tables in one insert statement. How can i do this using T-SQL ?
Thanks in advance.You can INSERT into both tables within one Transaction but not in one statement. By the way, you would need to alter your dbo.Test1 table to allow null for first INSERT test2_id column
See sample code below:
CREATE TABLE #test1(test1_ID INT IDENTITY(1,1),test2_id INT NULL)
CREATE TABLE #test2(test2_ID INT IDENTITY(1,1),test1_ID INT)
DECLARE @Test1dentity INT
DECLARE @Test2dentity INT
BEGIN TRAN
-- Insert NULL as test2_ID value is unknown
INSERT INTO #test1(test2_ID)
SELECT NULL;
-- get inserted identity value
SET @Test1dentity = SCOPE_IDENTITY();
INSERT INTO #test2(test1_ID)
SELECT @Test1dentity;
-- get inserted identity value
SET @Test2dentity = SCOPE_IDENTITY();
-- Update test1 table
UPDATE #test1
SET test2_ID = @Test2dentity
WHERE test1_ID = @Test1dentity;
COMMIT
SELECT * FROM #test1;
SELECT * FROM #test2;
-- Drop temp tables
IF OBJECT_ID('tempdb..#test1') IS NOT NULL
BEGIN
DROP TABLE #test1
END
IF OBJECT_ID('tempdb..#test2') IS NOT NULL
BEGIN
DROP TABLE #test2
END
web: www.ronnierahman.com -
How to upload the data from two sheets in one excel into SAP
Hi experts,
My requirement is to upload the data from two sheets in an excel into an internal table.How can this be achieved.Is some OLE application has to be used?
Thanks
AbhishekHi
see this program will upload excel file to application.
*& Report ZSD_EXCEL2
REPORT ZSD_EXCEL2.
types: begin of ttab ,
fld1(30) type c,
fld2(30) type c,
fld3(30) type c,
fld4(30) type c,
fld5(30) type c,
end of ttab.
data: itab type table of ttab with header line.
selection-screen skip 1.
parameters: p_file type localfile default
'C:\test.xls'.
selection-screen skip 1.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
clear itab. refresh itab.
perform upload_data.
loop at itab.
write:/ itab-fld1, itab-fld2, itab-fld3, itab-fld4, itab-fld5.
endloop.
* Upload_Data
form upload_data.
data: file type rlgrap-filename.
data: xcel type table of alsmex_tabline with header line.
file = p_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '5000'
tables
intern = xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
loop at xcel.
case xcel-col.
when '0001'.
itab-fld1 = xcel-value.
when '0002'.
itab-fld2 = xcel-value.
when '0003'.
itab-fld3 = xcel-value.
when '0004'.
itab-fld4 = xcel-value.
when '0005'.
itab-fld5 = xcel-value.
endcase.
at end of row.
append itab.
clear itab.
endat.
endloop.
endform. -
How to Fetch the Data from a Cube
Dear All,
We created a cube containing dimensions
Customer, Product, Branch, Activity, Time dimensions
using Oracle Analytical WorkSpace Manager.
Once Cube is created,
How can I see the Data existing in the Cube using normal SQL Queries ??? Through Analytical Workspace Manager Toll we r able to see the data. But our requirement is to see the data from the Cube using SQL Queries.
Regards,
S.Vamsi KrishnaHey I got the Solution. It follows in this way :
A Cube is nothing but a Data Storage. Based on the Mapping we given it considers the data.
To fetch the data from the Cube -> we have to write the SQl Query as below :
SELECT dealer_name,model_name,sales
FROM TABLE(OLAP_TABLE('MDB.FINAL_AW DURATION SESSION',
'DIMENSION dealer_name AS varchar2(30) FROM FINALDEAL
DIMENSION model_name AS varchar2(30) FROM FINALMODEL'));
We can create View for the above statement o
we can apply group by ,rollup, etc etc clauses
and even we can write where clauses for the above select statement.
But now my doubt is :
can we apply any calculations while mapping the Level to an Dimension.
Generally we will map Level toa dimension as DBUSER.TABLENAME.COLUMN NAME
can we apply any calculation like :
MIS.PROPKEY020MB.MATURITY_DATE+2
Please help for the above.
If any wrong is there please let me know
Regards,
S.Vamsi Krishna
can we apply -
No data Exists error while retrieving the data from a table
Hi Everyone!
I am getting "No Data Exists" error while retrieving the data from a table....where i need to check...if possible please give me example link.....please help me regarding thisHi !
thanks for ur response...
I have written vo.executeQuery for the table...My page is running but i m not getting the data....I have to select two LOV's and when I click on Go button the data has to display in the table...After the selection of LOV's when I click on Go in the table "No data exists" message is appearing...the table has the data and the query is also executing...please give info where i did the mistake....
Maybe you are looking for
-
I recently transferred my data (music, apps, etc.) to a new computer via transferring purchases and Home Sharing and only a few songs had play counts. On my older computer, all the songs had at least some documentation of a playcount. Thinking that I
-
Dear Friends, I have used mathematical fonts and symbol fonts in my job, when i export the XML file not converted in unicode or correct math and symbol fonts in my XML exported file. My requirement is actual font character export in xml file, how to
-
Please Read: NI Discussion Forums Maintenance
Hello Everyone, In my discussions with Lithium (our forum vendor) regarding performance, they have suggested some maintenance on the forums that could help with our community's performance. The maintenance is to "trim" subscriptions and floats (floa
-
I watched a Tom krcha video tutorial on rtmfp using cirrus or stratus. I copyed the code he used just has an experiment really in Flash Builder 4.6. For some reason though, it didn't work for me even though its the same code that was in the video tut
-
How to make Planned working time Override Substitution ?
Dear Friends, The User wants to make Planned working time to always OVERRIDE / PREVELANT on substition. Is it possible ? Thanks, Sri