Query for Linking Two Tables without Reference

Hi Folks,
Good Day!
I have this dilemma on how to link two tables without a reference. In the Business Partner Master Data, there is a field for the Territory which is from the table OTER. This OTER focuses on its description. Once you have added the particular Territory for that Business Partner, it is being stored in the Territory field of the BP right? Our client wants to have an automated way of searching for the Business Partner's Profit Center in creating a Sales Order wherein it is the same as the Business Partner's Territory. The Profit Center is from the table OPRC.
When I create a Sales Order, after I have entered the Business Partner/Customer Code, the Profit Center should have the value of the Profit Center Code wherein it is the Business Partner's Territory. My query will go like this:
Enter the BP/Customer Code automatically the Profit Center code where Profit Name = BP's Territory.
OTER and OCRD don't have connections. How can it be?
I'm thinking of retrieving the Territory first before the Profit Center but can you suggest of any other way?
Thank you much!
Regards,
Fringe

Hi Fringe,
Okay, I already understood your case here. I presume your configuration as follows:
OTER (Territory)
territryID - descript
1 - Philippine
2 - Indonesia
3 - Germany
OPRC (Cost Centre)
PrcCode - PrcName
25 - Philippine
33 - Indonesia
47 - Germany
Was above illustration correct? Then, you could use this formatted search in Cost Centre / Dimension field in Sales Order rows
SELECT PrcCode FROM OPRC WHERE PrcName=(
SELECT TOP 1 descript FROM OTER T0
INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
WHERE T1.CardCode=$[OCRD.CardCode.0])
However, I suggest you use a little bit different approach here. Since you can't define Territory Code / Territory ID (you could only type the Territory name, Philippine etc.), why don't you standardize Territory name with Cost Centre code? Let say, you define Philippine as PHI, Indonesia as INA, Germany as DEU and so on. Therefore, user can read the Cost Centre or more precisely Distribution Rules in Sales Order form in more familiar way.
OTER (Territory)
territryID - descript
1 - PHI
2 - INA
3 - DEU
OPRC (Cost Centre)
PrcCode - PrcName
PHI - Philippine
INA - Indonesia
DEU - Germany
When FMS worked in Sales Order document, your user will read PHI instead of 25, should be more familiar to them. With that being said, you could use simpler FMS
SELECT descript FROM OTER T0
INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
WHERE T1.CardCode=$[OCRD.CardCode.0]
You only need to maintain consistency between Territory Name and Cost Centre code. Just my two cents. Hope this help.
Best Regards,
Hendry Wijaya

