To link two tables in ap

hi
could someone pls guide me to link ap_invoices_all table with gl_code_combinationsthanking in advance
Edited by: makdutakdu on Oct 14, 2010 12:15 PM

Hello.
Use the following query (R11i):
SELECT i.invoice_num "Invoice Nr.",
c.segment1 "Segment1",
l.ae_line_type_code "Line Type",
l.accounted_dr "Debit",
l.accounted_cr "Credit"
FROM ap_ae_lines_all l, ap_ae_headers_all h, ap_invoices_all i, ap_accounting_events_all e, gl_code_combinations c
WHERE e.source_table = 'AP_INVOICES'
AND i.invoice_num = '<your invoice nymber>'
AND l.ae_header_id = h.ae_header_id
AND e.accounting_event_id = h.accounting_event_id
AND e.source_id = i.invoice_id
AND l.code_combination_id = c.code_combination_id
AND i.org_id = <your org_id>
As you may have more than one invoice with the same number, the query may return more lines then expected. To restrict it, enter the vendor_id from table AP_INVOICES_ALL.
Hope this helps.
Octavio
Edited by: Octopus Rex on Oct 14, 2010 4:10 AM

Similar Messages

  • 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

  • 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

  • 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

  • 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

  • Linking two tables with no duplicated records!

    Hi,
    I have two tables now with both tables is having the common filed matnr.
    now using this field MATNR from  first table ,i need to fetch projectno from the other table which has to be unique.if there are more than one entry found for MATNR in question then that must not be updated to the first table!
    any ideas?
    Raj

    hi raj,
    try this code.
    data:
      ld_count type p,
      ld_tabix type sy-tabix.
    loop at itab1.
      move sy-tabix to ld_tabix.
      ld_count = 0.
      loop at itab2 where matnr eq itab1-matnr.
        add 1 to ld_count.
      endloop.
      if ld_count = 1.
        read table itab2 with key matnr = itab1-matnr.
        move itab2-project to itab1-project.
        modify itab1 index ld_tabix.
      endif.
    endloop.

  • Linking two table views

    Dear all,
    I am creating an iView within VC which runs two BI queries from one variant input form.
    From the outputs i can create two output tables which supply all the information i require.
    My question is, can I combine the results of the two outputs and select from both outputs the information i want to display and deliver it in one output table. I will have one common key within both sets of data.
    Unfortunately the BI reports can not be changed due to their setup
    Regards
    PS.

    Hello,
    It may be related with the configuration of the model (how input and output ports are connected).
    Please have a look at below thread. It is quite in detail:
    [How to use the Union operator;
    -arda.

  • 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

  • Linking two tables in SQL

    Hi,
    Iam struggling with SQL for this scenario..can you please through some light on this.
    Table A:
    Order Number || W.O.Number || Enetrprise || ResourcePool
    1 || 1 || A || RP1
    2 || 2 || A || RP1
    3 || 3 || A || RP2
    4 || 4 || A || RP2
    5 || 5 || A || RP3
    B
    ResourcePool || Available Date
    RP1 || 20-Dec-2007
    RP1 || 21-Dec-2007
    RP1 || 22-Dec-2007
    RP2 || 20-Dec-2007
    RP2 || 21-Dec-2007
    RP3 || 20-Dec-2007
    RP3 || 21-Dec-2007
    My query should fetch
    Order Number|| W.O.Number|| Enetrprise|| ResourcePool|| Available Date
    1 || 1 || A || RP1 || 20-Dec-2007
    1 || 1 || A || RP1 || 21-Dec-2007
    1 || 1 || A || RP1 || 22-Dec-2007
    2 || 2 || A || RP1 || 20-Dec-2007
    2 || 2 || A || RP1 || 21-Dec-2007
    2 || 2 || A || RP1 || 22-Dec-2007
    3 || 3 || A || RP2 || 20-Dec-2007
    3 || 3 || A || RP2 || 21-Dec-2007
    4 || 4 || A || RP2 || 20-Dec-2007
    4 || 4 || A || RP2 || 21-Dec-2007
    5 || 5 || A || RP2 || 20-Dec-2007
    5 || 5 || A || RP2 || 21-Dec-2007
    when Iam including A.resourcepool=B.resourcepool in the query its returning no rows.
    Thanks

    (repeated)
    select Order Number,W.O.Number, Enetrprise, a.ResourcePool, Available Date
    from a,b
    where a.resourcepool=b.resourcepool;
    this is the simplest join condition.
    just check whether you have some data in those tables!

  • Join two table using two link field

    hi all
    i need to left join two table, and to link two table need to match two field
    ex: the link field is store_name and id
    i use below sql statement
    SELECT A1.store_name, A1.id, A1.card, A2.sale, A2.history
    FROM Georgraphy A1, Store_Information A2
    WHERE A1.store_name = A2.store_name(+)
    AND A1.id = A2.id(+)
    but it's wrong
    please tell me how to left join A1 and A2, thx!

    Whats your aim?
    Any error message?
    SQL> select * from geography;
            ID STORE_NAME
             1 a
             1 b
             2 a
             2 b
    SQL> select * from store_information;
            ID STORE_NAME
             1 a
             3 d
    SQL> SELECT *
      2  FROM Geography A1, Store_Information A2
      3  WHERE A1.store_name = A2.store_name(+)
      4  AND A1.id = A2.id(+);
            ID STORE_NAME         ID STORE_NAME
             1 a                   1 a
             2 a
             2 b
             1 b                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to link two databased

    I have to link two tables from two differen databases.
    select vendor from table a database e
    select vendor from table b database c
    how can i combine this two tables

    You create a database link. Assuming you are on database e:
    CREATE DATABASE LINK c_link
      CONNECT TO name_of_c_database_user_with_select_privilege_to_table_b
      IDENTIFIED BY password_of_c_database_user_with_select_privilege_to_table_b
      USING 'c_database_tns_entry_name'
    /Keep in mind 'c_database_tns_entry_name' must exists in tnsnames.ora on database e server.
    Now you can:
    select vendor from table_a
    union all
    select vendor from table_b@c_link
    /SY.

  • 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
    --$uDhA

    Dear 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 link two fact table in OBIEE

    i experts
    1. I have one fact table EXCHANGE_FACT(Contains the exchange rate for each curruncy on each day) .
    2. I Have anothe fact Table ACCOUNT_FACT(Contains Amount for each currency on each day).
    Now i have to link these two table on bace of currency_key and time_key in OBIEE. so i have can i achieve it in OBIEE.
    Regards
    Frnds

    Hi Frnds,
    You should create two common dimensions (currency en time) and join each fact table seperately to these dimension. Create a demnsion (hierarchy) for each dimension.
    Good Luck,
    Daan Bakboord
    Scamander Solutions

  • Sp to sync two tables using linked servers

    Hello everybody
    I'm working in a SP and I got two tables in different servers, one is the main and the other is a copy but whit less columns, all I want is to run the SP every 5 min over the main table in order to validate if new records has been created, if yes take those
    new records and insert them into the copy table, that resides in the other server.
    Searching a solution I've found this script wich works ok in the same server, but when I try to run it with the linked server it fails....please somebody help me with this.
    This is the code that I'm using:
    ALTER PROCEDURE  sp_newrecords
    AS
    BEGIN
    DECLARE @val1 int
    DECLARE @val2 nvarchar(50)
    DECLARE @val3 nvarchar(50)
        SET NOCOUNT ON;
        -- Insert statements for procedure here
    DECLARE mycur1 CURSOR for
     select empid,fname,lname from employee
     where empid = 507
     OPEN mycur1
     FETCH NEXT FROM mycur1 INTO @val1, @val2 , @val3
     WHILE @@Fetch_Status = 0
     BEGIN
     begin tran /* default read committed isolation level is fine */
     if not exists (select * from employee_backup with (updlock, rowlock, holdlock)
                         where employee_backup.empid = @val1
                            and employee_backup.fname = @val2 )
         --insert employee_backup values (@val1, @val2 , @val3) -->this works fine
         INSERT [ESDBCGW001T].[LiquidacionD2D_security].[dbo].[Employee_backup] values (@val1, @val2 , @val3) -->This NOT
     --else
     --  /* update */
     commit /* locks are released here */
     FETCH NEXT FROM mycur1 INTO @val1, @val2 , @val3
     END
     CLOSE mycur1
     DEALLOCATE mycur1
    END
    GO
    This is the error that a get....
    OLE DB provider "SQLNCLI" for linked server "ESDBCGW001T" returned message "The partner transaction manager has disabled its support for remote/network transactions.".
    Msg 7391, Level 16, State 2, Procedure sp_newrecords, Line 37
    The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "ESDBCGW001T" was unable to begin a distributed transaction.
    All configurations are perfect, and when I run the insert without the variables runs fine,I mean, instead of @val1, @val2 and @val3 I use real values 1, 'A', 'B'.
    PD. Sorry if my english is not so good.
    Edgardo Mancía

    Hi,
    Seems to be a DTC issue.
    These links may help you fix your problem
    http://www.sqlservices.com/web/news.aspx?NewsID=113
    https://social.msdn.microsoft.com/Forums/en-US/7172223f-acbe-4472-8cdf-feec80fd2e64/the-partner-transaction-manager-has-disabled-its-support-for-remotenetwork-transactions?forum=adodotnetdataproviders
    Cheers
    Bhanu

  • How to insert data into two tables linke with foreign key..

    I have two tables
    1)EMP(emp_ID,username,emp_type_code)
    emp_ID is primary key, emp_type_code is a foreign key references emptype table.
    2)emptype(emp_type_code,emp_type_descripton)
    emp_type_code is primary key
    Could anyone help me ..how to insert data into EMP table. How to insert data into two tables linke with foreign key..

    CREATE TABLE "CATDB"."DWDIMUSER"
    "USER_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_ID" NUMBER(10,0),
    "FULLNAME" VARCHAR2(20 BYTE),
    "FNAME" VARCHAR2(20 BYTE),
    "LNAME" VARCHAR2(20 BYTE),
    "USER_SUBTYPE" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMUSER_PK" PRIMARY KEY ("USER_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE,
    CONSTRAINT "DIMUSER_DIMSPECIALTY_FK" FOREIGN KEY ("SPECIALTY_ID") REFERENCES "CATDB"."DWDIMSPECIALTY" ("SPECIALTY_ID") DISABLE
    CREATE TABLE "CATDB"."DIMSPECIALTY"
    "SPECIALTY_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_NAME" VARCHAR2(100 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("SPECIALTY_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    INSERT INTO DIMUSER (FullName, FNAME, LNAME, USER_TYPE, USER_SUBTYPE)
    SELECT DISTINCT
    Engineer AS FullName,
    regexp_substr(Engineer , '[^,| ]+', 1, 1) as FName,
    regexp_substr(Engineer , '[^,| ]+', 1, 2) as LName ,
    'Engineer'
    FROM EMPLOYEELOOKUP;
    INSERT INTO DIMSPECIALTY (SPECIALTY_NAME)
    SELECT DISTINCT SPECIALITY
    FROM EMPLOYEELOOKUP;
    COMMIT;
    CREATE TABLE employeelookup ...IS A TABLE THAT HAS ALL THE DATA NEDED TO BE FILLED IN BOTHE TABLES...
    CREATE TABLE "CATDB"."EMPLOYEELOOKUP"
    "EMPLOYEELOOKUP_ID" NUMBER(10,0) NOT NULL ENABLE,
    "ENGINEER" VARCHAR2(25 BYTE),
    "SPECIALTY" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("EMPLOYEELOOKUP_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    DATA IN EMPLOYEELOOKUP
    Engineer, Specialty,
    John, Dow, Electronis,
    Dow, Jons, Technician
    Stan Smithers Sales
    Mark, Richards Marketing
    Jenny, Lane Marketing
    John, Lee Sales
    I NEED TO LOAD THE FOREIGN KEY IN DIMUSER FROM THE DIMSPECIALTY TABLE?
    BY USING THE LOOKUP TABLE TO MARCH THE NAMES UNDER THE Engineer COLUMN, SPECIALTY COLUMNE DISTICTIVLY BY JOINING THE DIMSPECILTY TO RISTIVE THE PRIMARY KEY AND FILL IT IN THE DIMUSER TABLE AS A FOREIGNE KEY.

Maybe you are looking for