How to find how/if two tables are related?
Hello Frnds,
If there an FM which can tell if two tables are related so that a join can be performed on them and if yes, it can tell on which field they are related?
Regards,
Arpit
thanks,
Rich, tables will be taken as input from user as parameters and hence will be dynamic. I want to use this logic for the purpose where user wud like to know, for example, which all DEL for SO are created by same user. Now in this case I want to know if there is relation between LIKP, LIPS and VBAK. But if user wants to see which all GR were created by same user who created POs, tables will be MKPF, MSEG and EKKO.
SO what I am trying to say is tables will change as per input but I need to before before processing logic, if there any relation exsits between input table at all or not?
Regards,
Arpit
Similar Messages
-
How to know if two tables are identical in the data they contain
Hello,
How do i know if two tables are identical in the data they contain ?Oais,
If table structure is same or the columns you are interested to compare. You can use following example.
select
OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID
, OBJECT_TYPE, CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS
, TEMPORARY, GENERATED, SECONDARY
from NEW_ME Tbl1
minus
select
OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID
, OBJECT_TYPE, CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS
, TEMPORARY, GENERATED, SECONDARY
from NEW_ME1 Tbl2 -
How to find which SAP R3 table are read during SAP R3 extractor execution ?
Hi Colleagues,
I would like to know which sap r3 table are read during the execution of a sap r3 extractor ?
1. I execute 2lis_03_bf extractor
2- I select debug mode
3. I put a break-point statement at abap command : select
I just see the program going to technical table, mara table and user exit from.
I am sure that this extractor read also MBEW table but I did not found it during the execution of the debug mode.
Can someone help me ? What should I do to see from which table the extractor 2lis_03_bf extractor is retrieving data ?
Thanks !HI Hanson,
You maynot directly hit the source table when you debug a LO Extractor, as you should be aware that the data
is read as below in case of a LO datasources ,
INIT or FULL load --> from Setup tables
Delta --> from the delta queue
Also finding the Source table fora LO extractor is simple as you check the EC pool and understand that , check the
below blog for more details
/people/sap.user72/blog/2005/09/05/sap-bw-and-business-content-datasources-in-pursuit-of-the-origins
But you can try with any other BI content extractor, for examle if you take a 0FI_AP_4
you find the table BSIK and BSAK are being read using FM
Regards,
Sathya -
How to know how many child tables are present for a parent table
hi all,
i created a table USERS in db user pavan (pavan.users (id primary key) ).
and child tables are may be in the same user pavan or in other users of database also.
for the other users i given relative grant permissions to access this USERS table and maintain relation to it.
now, my requirement is how to check the number of references to pavan.users.id
how many tables are dependent on it.
thanks in advance.
regards
pavanTry this
select a.owner,
a.constraint_name,
a.column_name,
a.table_name,
c.table_name Referenced_table,
d.column_name referenced_column
from
all_cons_columns a,
all_constraints b,
all_constraints c,
all_cons_columns d
where a.table_name=b.table_name
and a.constraint_name=b.constraint_name
and b.constraint_type='R'
and b.r_constraint_name=c.constraint_name
and c.constraint_name=d.constraint_name
and a.owner='PAVAN'
and c.table_name='USERS'
and d.column_name='ID' -
Find Discrepancies between two tables
Hello Everyone,
I have two tables payment and delegate, my payment table for some reason have more entries then in delegate table.
I can do something like , if the records in delegate table don't exsist....and they are in payments table
SELECT * FROM
Delegate d, Payment p
WHERE d.username != p.username
The usernames in payment table have to be in delegate table...So now if I want to look for discrepancies how should I find that out....
Tables Records :
Delegate :
Username Paid
User1 Y
User2 Y
User3 Y
User4 Y
User5 N
User6 N
Payment
username
User1
User2
User3
User4
User5
User6
So, basically I'm looking that which records are Paid = 'N' and somehow are in payments table:
In the above example result should be User5 and User6....
I'm using the old database, so please no fancy queries...even if it takes long time doesn't matter..
Please advise..
Thanks,
Harsimrat
Message was edited by:
HarsimratPerfect and if I want to do it other way around....Where there is an entry with Paid = 'y' in delegate table and is not in payments table. How can i find that out ??
Really appreciate.
Thanks,
Harsimrat -
Find Differences between two tables at column level
Hi,
I have 2 tables one live table and the other History table..
If i have to find differences between live table and the latest version in the History table and also find which column got chaanged
How would i do that for a table which has many columns and i need each column for which the value has changed for a id
for ex:
Table 1 (LIve) Table 2 (History)
ID col1 col2 Version ID col1 col2 Version
1 ABC 123 V1 1 ABCD 123 v2
2 NBS 1234 V1 2 NBS 123 V2
Result set should be
Result Set:
ID col which changed
1 col1
2 col2
Because the values for that column had been changed
Except gives me all the differences not just the column level ..The dynamic version using schema views... :D
--Build a coulple OF testing tables to play with
CREATE TABLE dbo.Table1 (
ID INT IDENTITY(1,1) PRIMARY KEY,
Col1 INT,
Col2 INT,
Col3 INT
CREATE TABLE dbo.Table2 (
ID INT IDENTITY(1,1) PRIMARY KEY,
Col1 INT,
Col2 INT,
Col3 INT
INSERT dbo.Table1 (Col1,Col2,Col3) VALUES
(123,456,789),
(111,222,333),
(444,555,666),
(777,888,999),
(321,345,769),
(179,753,758),
(362,362,236),
(856,874,896),
(821,729,324)
INSERT dbo.Table2 (Col1,Col2,Col3) VALUES
(123,456,789),
(111,999,333), --col2 diff
(444,555,666),
(777,888,999),
(321,345,123), --col3 diff
(179,753,758),
(362,362,236),
(234,874,896), --col1 diff
(821,729,324)
And then the actual solution...
DECLARE
@t1 VARCHAR(10) = 'Table1',
@t2 VARCHAR(10) = 'Table2'
IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp
SELECT
c.TABLE_SCHEMA,
c.TABLE_NAME,
c.COLUMN_NAME,
c.ORDINAL_POSITION,
CASE WHEN u.COLUMN_NAME IS NOT NULL THEN 1 ELSE 0 END AS PK
INTO #temp
FROM
INFORMATION_SCHEMA.COLUMNS c
JOIN INFORMATION_SCHEMA.TABLES t
ON c.TABLE_NAME = t.TABLE_NAME
AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE u
ON c.COLUMN_NAME = u.COLUMN_NAME
AND c.TABLE_NAME = u.TABLE_NAME
AND c.TABLE_SCHEMA = u.TABLE_SCHEMA
AND OBJECTPROPERTY(OBJECT_ID(constraint_name), 'IsPrimaryKey') = 1
WHERE 1 = 1
AND t.TABLE_TYPE = 'BASE TABLE'
AND c.TABLE_NAME IN (@t1,@t2)
ORDER BY
c.TABLE_SCHEMA, c.TABLE_NAME, c.ORDINAL_POSITION
DECLARE @select VARCHAR(MAX)
SELECT @select = COALESCE(@select + ', ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
FROM #temp AS t
ORDER BY t.TABLE_NAME, t.ORDINAL_POSITION
DECLARE @from VARCHAR(MAX)
SELECT @from = COALESCE(@from + ' FULL JOIN ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME
FROM #temp AS t
WHERE t.PK = 1
ORDER BY t.TABLE_NAME
DECLARE @on VARCHAR(MAX)
SELECT @on = COALESCE(@on + ' = ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
FROM #temp AS t
WHERE t.PK = 1
ORDER BY t.TABLE_NAME, t.ORDINAL_POSITION
DECLARE @where VARCHAR(MAX)
SELECT @where = COALESCE(@where + CASE WHEN t.TABLE_NAME = @t1 THEN ' OR ' ELSE ' <> ' END, '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
FROM #temp AS t
WHERE t.PK = 0
ORDER BY t.ORDINAL_POSITION, t.TABLE_NAME
DECLARE @sql VARCHAR(MAX) = '
SELECT ' + @select + '
FROM ' + @from + '
ON ' + @on + '
WHERE ' + @where
EXEC (@sql)
HTH,
Jason -
Can somebody explain to me how java and xml are related?
Hi guys
im new to java and xml.Been reading a lot regarding java and don't seem to have a problem with it...
the problem is the xml part...im doing a simple GUI project using swing(online store) and i have to convert it to xml
I have absolutely NO IDEA why i must convert my java to xml and have no idea how to do that.I been reading on the net that xml is a exten~ markup language and it is better and useful.
Can somebody explain to me in layman terms
1)how is java and xml related in?
2)why do ppl want to convert java to xml when they can just stick to java
3)what is actually xml...
4)Do i need a program to create xml like i need jcreater to create java application
5)How do we actually convert?is there any links that you guys could tell me?
thank you
tomleoim new to java and xml.Been reading a lot regarding
java and don't seem to have a problem with it...Okay.
the problem is the xml part...im doing a simple GUI
project using swing(online store) and i have to
o convert it to xmlYou have to? So presumably somebody in a position of authority told you that?
I have absolutely NO IDEA why i must convert my java
to xml and have no idea how to do that.I been reading
on the net that xml is a exten~ markup language and
it is better and useful.I have no idea either (besides which, it doesn't make sense). But why ask us? Somebody told you to do that, ask them why.
Sure, XML is useful. But it isn't a programming language so it can't be used as a substitute for Java.
Can somebody explain to me in layman terms
1)how is java and xml related in?They aren't related, except perhaps in that they are both used in computers.
2)why do ppl want to convert java to xml when they
can just stick to javaThey don't.
3)what is actually xml...Start here for numerous definitions:
http://www.google.ca/search?hl=en&lr=&oi=defmore&q=define:XML
4)Do i need a program to create xml like i need
jcreater to create java applicationNo, XML is just text. But then Java code is just text too.
5)How do we actually convert?is there any links that
you guys could tell me?You don't convert Java to XML. My guess is that because you don't know much about Java or XML, you have misinterpreted something that somebody told you. -
Oracle 11g sql to find difference from two table data
I have two tables ACTUAL AND ESTIMATE having unique column(sal_id, gal_id) and amount, tax, date columns.
ACTUAL table
actual_id, sal_id, gal_id, process_flag, amount, tax date
A1 101 201 Y 10 1 27-Aug-12
A2 102 202 Y 20 2 27-Aug-12
A3 102 202 N 30 3 29-Aug-12
A4 302 402 N 40 3 30-Aug-12
ESTIMATE table
estimate_id, sal_id, gal_id, process_flag, amount, tax date
E1 301 401 Y 5 1 19-Aug-12
E2 302 402 Y 45 4 20-Aug-12
E3 302 402 Y 50 5 25-Aug-12
E4 301 403 Y 10 2 27-Aug-12
E5 301 403 N 15 3 28-Aug-12
E6 101 201 Y 12 3 29-Aug-12
Now My FINAL table, 1) Should have record for unprocessed (process_flag='N') from ACTUAL/ESTIMATE table for difference in amount and tax for (sal_id + gal_id) combination. If more than one processed record there, then max (date) should be consider.
FINAL table
actual_id, estimate_id, sal_id, gal_id, amount, tax
A3 null 102 202 10 1 (A3-A2 actual-actual)
A4 null 302 402 -10 -2 (A4-E3 actual-estimate with max date)
null E5 301 403 5 1 (E5-E4 estimate-estimate)
null E6 101 201 2 2 (E6-A1 estimate-actual)
So basically I need a query for (A-A) U (B-B) U (A-B) U (B-A).
I am using Oracle 11g Please help me.
Edited by: Suresh on Aug 31, 2012 7:38 PM
Edited by: Suresh on Aug 31, 2012 7:38 PM
Edited by: Suresh on Aug 31, 2012 10:53 PMYou need to provide better explanation here.A-A is always null.
You might be looking for something like this..
Untested version and also i cannot read your mind
select actual_id, sal_id, gal_id, process_flag,ld_amount,ld_tax,e_date
from(
select actual_id, sal_id, gal_id, process_flag,e_date, amount-lead(amount) over(partition by sal_id, gal_id order by e_date desc) ld_amount,
tax-lead(tax) over(partition by sal_id, gal_id order by e_date desc) ld_tax,
rank() over(partition by sal_id, gal_id order by e_date desc)rnk
from
(select * from actual a union
select * from estmt e)
) where rnk=1 -
How to guarantee two tables are in sync both ways on 10gR2?
a table at x database and b table at y database are wanted to be in sync.
if the request was in one way a dblink and a materialized view with refresh on commit would do the trick. but changes wanted to be replicated both ways, so I thought a trigger based solution but wanted to have your opinions if there is any clever trick for this kind of a need.
Thank you.please correct me if I am wrong, by streams you meand async change data capture from redo logs right? In my opinion this is not easy to configure, and since these are two small parameter tables, so it will be throwing a rock to a frog?
-
How to find difference in two tables
Hi all,
I am having 2 tables (Table1 and Table2 ) same structure.
1. Table1 is having some data.
2. Now, i got data in CSV file, which was loaded into Table2.
This data contains....
A. Data of Table1
B. Some colum values are different compare to Table1 column values.
(Pkey is same, but column values are different in Table1 and Table2)
C. Additional rows are there compared to Table1.
Now, what i want is......
I want to select the data from Table2,
1. The rows in which column values are different from the Table1
2. New records added from CSV file (i.e. Those records that are not
there in Table1).
Thanks in advance,
PalThanks for your solution. It is working, but my problem is
Table1
COL1 COL2 COL3 COL4
1 col2 col3 col4
2 col2 col3 col4
3 col2 col3 col4
4 col2 col3 col4
Table2
COL1 COL2 COL3 COL4
5 col2 col3 col4 -- New row
6 col2 col3 col4 -- New row
1 col2 col3 col44 -- Different column value
2 col2 col3 col4
3 col2 col33 col4 -- Different column value
4 col2 col3 col4
select * from test2
minus
select * from test1
COL1 COL2 COL3 COL4
1 col2 col3 col44 --- needs to be update
3 col2 col33 col4 --- needs to be update
5 col2 col3 col4 --- needs to be insert
6 col2 col3 col4 --- needs to be insert
Actually, I need to update and insert those records through LIVE UPDATE in the remote database. In this case, Table1 data is in the remote database. The output of MINUS statement needs to be implimented in Table1, which is in remote database.
Any suggestion will be appreciated. Thanks,
Pal -
How the tables are related in sap-crm
Can anybody help me out ??regarding the relationship between below tables??
CRMD_PARTNER Opportunity/Activities based on Contact
CRMD_LINK Opportunity/Activity Contact Link table
CRMD_ORDERADM_H Opportunity / Activity header table
CRMD_ACTIVITY_H Activity header table
BUT000 Client / Contact/Employee Name
Thanks in advance,...
bye--
Pradeepa1 ) CRMD_ORDERADM_H -
TAKE GUID
2)CRMD_LINK --->FIND GUID-SET FOR GUID-HI
3)CRMD-PARTNER--->PASS GUID-SET IN GUID ---TO GET PARTNER-NO
4)BUT000>GIVE PARTENR NO IN PARTNER-GUID->GET PARTNER.
5) CRMD_ORDER_INDEX--->GIVE PARTNER IN PARTNER-NO >GET>OBJECT_TYPE.. -
Hai guys
In drop down list i am having lot of names which is to be list.
I know the condition how to select in one name from that list.
Now i want to select any condition so that all the name can be display.
I want a query to make both the result in single query.
that is if user can select one name only that name can be displaying.
if user can select any option all the name can be displaying...
please tell the query any one.....Which application?
May be you want to post in the application forum, or post some sample data and expected output so that someone can help you -
How to get the 'link' between two tables
hi pple
i need to find out HOW two tables are related.
sample tables:
SHIPS ( HULL_ID [PK] , VESSEL_NAME, GROSS_TONNAGE )
EQUIPMENT ( E_ID [PK] , HULL_ID [FK frm SHIPS], DESC )
PARTS ( PART_ID [PK] , E_ID [PK, FK frm EQUIPMENT], MANUFACTURER_ID)
--> SHIPS and PARTS are some how related thro' EQUIPMENT.
i need to get this relationship:
Ships --> Equipment (E_ID) --> PARTS
currently, i can get the direct parent and child tables of a given table using:
SELECT lpad ( ' ', 2 * ( LEVEL - 1 ) ) || table_name as Child_Tables
FROM ALL_CONSTRAINTS
START WITH R_CONSTRAINT_NAME in
select constraint_name
from all_constraints
where table_name = '%table_name%'
and constraint_type = 'P'
CONNECT BY PRIOR CONSTRAINT_NAME = R_CONSTRAINT_NAME ;
To get ALL parents:
SELECT lpad ( ' ', 2 * ( LEVEL - 1 ) ) || table_name as Parent_Tables
FROM ALL_CONSTRAINTS
where owner = 'CHARTUSER'
START WITH CONSTRAINT_NAME in
select constraint_name
from all_constraints
where table_name = '%table_name%'
and constraint_type = 'R'
CONNECT BY PRIOR R_CONSTRAINT_NAME = CONSTRAINT_NAME ;
what i need to do is:
1) get children & parents of SHIPS
2) for each element of (1), get children, parents till i get PARTS
3) so, i will get EQUIPMENT and then, PARTS.
this wud be very expensive. my appln is in Java and i will need to call these functions - that makes it more complex. is there any simpler way out?
and my main problem is to find out WHAT attributes line two tables. this wudnt be a big deal if it were just simple parent-child tables. but, how do i find out the attributes that link PARTS and SHIPS table?
any ideas? -please help.
thanks in advance
--$uDhADear Srikanth,
This tables can be used once we come to know whether its a customer or vendor line item but in our case we using the GL account as reference have to knock off the entries.How we come to know that aginst the GL whether its a customer or vendor line item.. Then it should route to this table.
Suggest me if any options are there.
Regards,
Balaji.c -
How to get tables from at a time two database connections
dear all ,
i have get two table information these two table are in two diffrent db(like different conncections username ,password,portno... these r differnt)so how to get at a time that two table inforamtions
Edited by: user13092208 on Dec 28, 2010 10:42 PMrepost
-
How to print two tables adjacent to each other?
Hi,
Scenario
I have a form with a body page and two tables. The property of the body page is set to 'Flowed', 'top to bottom' as flow direction and the check box for page break is set.
Requirement
The two tables need to be printed adjacent to each other.
Approach followed until now
1. Since the body page is 'Flowed' type, the two tables are placed one below the other (Tab1 & Tab2). So I tried to set the Flow direction of the Body page to 'Western text'. But this did not solve the issue as since it is set to 'western text', only after Tab1 is rendered, table Tab2 starts printing itself, which is not desired. Both the tables should be printed at the same time.
2. I wrapped both the tables in one sub form with 'Type' set to 'Positioned' and set the check box for page break. Now I arranged the tables adjacent to each other. But the check box for page break for both the tables were disabled and because of this if there is not enough space to print the total records of both the tables, the complete tables is shifted to another page leaving the previous page blank.
Kindly suggest how to resolve this issue.
Regards
s@kDear Andres,
I tried as per you suggestion and it works fine. Thanks a lot.
Now adding to this, I am trying to print the 'formatted text'. The tables have two columns. the first column is a normal field and the second column is table having the 'formatted text'.
As per your suggestion, I concatenated the two tables in one table. So the final table has 2 normal fields and 2 tables.
Final table structure:
Column1 Column2(Table) Blank Column3 Column4(Table)
Settings maintained:
I have set the 'Body' row of the table to 'Flowed' with direction as 'Western text' (Top to bottom does not help ).
The settings for Column 2 & 4 (tables) are maintained as:
1. The Table is set to 'Flowed' with direction 'Top to Bottom'.
2. The body row is 'Flowed' with direction 'Western Text'
(The Border 'Edges' for the tables, columns is maintained as 'None')
Issue:
The sample data has around 10 entries in the (final) table. When I try to print the form, if column2(table) is initial, the data in Column3 and 4 are shifted towards Left hand side.
Kindly suggest how to resolve this issue.
Regards
s@k
Maybe you are looking for
-
Problem during creation of dynamic Internal
Hi All, I am trying to create a dynamic internal table. I went through many posts, but the problem i am facing is, I want an internal table as: Empno Ename Lgart1- Depending on the Wage types user enter on the selection screen. Lgart2 When i tried to
-
How to Create payment term for -Net Due 1st Day of Second Month Following
Hi, We need to add a payment term for "Net Due 1st Day of Second Month Following Delivery". We need this to be in the system as soon as possible as we just were told of a change in terms for our client effective May 1st. Kindly advice me how to selec
-
Cannot create a new model in designer
Hi I am not able to create a new model in designer as I get the following error: "Invalid column name sysdate" Does anyone knows how to resolve this? I am on version 10.1.3.6.0. Thank you Namita
-
Is activex,ole,and com section only used by internet explorer?
When I go to a registry cleaner the above item always appear but are not fixed so I thing they are not part of Firefox. Is this true and why?
-
Hello all, I've got my iPod touch language set to Russian, and regional settings set to English Canada. When I reply to a message in Mail, the language of the bits added by the app (forwarded message begins, replying to, from, to, etc) are in Russian