Similar Messages

  • Query that link two tables together

    I am using this query to extract  Account Payable data:
    SELECT T0.DocNum, T0.DocStatus, T0.DocDate, T0.DocDueDate, T0.CardCode, T0.CardName, T0.NumAtCard, T0.DocTotal FROM Akron.dbo.OPCH T0
    How would I also add the unique number for each individual payment from these tables?
    OVPM and VPM2.
    What field links these 2 tables together?

    Hi,
    You may check this: Incoming Payments Report
    Replace all INV with PCH and RCV with VPM
    Thanks,
    Gordon

  • Data fetch from two table without refresh

    hi Friends,
    I have a problem i want to extract data from two table without refresh into text field when i'll enter any value in a text field then corressponding value should come in to corressponding textfield.
    eg. there two table A and B.
    Table A has Colunm
    s_id Number;
    c_id Varchar2(30);
    sec varchar2(4);
    Second Table B Colunm Name
    s_id Number;
    f_name varchar(30);
    l_name varchar(20);
    when i enter s_id 101 in a text field then the c_id ,sec,first_name and last_name should come in to corressponding text fields without refresh.
    How Can I do this.
    Thanks
    Manoj

    Hi Manoj,
    You have to make an Ajax call to display data without refreshing the page. Search this forum for Ajax and you can find lots of related posts. This link might help too. http://www.dba-oracle.com/t_html_db_apex_ajax_application_express.htm
    Thanks,
    Manish.

  • Combining two tables without any distinct columns between them

    Folks,

    Hi sidy2j,
    According to your description, we need to verify your table structures, and the actual results which you want to get from your tables. Please post more information for analysis.
    Assume, if you want to a one to one record mapping between  two tables without any common column between them for joining, you can refer to the following scripts to implement your requirement. For more information, see:
    http://sqlhints.com/2013/09/07/joining-two-tables-without-any-common-column-between-them-sql-server/
    If you want to match every row in the first table with every row in the second table, you can refer to the following detail.
    http://stackoverflow.com/questions/1198124/combine-two-tables-that-have-no-common-fields
    Hope it can help you.
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How to link two tables?

    Hello,
    I'm trying to create invoices with Pages, but my question is how can I link two tables in one Pages document?
    Or having two Header Rows with some 'normal' rows between would also be great. (even better)
    I'm trying to calculate my subtotal etc. below my overview of articles.
    Thanks in advance!
    Andy

    (1) no way to link two tables in Pages.
    (2) you may have several header rows, several footer rows but you can't have standard rows between header (or footer) ones.
    You may achieve what you describe without the asked feature.
    Use correct ranges and you will be able to calculate subtotals.
    Yvan KOENIG (VALLAURIS, France) lundi 28 décembre 2009 19:02:38

  • In ER DIagram using toad( how can i link two tables)

    Hi,
    Any Toad expert can guide me that how can i link two tables in Toad in ER Diagram to show the relationship between two tables.
    Thanks

    Hi,
    I hope there is foreign key relationship in tables, if so then you can click on "Find table dependencies" icon which will draw lines between them.
    ~Vinod

  • Oracle query for top two salary of each group departmentwise

    oracle query for top two salary departmentwise

    sigh...
    But anyway,
    Top-n queries:
    http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2853107469873
    and ofcourse lots of 'em here on OTN...

  • How to find top utilized query for last two months in oem

    how to find top utilized query for last two months in oracle enterprise manager?

    Can you mark the thread as Helpful  and once marked the information can be reviewed by other customer for similar queries
    Regards
    Krishnan

  • Query for comparing two columns in two tables

    Hai, all,
    I have following two tables and columns, I need to get the rows (all columns) from scott.cp_ip which are not ( the same value present in t1 and also in t2).
    Table scott.cp_ip column cp_ip.vrno = Table scott.cb1 column cb1.cb_vnno
    I used the following query and did not get the correct result:
    select * from scott.cp_ip where cp_ip.vrno in (select cb1.cb_vnno from scott.cb1);
    Can you please tell how it can be solved?
    Thanks in advance.
    Rcs
    SQL> desc scott.cb1;
    Name Null? Type
    ID NUMBER
    SUPCODE NUMBER
    SUPLNAME VARCHAR2(100)
    NAME VARCHAR2(100)
    ITEMCODE VARCHAR2(10)
    RECDOC NUMBER
    RECDATE VARCHAR2(10)
    TOTVALUE NUMBER
    QTY NUMBER
    CB_IPNO NUMBER
    CB_VNNO NUMBER
    CB_VDT VARCHAR2(10)
    CB_AMT NUMBER
    SQL> desc scott.cp_ip;
    Name Null? Type
    ID NUMBER
    VRNO NUMBER
    CODE VARCHAR2(50)
    HEAD VARCHAR2(255)
    PARTI VARCHAR2(255)
    CR NUMBER
    SQL> select * from scott.cp_ip
    2 intersect
    3 select * from scott.cb1;
    select * from scott.cp_ip
    ERROR at line 1:
    ORA-01789: query block has incorrect number of result columns
    SQL> (select * from scott.cp_ip
    2 minus
    3 select * from scott.cb1)
    4 union all
    5 (select * from scott.cb1
    6 minus
    7 select * from scott.cp_ip);
    (select * from scott.cb1
    ERROR at line 5:
    ORA-01789: query block has incorrect number of result columns
    SQL> select * from scott.cp_ip where cp_ip.vrno in (select cb1.cb_vnno from scott.cb1);
    result=instead of 1408 rows, 1481 rows (excess 73 rows) getting!
    ----------

    Instead of SELECT * write only the column that you want to compare. I guess that would be cb1.cb_vnno and cp_ip.vrno.

  • Error while running query for a specific table

    Hi All,
    I need your help please.
    I've configured everything correctly in my SCCM environment. And i used to connect the CAS database from a separate box(same domain) which has SSMS console installed in it. Now the problem is, whenever i try to run a query in CAS database locally, it runs
    successfully. But when i connect the CAS database remotely and run the same query with the same login i used in CAS, it says the below error. This is happening from past 2 days only. :'(
    Query ran :
    select top 100 * from v_GS_WORKSTATION_STATUS
    Error :
    Msg 18456, Level 14, State 1, Line 1
    Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
    OLE DB provider "SQLNCLI11" for linked server "abc.domain.com" returned message "Invalid connection string attribute".
    I checked the SQL connection authentication information it says authenticated by kerberos using below query :
    SELECT 
        s.session_id
      , c.connect_time
      , s.login_time
      , s.login_name
      , c.protocol_type
      , c.auth_scheme
      , s.HOST_NAME
      , s.program_name
    FROM sys.dm_exec_sessions s
      JOIN sys.dm_exec_connections c
        ON s.session_id = c.session_id
    where s.host_name='servername'
    Result:
    136 2015-01-30 17:50:29.277 2015-01-30 17:50:29.280 domain\user TSQL KERBEROS servername Microsoft SQL Server Management Studio
    But, another wierd information is i can successfully run the below query in remote.
    select * from vSMS_R_System
    I think that specific table is not working in remote. Pleaseeeeeeee helppp me......
    Regards,
    Jay

    Hi JaySmiley,
    According to your description, you get the logon issue when connecting to CAS database remotely and execute query. Right?
    In this scenario, this error can happen when the SPN account is registered without setting 'trusted for delegation' property. Account must be trusted for delegation in order for Kerberos delegation to succeed. Here's a blog talking about your scenario, please
    refer to the link below:
    http://blogs.technet.com/b/umairkhan/archive/2013/10/19/the-distributed-views-do-not-get-created-in-configmgr-2012-sp1-because-of-the-login-issue.aspx
    If you have any question, please feel free to ask.
    Simon Hou
    TechNet Community Support

  • Display columns from two tables without making join

    Hi,
    I need to perform currency conversion in the report.
    For eg:) Whatever the currency in ar_payment_schedules i want to
    convert it to INR equivalent.
    Following is the query to do this.
    select ps.invoice_currency_code Currency_B,
         decode(ps.invoice_currency_code, 'INR',ps.amount_due_original,
                   round(ps.amount_due_original*
                                  ps.exchange_rate,
                             curr.precision)
         from
              ar_payment_schedules     ps,
              fnd_currencies          curr
         where ps.customer_id          = '111'
         and curr.currency_code      = 'INR'
    When i do this in the Administration tool, the answers modules erroring out saying
    that no joins between ar_payment_schedules and fnd_currencies. But here join is
    not needed becuase fnd_currencies is filtered with INR and will return only
    one row. Without joining two tables how can i get the same results in Answers.
    thanks,
    Prasanna

    If it would return only one row then what is the need for the join (is it just for returning the precision?). Cant you just hard code the precision value instead of getting it from the table? Also you are doing a cartesian join, though the filters would take care of the final output this would result in a bad performance as your data starts scaling out. You need to find a key to join these 2 tables. If you do not have one, then just create a view with the cartesian join alone and then use that in your report.
    Thanks,
    Venkat
    http://oraclebizint.wordpress.com

  • Join two tables without index scan

    Hi All,
    I have two tables (ProgramMaster, ProgramDetails). ProgramMaster have very less number of records and Programdetails have large number of records
    My Query is
    Please vote if you find this posting was helpful or Mark it as answered.

    Saravanan,
    As you may know, usage of functions over the columns will force the compiler to go for a SCAN and not a SEEK. How about rewriting the query (without using functions) to make way for better usage of the index.
    One option is to make use of a calendar table that would prove to be effective for date operations like this one..
    For more info on calendar table:
    http://www.allaboutmssql.com/2014/01/sql-server-calender-details.html
    http://social.technet.microsoft.com/wiki/contents/articles/22776.t-sql-calendar-table.aspx
    http://blog.jontav.com/post/9380766884/calendar-tables-are-incredibly-useful-in-sql
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Best way for joing two tables

    hi all
    i have two tables i want to join them but i do not know how to do it? i tried to use foreign key and primary key but after using primary and foreign key i am not able to insert records help me out thanks in advance
    sarah
    Edited by: SarahSarahSarah on Aug 31, 2009 12:08 PM

    hi thanks for reply
    i have the following table and named ins1 i want to join this table with ins2 how to do it?
    create table ins1
    (ref varchar2(18),
    doc varchar2(3),
    trans varchar2(3),
    facflag varchar2(3),
    branch varchar2(1),
    class varchar2(3),
    year varchar2(4) ,
    serial varchar2(5) primary key,
    cno varchar2(2),
    edno varchar2(2),
    branch1 varchar2(1),
    class1 varchar2(3),
    year1 varchar2(4),
    serial1 varchar2(5),
    cno1 varchar2(2),
    edno1 varchar2(2),
    issue date,
    docdat date,
    period date,
    inscode varchar2(10),
    payment varchar2(3),
    debit varchar2(10),
    beneficiary varchar2(5),
    producer varchar2(6),
    broker varchar2(10),
    insperiod date,
    end date,
    noday varchar2(2),
    risktype varchar2(10),
    remarks varchar2(50),
    oldpolicy varchar2(12),
    fleet varchar2(5),
    interestco number,
    fleetremark varchar2(50),
    dbcnremarks varchar2(50),
    time varchar2(6),
    time1 varchar2(6),
    add5 varchar2(20),
    add7 varchar2(25),
    name varchar2(40),
    nameman varchar2(50),
    newpolicy varchar2(10),
    renewpolicy varchar2(10)
    create table ins2
    (ref varchar2(10) primary key,
    transtype varchar2(1),
    transfer varchar2(10),
    serialno varchar2(3),
    incepectionDate date,
    time3 varchar2(10),
    pdate date,
    time4 varchar2(10),
    limit varchar2(3),
    state varchar2(20)
    ptype varchar2(20),
    private varchar2(10),
    pno varchar2(10),
    engno varchar2(10),
    chasno varchar2(10),
    engcap varchar2(10),
    vmake varchar2(10),
    model varchar2(10),
    myear varchar2(4),
    btype varchar2(5),
    power varchar2(10),
    cylender varchar2(10),
    load varchar2(4),
    color varchar2(4),
    cid varchar2(2),
    passenger varchar2(10),
    passcovered varchar2(10),
    certificateno varchar2(10),
    covertype varchar2(1),
    compulsory varchar2(30),
    rate varchar2(4),
    riyal varchar2(30),
    no1 varchar2(1),
    sum number(10),
    Lc varchar2(10),
    excess varchar2(10),
    Remark varchar2(10),
    prevAccident varchar2(10),
    totalVihicle varchar2(5),
    total number(10),
    sum1 number(10))
    after creating foreign key i am not able to insert query its showing the error :unable to insert
    sarah

  • Pricing procedure for Credit Memo request WITHOUT reference

    Dear friends,
    I have come across a requirement where credit memo request has to be created without reference to preceding document. i.e. for just giving some credit to customer may be for over pricing or giving some credit to customer (as to maintain good relation).
    So generally we have different pricing procedure for Cr/Dr process.
    thus i have different pricing procedure for Cr/Dr process than normal sales process.
    here i have copied pricing procedure of normal sales and added extra condition type for manual pricing, which overrides basic pricing condition type.
    but calculate the discount and taxes on the manual price.
    I would like to know whether discounts and taxes condition type's should be used
    in the cr/dr process without reference to preceding document. and suggest me the right condition types to be used in cr/dr pricing procedure without reference.
    Thanks.

    HI,
    Remove all the other condition types from the procedure and keep only those which you need.
    Regards
    Abhilash

  • Linking two table..it is look like unpivot but it is not

    Hi guys, I got a situation like this:
    Table A
    create table #fly (company varchar (50), period varchar(6), adcost (int), ppcost (int))
    insert into #fly values ('PanAm', '201401', 100, 200) ,  ('PanAm', '201402', 200, 200) , ('PanAm', '201403', 700, 1000), ('EGAm', '201401', 1100, 1200), ('EGAm', '201402', 7100, 7200)                                                                                                                 
    Table 2 #Cost (firm varchar (100), client varchar (100), period varchar(6), element (varchar 10), tot int) insert into #firm ('Zuck', ''Panam', '201401', ''adcost', 40), ('Zuck', ''Eagam', '201401', ''adcost', 40), ('Zuck', ''Panam', '201402', ''ppcost', 240)                
    As you can see I got in fly the field adcost that is a value in the table #cost. I need to link the two table and I'm wondering whitch is the best way. Another issue is the adcost (#fly) has in #cost two relatives adcost and fixadcost element. I should consider
    both the elements as adcost.  Advices? Thanks

    create table #fly (company varchar (50), period varchar(6), adcost int, ppcost int)
    insert into #fly values ('PanAm', '201401', 100, 200) , ('PanAm', '201402', 200, 200) , ('PanAm', '201403', 700, 1000), ('EGAm', '201401', 1100, 1200), ('EGAm', '201402', 7100, 7200)
    create table #Cost (firm varchar (100), client varchar (100), period varchar(6), element varchar (20), tot int)
    insert into #cost values ('Zuck', 'Panam', '201401', 'adcost', 40), ('Zuck', 'Eagam', '201401', 'adcost', 40)
    , ('Zuck', 'Panam', '201401', 'fixedadcost', 40)
    , ('Ford', 'Panam', '201401','ppcost', 240)
    select * from #Cost
    select * from #Fly
    Select company,f.period,adcost, (c1.tot+c2.tot) as [adcost + fixedadcost] , ppcost, c3.tot as [ppcost from Cost] from (select company,period,adcost,ppcost from #Fly
    WHERE company='PanAM' AND period='201401') f
    left join #Cost c1 on c1.period = f.period AND c1.client=f.company AND c1.element ='adcost'
    left join #Cost c2 on c2.period = f.period AND c2.client=f.company AND c2.element ='fixedadcost'
    left join #Cost c3 on c2.period = f.period AND c3.client=f.company AND c3.element ='ppcost'
    drop table #Cost, #Fly

Maybe you are looking for