SAP Query join statements

Hello,
I am working on SAP Query in infoset I want to link the MVKE-MATNR to DRAD-OBJKY,
but the length of the two fields are different. So the Query is not allowing the join. Hw can I over come the issue.
Note. One material will have multiple docments.
Thanks,
Ravi.

Hi,
Define the final internal table with the fileds of the both internal table it1 and it2.
the programming logic is like as following.
Loop at it1 with every line item.
move line item of it1(work area) into it_final.
read table it2 with key wa_key (the same primary key field in any table it1 and it2).
move line item of it2(work area) into it_final.
endloop.
try this to fill the it_final like this.
regards,
Pulak.

Similar Messages

  • SAP Query - Joining two tables - SQVI, SQ01

    Hi gurus,
    Can anybody send word documentation of joining any two tables. (Variant creation). Simple and easy to understand with screen shots step by step procedure.

    Got the doc from Google.

  • SAP query

    Hello ABAP Guru
    I need a help here. trying to create SAP query joining three table VBAK VBAP KONV since KONV being cluster table I am not able to do that
    thpough I am suceesfully establishe dthe link
    VBAK-VBELN=VBAP-VBELN
    VBAK-KNUMV=KONV-KNUMV & VBAP-POSNR=KONV-KPOSN
    OSS msg says we have to write routine in sap query
    but I never used that option
    anyone has any clue on how to use cluster table in SAP query?
    Thx
    Praveen

    Hi,
         Inner Join can't be  used for cluster tables.
         Write a routine in SAP query as follows.
          do inner join on vbak,vbap into internal table  
          itab.
           select for konv for all entries itab .           
    Regards
    Amole

  • *SAP Query on Vendor Master*

    Hello SAP Gurus,
    I have created a SAP query joining SAP tables LFM1, LFA1 & ADRCT.
    The join condition is LIFNR for LFM1 & LFA1.
    The join condition for LFA1 & ADRCT is ADDRNUMBER.
    The query is intended to pick the following fields
    Vendor, POrg, ABC indicator & Remark(field in ADRCT table)
    Problem:
    I have 20 records created for LFM1/LFA1, but the query retrieves only 5 records which has value in remark field. Balance 15 records which had null value in remark field is not getting displayed.
    Request:
    Is there a way to retrieve all the 20 records, so that users can know what are the missing vendors(15) which did not have remark field updated. If I remove the join condition between LFA1 & ADRCT all the 20 records are displayed. User wants to execute the query for all the vendors for a particular PORG.
    Thanks in advance for your inputs.
    Regards,
    Narayan.

    Hi Ramesh,
    Thanks for your immediate response.
    I have linked all the common fields. But still it is not working.
    Any idea why this is happening.
    Regards,
    Narayan.

  • SAP Query statements

    Hi guys
    Can any one give me some notes on SAP-Query STATEMENTS.
    I know T.CODES and creation of Info sets, groups etc.
    but  I am finding difficult when i wanted to Join the tables.
    Thanks in Advance.
    Rgds
    BJ

    Hi
    By using T-Code SQVI
    Give query name in QUICK VIEW
    Select the button “Create”
    Select “Table Join” in the field Data source
    Thanks& Regards,
    Subbu.

  • SAP QUERY/INFOSET with OUTER JOIN

    Hi,
    I have created an infoset (SQ02) using two tables for SAP query.
    Table: AGR_TEXTS. Fields: AGR_NAME, SPRAS, LINE, TEXT.
    TABLE: AGR_FLAGS. Fields: AGR_NAME, FLAG_TYPE, FLAG_VALUE.
    Joined these two tables using outer join.  Defined the join condition as AGR_NAME = AGR_NAME.  Saved and Generated the infoset.
    Created SAP Query (SQ01) using the above created infoset.
    In the basic list,
    Marked AGR_NAME (AGR_TEXTS), TEXT, FLAG_VALUE as listed fields.
    Marked AGR_NAME (AGR_TEXTS), SPRAS, LINE, FLAG_TYPE as selection fields.
    Save the query.  When execute the query provided the inputs for all the selection fields in the selection screen as given below:
    AGR_NAME=Z*
    SPRAS=E
    LINE=00000
    FLAG_TYPE=LICENSE_01
    Executed the Query. 
    Got the results only the matched records as per the selection field FLAG_TYPE.
    But I want all the records from table AGR_TEXTS and matched records from table AGR_FLAGS.
    I want the report (output) as below,
    _AGR_NAME                                               TEXT                                                                                  FLAG_VALUE_
    ZCA_BASIC_ACCESS_GLOBAL     Non-critical basic access for all users.                                       53
    ZCA_BASIC_ENDUSER_ACCESS     UK:CA Basic Enduser Access     
    ZCA_BASIC_ENDUSER_ACCESS_UK     UK:CA Basic Enduser Access UK                                        52
    ZCA_BASIC_ENDUSER_SU52_UK     UK:CA Basic Enduser Access to change Parameter ID's     
    But I got the report (output) as below, 
    _AGR_NAME                                                TEXT                                               FLAG_VALUE_
    ZCA_BASIC_ACCESS_GLOBAL     Non-critical basic access for all users.     53
    ZCA_BASIC_ENDUSER_ACCESS_UK     UK:CA Basic Enduser Access UK     52
    Apprecited your help. Thanks.
    Code Formatted by: Alvaro Tejada Galindo on Dec 30, 2009 2:20 PM

    Identify a KF for which there are non-zero values for all accounts in the cube.
    Create the query with Account (from MP coming from both IO and cube) and this KF. KF will have 0 values for accounts not existing in the cube. Create a condition to show only the 0 value for the KF. This should show you all the accounts in the IO which are not in the cube.

  • SAP Query to join action infotype with additional action infotype

    We have created SAP Query on PA0000 which shows all actions that are executed for an employee.
    The problem is that if two actions are exceuted on the same day then it shows only one action instead of showing both the actions.
    As two actions are executed on the same day it will be stored in additional action infotype(0302).We tried to join PA0000(Action infotype) with PA0302(additional action infotype) in SAP Query by using joins(inner join/outer join) but it shows duplicate records.
    Is there any way to get additional action along with records of action infotype without any duplication in SAP Query.

    All entries that are in PA0000 will be in PA0302, but not vice-versa so you just have to reverse what you are currently doing, i.e.: create a Query on PA0302 and join to PA0000, and then make sure your selection criteria is from PA0302 and not PA0000.

  • Query based on "NATURAL JOIN" statement of Oracle9i

    I have created following 4 tables
    create table CUST_MASTER
    (CUST_NO NUMBER(3),CUST_NAME VARCHAR2(20),CUST_CITY VARCHAR2(20));
    create table ITEM_MASTER
    (ITEM_NO NUMBER(2),ITEM_NAME VARCHAR2(20),
    PRICE NUMBER(4));
    create table ORDER_HEADER
    ( ORDER_NO NUMBER(4), CUST_NO NUMBER(3));
    create table ORDER_ITEMS
    ( ORDER_NO NUMBER(4), ITEM_NO NUMBER(2), QTY NUMBER(3));
    Based on the above 4 table I have executed the following query.
    select c.cust_no, c.cust_name, c.cust_city, oh.order_no, i.item_no, i.item_name, i.price, oi.qty
    from cust_master c, item_master i, order_header oh, order_items oi
    where c.cust_no = oh.cust_no and oh.order_no = oi.order_no and oi.item_no = i.item_no;
    How should I build similar query in Oracle9i making use of "NATURAL JOIN" statement?

    Hallo,
    yes you are correct.
    From SQL Reference
    NATURAL JOIN The NATURAL keyword indicates that a natural join is being performed. A natural join is based on all columns in the two tables that have the same name. It selects rows from the two tables that have equal values in the relevant columns
    Nothing about foreign keys.
    Test:
    select * from scott.emp natural join scott.dept
        DEPTNO      EMPNO ENAME      JOB               MGR HIREDATE                  SAL       COMM DNAME          LOC         
            20           7369     SMITH          CLERK                7902     17.12.1980            800                    RESEARCH           DALLAS
            30           7499     ALLEN          SALESMAN             7698     20.02.1981           1600            300     SALES              CHICAGO
            30           7521     WARD           SALESMAN             7698     22.02.1981           1250            500     SALES              CHICAGO
            20           7566     JONES          MANAGER              7839     02.04.1981           2975                    RESEARCH           DALLAS
            30           7654     MARTIN         SALESMAN             7698     28.09.1981           1250           1400     SALES              CHICAGO
            30           7698     BLAKE          MANAGER              7839     01.05.1981           2850                    SALES              CHICAGO
            10           7782     CLARK          MANAGER              7839     09.06.1981           2450                    ACCOUNTING         NEW YORK
            20           7788     SCOTT          ANALYST              7566     19.04.1987           3000                    RESEARCH           DALLAS
            10           7839     KING           PRESIDENT                     17.11.1981           5000                    ACCOUNTING         NEW YORK
            30           7844     TURNER         SALESMAN             7698     08.09.1981           1500              0     SALES              CHICAGO
            20           7876     ADAMS          CLERK                7788     23.05.1987           1100                    RESEARCH           DALLAS
            30           7900     JAMES          CLERK                7698     03.12.1981            950                    SALES              CHICAGO
            20           7902     FORD           ANALYST              7566     03.12.1981           3000                    RESEARCH           DALLAS
            10           7934     MILLER         CLERK                7782     23.01.1982           1300                    ACCOUNTING         NEW YORK
    alter table scott.emp drop constraint fk_deptno
    select * from scott.emp natural join scott.dept
        DEPTNO      EMPNO ENAME      JOB               MGR HIREDATE                  SAL       COMM DNAME          LOC         
            20           7369     SMITH          CLERK                7902     17.12.1980            800                    RESEARCH           DALLAS
            30           7499     ALLEN          SALESMAN             7698     20.02.1981           1600            300     SALES              CHICAGO
            30           7521     WARD           SALESMAN             7698     22.02.1981           1250            500     SALES              CHICAGO
            20           7566     JONES          MANAGER              7839     02.04.1981           2975                    RESEARCH           DALLAS
            30           7654     MARTIN         SALESMAN             7698     28.09.1981           1250           1400     SALES              CHICAGO
            30           7698     BLAKE          MANAGER              7839     01.05.1981           2850                    SALES              CHICAGO
            10           7782     CLARK          MANAGER              7839     09.06.1981           2450                    ACCOUNTING         NEW YORK
            20           7788     SCOTT          ANALYST              7566     19.04.1987           3000                    RESEARCH           DALLAS
            10           7839     KING           PRESIDENT                     17.11.1981           5000                    ACCOUNTING         NEW YORK
            30           7844     TURNER         SALESMAN             7698     08.09.1981           1500              0     SALES              CHICAGO
            20           7876     ADAMS          CLERK                7788     23.05.1987           1100                    RESEARCH           DALLAS
            30           7900     JAMES          CLERK                7698     03.12.1981            950                    SALES              CHICAGO
            20           7902     FORD           ANALYST              7566     03.12.1981           3000                    RESEARCH           DALLAS
            10           7934     MILLER         CLERK                7782     23.01.1982           1300                    ACCOUNTING         NEW YORK
    ALTER TABLE scott.emp
    ADD CONSTRAINT fk_deptno FOREIGN KEY (deptno)
    REFERENCES SCOTT.dept (deptno)
    ENABLE NOVALIDATE
    /Regards
    Dmytro Dekhtyaryuk

  • SAP QUERY(SQ03/02/02) - how to join tables

    Hi MM Wizards,
    I would like to know how to join tables EINE & A017 through SAP Query?
    Thanks,
    Kaveri

    Hi Kaveri,
    A017 is a pooled table.  SAP Query does not support joins against Pooled tables.  You should stick to transparent tables if you want to use Query.
    You can do a direct read of A017, but you will just end up with a glorified SE16 display.
    You could have a programmer write some ABAP and place it into the 'extras' section in SQ02 to grab the additional data that you want, but once you have decided to enlist the aid of an ABAPer, it is better just to write a custom Z program from scratch.
    Regards,
    DB49

  • SAP Query - Need to join 3 Tables via outer join

    Hi,
    I need to join 3 Tables using SAP Query. I wish an OUTER JOIN to be performed for the table join.
    For Example:
    Table 1 has 1000 Entries           Field A             Field B          
    Table 2 has 300 Entries             Field A            Field C
    Table 3 has 100 Entries             Field A           Field D
    The normal Join (INNER JOIN) gives me only the records that exists in all the 3 Tables.
    But what i need is:
    In the above example, If one entry in Table 1 has no matching records in Table 2 / Table 3, there should be an output entry in the SAP Query like
    Field A            Field B              Field C            Field  D
    xxxx              yyyy                  Blank             Blank
    If there is a common record that exists in the tables, that record should appear in the same entry in the Query output.
    Field A            Field B              Field C            Field  D
    xxxx              yyyy                  zzzz              aaaa
    In this way, there should be a minimum of 1000 entries (Largest no of records in the Tables joined). More than 1000 records in the Query output depends on the number of common records.
    Kindly help if you have come across such a scenario.
    thanks & regds
    sriram

    Hi
    Please join the outer join as below
    Table1 with Field A  to Table 2 Field A-----outer join
    Table1 with Field A  to Table 3 Field A------outer join
    then you get the out put as per your requirement
    Regards
    Damu

  • SAP Query not working

    Hi,
    I am facing problem with SAP Query. My query is not working for one particular date. Its giving timeout error when i just give date as input. I tried executing it by giving some particular document as input, then its giving "no data" message but when i check the table data, there are some records for that input condition.
    I debugged it, i found that the statement "FETCH NEXT CURSOR cursorname" is throwing sy-subrc eq 4. I couldn't understand the problem.
    Any inputs will be very helpful.
    Regards,
    Mahidhar.

    Hi Azeem,
    There are more than 10 tables that were used in this query with different types joins like inner join, left outer, right outer join. So i wasnt able to decode the select query that was present in open cursor command.
    I have given the date and executed the same in background. It ran in 19min. But when i add one more input parameter, then its running more than a day(still running ). Didn't get the exact problem still.
    Regards,
    Mahidhar.

  • Query SQL Statement & Update SQL Statement

    Hi!
    I configure the JDBC adapter sender (XI) to take data from MSSQL database.
    I have to run select like this:
    SELECT
    tblMilestone.Site,
    tblMilestone.Revision,
    tblMilestone.MilestoneNameID,
    tblMilestone.ApprovedDate,
    tblMilestoneName.MilestoneName
    FROM
    tblMilestoneName
    INNER JOIN tblMilestone ON tblMilestoneName.MilestoneNameID = tblMilestone.MilestoneNameID
    WHERE tblMilestone.StatusCode = 1;
    My question is what "Update SQL Statement" I should use in communication channel definition? I only need to update tblMilestone or this two tables?
    Maybe you give me some example.

    Check this from SAP help...
    Update SQL Statement
    You have the following options:
    ●     Enter a valid SQL statement that is to be applied to the database once the data (determined from the Query SQL Statement) has been successfully sent to the Integration Server/PCK.
    It must be an INSERT, UPDATE, or DELETE statement.
    &#9679;     In place of the SQL statement, you can also enter <TEST>. Once the data determined from Query SQL Statement has been successfully sent, the data in the database remains unaltered.
    This is recommended if the data has not only been read, but also changed by a stored procedure entered under Query SQL Statement.

  • SAP Query Creation

    Hi All,
    I am creating a SAP query in the system using the tables KONP,MBEW & A018 i could join tables KONP & MBEW but i am not able to add the table A018 and a error message is displayed
    Error Message:
    Table A018 cannot be used in a join
    Message no. AQ501
    Diagnosis
    1. You cannot read the selected table with SELECT statements (because, for example, it is a structure without a database table). Therefore, this table cannot be read within a table join either.
    2. The chosen table is a pool or cluster table. These tables may not be used in a table join.
    Can anyone tell me a alternative to join this table to MBEW & KONP.
    I want this Join Conditions:
    MBEW-MATNR = A018-MATNR
    A018-KAPPL = KONP-KAPPL     
    A018-KSCHL = KONP-KSCHL     
    A018-KNUMH = KONP-KNUMH
    Thanks & Regards
    Andrew
    Edited by: Andrew J on Dec 18, 2008 2:49 PM

    hi,
    use  FOR ALL ENTRIES
    EXAMPLE:
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    REGARDS
    RAHUL

  • SAP Query Genrator Error Again

    Experts,
    select T0.Father 'Parent Item',
    T0.Code 'Children',
    Case
    When T1.ItemType = 'I' Then 'Item'
    When T1.ItemType = 'L' Then 'Labour'
    When T1.ItemType = 'T' Then 'Travel'
    End 'Item Type',
    Case
    When T1.PrcrmntMtd = 'B' Then 'Buy'
    When T1.PrcrmntMtd = 'M' Then 'Make'
    End 'Procurement Method ',
    T1.CardCode 'Preferrd Vendor',
    ISNULL((select T2.Price from OSPP T2 where T2.CardCode = T1.CardCode and T2.ItemCode = T0.Code), 0)'Price of the Item in Special price list ',
    Case
    When T1.ItemType = 'L' Then T1.AvgPrice
    Else 0
    End 'Item Cost (If Labour)'
    from ITT1 T0 inner join OITM T1 on T0.Code = T1.ItemCode
    where T0.Father = '[%0]'
    group By
    T0.Father,
    T0.Code,
    T1.ItemType,
    T1.PrcrmntMtd,
    T1.CardCode,
    T1.AvgPrice
    This gives error i SAP Query genrator . Plz help

    1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. 2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'Received Alerts' (OAIB) (s) could not be prepared.
    For
    select T0.Father 'Parent Item',
    T0.Code 'Children',
    Case
    When T1.ItemType = 'I' Then 'Item'
    When T1.ItemType = 'L' Then 'Labour'
    When T1.ItemType = 'T' Then 'Travel'
    End 'Item Type',
    Case
    When T1.PrcrmntMtd = 'B' Then 'Buy'
    When T1.PrcrmntMtd = 'M' Then 'Make'
    End 'Procurement Method ',
    T1.CardCode 'Preferrd Vendor',
    ISNULL((select T2.Price from OSPP T2 where T2.CardCode = T1.CardCode and T2.ItemCode = T0.Code), 0)
    'Price of the Item in Special price list ',
    Case
    When T1.ItemType = 'L' Then T1.AvgPrice
    Else 0
    End 'Item Cost (If Labour)'
    from ITT1 T0 inner join OITM T1 on T0.Code = T1.ItemCode
    inner join OSPP t2 on t2.ItemCode = T1.itemcode
    where T0.Father = '[%0]'
    group By
    T0.Father,
    T0.Code,
    T1.ItemType,
    T1.PrcrmntMtd,
    T1.CardCode,
    T1.AvgPrice

  • SAP Query- Reporting on SOD

    Hello everyone,
    I need some help in creating a report in SAP Query based on user's processing Vendor Invoices and also Vendor Payments?
    I would like to have the following columns to report on:
    USNAM u2013 User Name (from BKPF)
    BLDAT u2013 Document Date (from BKPF)
    BELNR u2013 Document Number (from BKPF)
    BUKRS u2013 Company Code (from BKPF)
    BLART u2013 Document Type (from BKPF)
    LIFNR u2013 Vendor Number (from BSEG)
    NAME1 u2013 Vendor Name (from LFA1)
    WRBTR u2013 Amount (from BSEG)
    Vendor Invoice- I would like to restrict to only document type fields that are KA,KR,RC,RE,RN and ZE
    Vendor Payment- I would like to restrict to only document type fields that are ZV,ZS,ZP,ZH and KZ
    I have a few questions:
    First is i am using a logical database (BRM as BSEG cannot be joined) to select my columns however i do not know how to pull the 'Vendor Name' from LFA1. I understand that this table is not in BRM but is there a way to add any extra tables to work along side the logical database?
    Secondly, i have managed to report on all columns except the vendor name (from LFA1) and although i can restrict my output data based on document type fields, i need the report to only show the user's that have process vendor invoices & vendor payments only?
    At the moment i have a list of restricted document type but cannot seem to jsut show only those users who have processed both in both processes. For example User A has processed a vendor invoice (which is shown) and the same user may have processed vendor payment (after searching through the long output list!)
    I want all users who have doen one of the other process and only interested in those that have done both?
    Any feedback is much appreciated and pelase let me know if i have not explained this problem properly (as i am a newbie in this area)
    Many thanks
    Amar

    Hi Pascal,
    Since the IT2501 is a "Simulated Time Infotype" you cannot look at the data in it, but you can confirm the data from the ZL cluster and the data from the employee.  Since it is only this employee or a few employees, it is probably not the configuration of the time buckets for the IT2501, but you may want to make sure all time times are captured as you want.  Then look at the time entries for this individual or individuals.  Did they enter a time type that was not expected or configured?  Is all their time approved and passed through Time Evaluation?  Finally check the Master Data for the employee - is the Planned Working Time (IT0007) infotype correct or has it been recently changed?  Is he in a special Cost Center (IT0027) or Project that is captured differently for time purposes? 
    Since it just one or a few individuals, I would suspect the Master Data and some inconsistant entry that affects the time cummulation for the IT2501.
    Paul

Maybe you are looking for