ALV OOps report- getting data from two tables and adding issue

Hi,
This is sales employee performance report.
I need to select all the fields from two tables based on user input ie VKorg, sales employee .
There is one field callled " Net sales"in both the tables.
Based on sales employee number, i need to add that net sales which i get from two tables.
I need to generate single report.
Can you give some inputs reg. the select query.
My idea is select all the data from both tables using join statement.
Thanks

Hi,
I have written like this:
select * from S002 as a join S006 as b
    into table ME->SS002_RAW[]
    where vkorg in me->select_parameters->SO_VKORG[] = vkorg in me->select_parameters->SO_VKORG[]
          and ZZSLSEMP01 in me->select_parameters->SO_so_empl[] = ZZSLSEMP02 in me->select_parameters->SO_so_empl[].
when i do like that,
I am getting error
Incorrect structure of FROM clause . . . .     
If you give some idea on this
Edited by: Raja on Apr 22, 2009 11:19 AM

Similar Messages

  • Fetch data from two tables and insert into one table

    I have similar to the following data in two tables (@Plant, @PlantDirector) and need to consolidate into one table (@PlantNew) as follows.
    DECLARE @Plant TABLE (PlantID INT, PlantName VARCHAR(100))
    INSERT INTO @Plant (PlantID, PlantName) VALUES (1, 'Name One'),(2, 'Name Two'),(3, 'Name Three'),(4, 'Name Four'),(5, 'Name Five'),(6, 'Name Six')
    Director data for the Plants exist in the following table. Assistant value 1 means Assistant Director and 0 means Director. 
    Data exists only for subset of plants and a Plant may have one or both roles.
    DECLARE @PlantDirector TABLE (PlantID INT, PlantDirectorID INT, Assistant bit)
    INSERT INTO @PlantDirector (PlantID, PlantDirectorID, Assistant) VALUES (2, 111, 1),(2, 222, 0),(4, 333, 0),(6,444,1)
    The above data needs to be inserted into one table (@PlantNew) as follows: 
    PlantID in @Plant table is IDENTITY value and needs to be inserted as-is into this table.
    PlantDirExists will get a value of 1 if at least one record exists in @PlantDirector table for a PlantID. PlantAssistantDirID and PlantDirID should be set to the corresponding PlantDirID or NULL appropriately depending on the data.
    DECLARE @PlantNew TABLE (PlantID INT, PlantName VARCHAR(100), PlantDirExists bit, PlantAssistantDirID INT, PlantDirID INT)
    INSERT INTO @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
    VALUES (1, 'Name One', 0, NULL, NULL),(2, 'Name Two', 1, 111, 222),(3, 'Name Three', 0, NULL, NULL),(4, 'Name Four', 1, NULL, 333),(5, 'Name Five', 0, NULL, NULL),(6, 'Name Six',1, 444, NULL)
    How do I achieve the above using SQL ? Thanks.

    like this
    INSERT @PlantNew  (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID) 
    SELECT p.PlantID,
    p.PlantName,
    CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
    PlantAssistantDirID,
    PlantDirID
    FROM @Plant p
    LEFT JOIN (SELECT PlantID,
    MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
    MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
    @PlantDirector
    GROUP BY PlantID)pd
    ON pd.PlantID = p.PlantID
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    You're missing a FROM
    insert into @PlantNew
    SELECT p.PlantID,
    p.PlantName,
    CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
    PlantAssistantDirID,
    PlantDirID
    FROM @Plant p
    LEFT JOIN (SELECT PlantID,
    MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
    MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
    from @PlantDirector
    GROUP BY PlantID)pd
    ON pd.PlantID = p.PlantID

  • Line Chart - getting data from two table to behave as 1 data series

    I'm using the 'Personal Budget' template, and have two tables titled 'Annual Budget by Month: 2009' and 'Annual Budget by Month: 2010'. These tables show, as their last row, my total savings. I want to set up a line chart to display the (downward) trajectory of my savings in one continuous line.
    However, if I create a line chart, the two data sets from the two tables are displayed as two lines, one below the other. If I convert it to a column chart, and then switch to columns instead of rows as the Plotting Orientation (data series button in the upper left of the table), the columns do display correctly. Can anyone tell me how I can get the line version to work?

    spiff,
    I think the solution to your problem is to create a summary table that gathers the data from all your month tables, then plot the summary. Remember to put the category names into a Header row or column so they will automatically show up on the chart axes.
    Jerry

  • GETTING DATA FROM TWO TABLES.

    Hi,
    I am having i_matgrp table with fields matkl , l_sum , l_t_sum.
    I need to get material group description(wgbez,wgbez60) from t023t table for each matkl in i_matgrp
    and put all 3 fields and descriptions(2 fields) in to a single table i_display for display.
    please suggest select query for this...
    Thanks in advance.

    I am having i_matgrp table with fields matkl , l_sum , l_t_sum.
    I need to get material group description(wgbez,wgbez60) from t023t table for each matkl in i_matgrp
    and put all 3 fields and descriptions(2 fields) in to a single table i_display for display.
    please suggest select query for this...
    hi.
    sorry do like in this way.just copy paste it and check t
    but also paste ur code for the internal table of i_matgrp which u have made
    data: begin of itab,
    matkl like t023t-matkl,
    wgbez like t023t-wgbez,
    wgbez60 like t023t-wgbez,
    end of itab.
    data:wa_itab like itab.
    data:wa_i_matgrp like i_matgrp.
    data: begin of i_display,
    matkl like t023t-matkl,
    l_sum type i,
    l_t_sum type i, "these two fields can be according to ur need,
    wgbez like t023-wgbez,
    wgbez60 like t023t-wgbez60,
    end of i_display.
    data: wa_i_display like i_display.
    select matkl wgbez wgbez60 into corresponding fields of itab
    from t023t FOR ALL ENTRIES IN i_matgrp
    where matkl = i_matgrp-matkl.
    loop at i_matgrp into wa_i_matgrp.
      MOVE-CORRESPONDING wa_i_matgrp to wa_i_display.
      read table itab into wa_itab WITH KEY matkl = wa_i_matgrp-matkl.
       MOVE-CORRESPONDING wa_itab to wa_i_display.
      append wa_i_display to i_display.
    endloop.
    Edited by: tahir naqqash on Feb 17, 2009 1:07 PM

  • Retrieve data from two tables and store it in one itab

    Hi All,
    i have an internal table of structure which has fields ar_object and objecttext.
    I want to retrieve all the ar_object from table toaom for object type BUS2012 and then the corresponding objecttext from toasp where toaom-ar_object = toasp-ar_object and then store both this values in my internal table.
    what is the best method to do it ?  Please let me know if you want to know how i am doing it right now
    thanks,
    Golu

    Hi,
    You can get many ways 
    1. using  For all entries in 
    2. using Inner join
    3. you can get 2 tables data into 2 different internal tables  and   loop first internal table and read second internal using key fields append it another internal table or modify second internaltable.
    In above ways 1st and 2nd are performance issues.   the best way is
    get TOAOM table data into itab1 and get TOASP table data into itab2 you can append data into another itab3 or modify itab2
    regards,
    Ganesh

  • SaveToFile example modificati​on to get data from two channels simultaneo​usly.

    We are trying to modify the “SaveToFile” example for C++. This particular example comes with NI-scope 2.9.1 and some other versions. This example collects data from one channel and saves the output as a text file. Also, we are using NI PCI-5112 DAQ.
    However, it can be modified to get data from channel 0 and channel 1 at the same time. There is a help file called “Fetching Multiple-Record Acquisitions”, which is under the NI-High speed digitizer help topics. This confirms that you can modify the code to get data from two channels and the output will be a text file where every other value is from one channel. This help file also gives some code. However, it is not very much helpful to us, please keep in mind that we have only taken a basic course in C++.
    Our project is to analyze the data, however, we need to acquire the data before we can analyze. We have spent so much time trying to get the data.  What we need to do is get data from both channels simultaneously and output the data as a text file.
    Can anyone help us to modify the code so it can get data from both channels simultaneously? Or can anyone help as where we can get more information? Or does anyone know of any sample examples that will take data from two channels simultaneously and output the data as a text file or any other type of document.
    Any help will be really appreciated, as we have spent so much time trying to acquire the data.
    Thanks.

    Hi Finomad,
    Please see this post for an answer to your question.
    Regards,
    Natasa

  • How to get data from a table in a condition between twomonth

    hai friends
    I have a query that is i want to get data from a table based on a condition between two months in a format of char column
    Ex
    I have a column called from_month in the format of 'mon/yyyy'(already converted from date')
    then the second column is to_month in the same format 'mon/yyyy'
    now i wiil select from_month and to_month like
    from month jan/2009
    to month mar/2010
    how to use between of two months in the format of char.Please tell me how to get two different month between data.

    Hi,
    This may be of help.
    Remember Pointless has made a point ;) (worth millions)
    If possible , DO NOT store dates as strings or numbers.Let dates be dates.
    WITH dat AS
    (SELECT ' THIS IS JAN' x,to_char(to_date('01-JAN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS FEB' x,to_char(to_date('01-FEB-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAR' x,to_char(to_date('01-MAR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS APR' x,to_char(to_date('01-APR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAY' x,to_char(to_date('01-MAY-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUN' x,to_char(to_date('01-JUN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUL' x,to_char(to_date('01-JUL-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS AUG' x,to_char(to_date('01-AUG-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS SEP' x,to_char(to_date('01-SEP-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS OCT' x,to_char(to_date('01-OCT-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS NOV' x,to_char(to_date('01-NOV-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual)
    SELECT * FROM dat
    WHERE to_date(y,'mon/yyyy') BETWEEN to_date('01 jan 2009','dd mon yyyy') AND to_date('01 mar 2009','dd mon yyyy')Cheers!!!
    Bhushan

  • Problem reading data from two tables

    Hi experts,
    I'm developing a JDBC - IDOC scenario that needs to read data from two oracle tables. I have created a BPM that has a initial fork for the two channels and it works fine.
    The problem is that I need to read data from the first, two or both tables depending if there is data to read. If there is data in the two tables it works, but if only there is data in one of the two tables, I have read problems. I have tryed to set the 'neccesary branches' to 1 but this is a problem when I have data in both tables.
    Any idea?
    Best Regards,
    Alfredo Lagunar.

    Hi,
    have your fork step inside a block and then right-click your block to insert a deadline branch to your BPM process and specify the time after which your BPM process should be cancelled.....so if in that time, you get data from both tables, your BPM will work okay otherwise if that time is over, then your BPM process will be cancelled.
    Regards,
    Rajeev Gupta

  • Cartesian of data from two tables with no matching columns

    Hello,
    I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
    I am thinking about something like:
    for $COUNTRY in ns0: COUNTRY ()
    for $PROD in ns1:PROD()
    return <Results>
         <COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
         <PROD> {fn:data($PROD/PROD_NAME)} </PROD>
    </Results>
    And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
    What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
    What I’ve noticed also is that when I add something like:
    where COUNTRY_NAME != PROD_NAME
    everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
    So the question is – what’s the suggested approach for such queries?
    Thanks,
    Leszek
    Edited by xnts at 11/19/2007 10:54 AM

    Which in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
    Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
    If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so.

  • Creating a external content type for Read and Update data from two tables in sqlserver using sharepoint designer

    Hi
    how to create a external content type for  Read and Update data from two tables in  sqlserver using sharepoint designer 2010
    i created a bcs service using centraladministration site
    i have two tables in sqlserver
    1)Employee
    -empno
    -firstname
    -lastname
    2)EmpDepartment
    -empno
    -deptno
    -location
    i want to just create a list to display employee details from two tables
    empid firstname deptno location
    and same time update  in two tables
    adil

    When I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list.  When I attempt to edit it, I get an error:
    External List fails when attached to a SQL view        
    Sorry, something went wrong
    Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
    I can edit the view in SQL Manager, so it seems strange that it fails.
    Any advice would be greatly GREATLY appreciated. 
    Thanks,
    Randy

  • Getting data from REGUP table

    Hi All,
    I am working on a report where i need to get the data from few tables and get it displayed, in the requirement I need to get some data from REGUP based on the vendor and then I am trying to retrieve the information from PAYR table such as check #, check date. So far I have tried selecting the information from REGUP using the vendor number entered by the user and then I am doing a select on PAYR to get the other information for all the entries in my REGUP internal table. Using a simple select statement is taking lot of time and I am having performance issues, can you please suggest any better approach? I understand REGUP is a huge table.
    Thanks,
    Raj

    Hi Raja,
    RUGUH is Payment header table and REGUP is payment item table.
    If your basic requirement is to pick data from PAYR table only then why don't you write query as below,
    Select
    laufd
    laufi
    hktid
    hbkid
    from reguh
    into table it_data_reguh
    where ZBUKR = 'ZTC'
    AND    lifnr in s_lifnr.
    sort it_data_reguH.
    select chect
               bancd
    for all entries in it_data_reguH
    into table it_data_payr
    where ZBUKR = 'ZTC'
    AND hbkid = it_data_reguH-hbkid
    AND HKTID = it_data_reguH-hKTid
    AND laufd = it_data_reguH-laufd
    and  laufi =  it_data_reguH-laufi.
    After doing above you can pick entries from REGUP if required as REGUP contains item details against the paymnt header details IN REGUH, you will also find all key fields of REGUP table from REGUH table hence your performance will definitely get improve.
    Hope it will help you.
    Regards,
    Umang Mehta

  • Get data from two databases?

    Hello all,
    Do anyone know if it's posible to get data from two databases while I'm running SBO in one of them? I need this because our client wants to be able to print reports with all the information stored in both companies. I searched this forum trying to find if this is possible but I did't find any information about this.
    Can someone help me?
    Thanks and regards,
    Mariana Mazzero

    Hi Mariana,
    What you can do is use two company objects to retrieve the data. As far as I know you're not restricted to one company connection.
    You can also just use a standard read only connection (like ADO/ODBC) to retrieve the data for the reports.
    Hope it helps,
    Adele

  • 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.
    Ramesh

    Hi,
       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 get data from COSP table, field HRKFT as the key to data from PM?

    Dear ladies and gentlemen!
    I need to get data from COSP table, field HRKFT as the key to data from PM tables (AFKO and AUFK).
    The problem is that it is a key field to the COSP, and all non-key fields as an alternative to HRKFT are not suitable for this task.
    All this is necessary for the extractor, which loads the data from the R \ 3 systems in the BW-system. I need to perform SELECT from a table COSP and maybe also JOIN, most likely between tables COSP and AUFK.
    What should I do in this case?
    Thank you very much in advance!

    From information on help.sap.com I've made a conclusion that one of possible solutions in theory is to modify standard extractor PM_OM_OPA_1 in order to make HRKFT field available for work, because by default it is hidden by SAP and not available for use as a key field.
    Of course, it's not a very good solution, but for now I know no other way to solve this problem.
    Maybe someone knows better ways? In this case I will be very grateful for any help!
    Moderator: You'd better post it on BI forums

  • Select data from two tables...!

    HI Experts...!
    i m a beginner user and i want to select data from two tables proj and prps.....using joins.....and internal tables i have written a code...
    SELECT prps~pspnr
           prps~objnr
           prps~psphi
           proj~ernam
           proj~erdat
           proj~pspnr
    INTO  table itab   -
    itab is internal table
    FROM prps inner join proj
    WHERE pspnr in p_no and prpspsphi = projpspnr.
    but there is error in from clause ..please help me....
    Advance thanx....

    Hi,
    check the sample code bellow above two reply will solve out your problem but one more extra line in your code pointed out bellow.
    TABLES: prps, proj.
    TYPES:  BEGIN OF ty_test,
            pspnr LIKE prps-pspnr,
            objnr LIKE prps-objnr,
            psphi LIKE prps-psphi,
            ernam LIKE proj-ernam,
            erdat LIKE proj-erdat,
            END OF ty_test.
    DATA: itab TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
    SELECT-OPTIONS: p_no FOR prps-pspnr.
    SELECT  prps~pspnr
            prps~objnr
            prps~psphi
            proj~ernam
            proj~erdat
    *        proj~pspnr " No need for this you have selected this in
    *     the first line because it is commone so you only need to select from any one
            INTO TABLE itab
    FROM prps INNER JOIN proj ON ( prps~pspnr = proj~pspnr  )
    WHERE prps~pspnr IN p_no.
    Best Regards,
    Faisal
    Edited by: Rob Burbank on Dec 24, 2009 12:24 PM

Maybe you are looking for

  • Whitespace removed in Content Conversion

    Hey! After content converting a flat file and running it through an xslt mapping, the java mapping need to find substrings within some fields. It turns out the fields are suppressed, meaning the whitespace before and after values are missing. Can thi

  • Embed Video: Playback error | How to use?

    Hello everyone, I'm trying to insert different videos into a multistate, they're like 10-15 seconds videos and the idea is to be able to play them inside the presentation (folio). I'm creating this for an Android device. I've been trying with several

  • Dual G4 1.8 GHz on steroids?

    Hi all, I'm contemplating purchasing a Mac Dual 1.8 GHz system. Apparently it's been upgraded as I don't believe Apple sold dual 1.8 stock systems. A screen snapshop shows such under the hardware overview: PowerMac G4 PowerMac 3,5 PowerPC G4 (0.0) Pr

  • Large images look pixelated in Keynote 6.2.2

    Hi, I'm having a problem with Keynote 6.2.2 whereby a very tall image I use (770w 15,000h pixels) looks really pixelated when I insert it. I use this image with magic move to create a content strip the presenter can work through.  A bit like a twitte

  • HT4095 Movie rental not showing up

    I paid for a movie rental, but it didn't download. It shows up in my videos but it isn't viewable. I can't find it to download in iTunes either. So how do I go about "redownloading" this?