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.

Similar Messages

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

  • Could anyone provide the complete manual of SAP Query Creation

    Hi,
    Now I am learning to create SAP Query.
    I viewed many questions and answers about SAP Query.
    Some mentioned this,and some did that...
    Could anyone provide a complete manual of SAP Query Creation for developers.
    I can create SAP Queries step by step with it.

    http://help.sap.com/saphelp_46c/helpdata/en/35/26b413afab52b9e10000009b38f974/content.htm
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Introduction.asp
    Step-by-step guide for creating ABAP query
    http://www.sappoint.com/abap/ab4query.pdf
    ABAP query is mostly used by functional consultants.
    SAP Query
    Purpose
    The SAP Query application is used to create lists not already contained in the SAP standard system. It has been designed for users with little or no knowledge of the SAP programming language ABAP. SAP Query offers users a broad range of ways to define reporting programs and create different types of reports such as basic lists, statistics, and ranked lists.
    Features
    SAP Query's range of functions corresponds to the classical reporting functions available in the system. Requirements in this area such as list, statistic, or ranked list creation can be met using queries.
    All the data required by users for their lists can be selected from any SAP table created by the customer.
    To define a report, you first have to enter individual texts, such as titles, and select the fields and options which determine the report layout. Then you can edit list display in WYSIWYG mode whenever you want using drag and drop and the other toolbox functions available.
    ABAP Query, as far as I Believe, is the use of select statements in the ABAP Programming. This needs a knowledge of Open SQL commands like Select,UPdtae, Modify etc. This has to be done only by someone who has a little bit of ABAP experience.
    To sum up, SAP queries are readymade programs given by SAP, which the user can use making slight modification like the slection texts, the tables from which the data is to be retrieved and the format in which the data is to be displayed.ABAP queries become imperative when there is no such SAP query existing and also when there is a lot of customizing involved to use a SAP Query directly
    use either SQ02 ans SQ01
    or SQVI tr code
    for more information please go thru this url:
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Create_The_Query.asp
    http://goldenink.com/abap/sap_query.html
    Please check this PDF document (starting page 352) perhaps it will help u.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVQUE/BCSRVQUE.pdf
    check the below link will be helpful for u
    Tutorial on SQVI
    once you create query system generates a report starting with AQZZ/SAPQUERY/ABAGENCY2======= assing this report to tr code for the same
    useful
    http://www.erpgenie.com/abap/code/abap47.htm
    regards,
    Prabhu
    reward if it is helpful

  • SAP Query - Modfication/Changes

    Hi Experts,
    I am new SAP Query, so i have come up with this issue. Please help.
    I have an infoset query with me, also a SAP query and a transaction with some Z transaction code, the program name as taken from System->Status is AQZZZSD=========Z_SD_ORD_WO_ST.
    1. Now I can see code in the program, but I cant see that much of code in the SQ02 under extras tab. 
    2. Moreover, I have to change the code to address new requirements. How can I change the code in a SAP query???
    What are the ways to change an existing SAP query's code ???
    Thanks,
    Chandan

    Hi Chandan,
    Go to Infoset (SQ02) in change mode, click on Code icon (Sfift + F8) displayed on Application bar.
    You will find, 'Code section' where different events are listed. You can write your code in any of listed events depending on your need.
    For ex. if you want declare any variable in u2018DATAu2019 Section, to initialize any variable can use INITIALIZATION event.
    If you want to perform operation on selection screen you can use 'AT SELECTION-SCREEN OUTPUT'
    And most important event for this tool is Record Processing event like if you want to have any condition and calculation or modification of field value, you can write code in this event.
    END OF SELECTION BEFORE LIST--> You can write header information in this event. After this information, your output is displayed. (User WRITE statement to write your information)
    END OF SELECTION AFTER LIST--> You can write footer information in this event. After query output, information mentioned in this event is displayed.
    Note: END OF SELECTION BEFORE LIST and END OF SELECTION AFTER LIST work only when output format of your query (SQ01) is u2018ABAP LIST'
    GET and GET LATE: When you select a logical database as a data source of an infoset, you get this additional event to maintain the code as per your need for LDB.
    Please let me know if you need any further details.
    Regards,
    Dinesh
    Edited by: Dinesh Tiwari on Sep 30, 2009 7:21 AM

  • Help needed on creating a SAP query

    Hi All,
    Can somebody give me the step by step procedures of creating a SAP query and Infoset.
    My requirement is to display asset master details with Asset number or Asset class as input.
    Any pointers or links to create an infoset and query will br highly helpful.
    Thanks,
    Arun

    Here are couple of fields you might be needed :
    AGKO     Cleared Accounts
    ANAR     Asset Types
    ANAT     Asset type text
    ANEK     Document Header Asset Posting
    ANEP     Asset Line Items
    ANEV     Asset downpymt settlement
    ANKT     Asset classes- Description
    ANLA     Asset Master Record Segment
    ANLB     Depreciation terms
    ANLC     Asset Value Fields
    ANLH     Main asset number
    AT02T     Transaction Activity Category- Description
    AT02A     Transaction Code for Menu TIMN
    AT10     Transaction type
    AT10T     Name of Transaction Type
    BKDF     Document Header Supplement for Recurring Entry
    BKORM     Accounting Correspondence Requests
    BKPF     Accounting Document Header
    BLPK     Document log header
    BLPP     Document log item
    BLPR     Document Log Index and Planned Order (Backflush)
    BNKA     Bank master record
    BP000     Business Partner Master (General Data)
    BPBK     Doc.Header Controlling Obj.
    BPEG     Line Item Total Values Controlling Obj.
    BPEJ     Line Item Annual Values Controlling Obj.
    BPEP     Line Item Period Values Controlling Obj.
    BPGE     Totals Record for Total Value Controlling obj.
    BPJA     Totals Record for Annual Total Controlling Obj.
    BSAD     Accounting- Secondary Index for Customers (Cleared Items)
    BSAK     Accounting- Secondary Index for Vendors (Cleared Items)
    BSAS     Accounting- Secondary Index for G/L Accounts (Cleared Items)
    BSEC     One-Time Account Data Document Segment
    BSEG     Accounting Document Segment
    BSID     Accounting- Secondary Index for Customers
    BSIK     Accounting- Secondary Index for Vendors
    BSIM     Secondary Index, Documents for Material
    BSIS     Accounting- Secondary Index for G/L Accounts
    CEPC     Profit Center Master Data Table
    CEPCT     Texts for Profit Center Master Data
    COBRA     Settlement Rule for Order Settlement
    COBRB     Distribution Rules Settlement Rule Order Settlement
    COKA     CO Object- Control Data for Cost Elements
    COSP     CO Object- Cost Totals for External Postings
    COSS     CO Object- Cost Totals for Internal Postings
    CRCO     Assignment of Work Center to Cost Center
    CSKA     Cost Elements (Data Dependent on Chart of Accounts)
    CSKB     Cost Elements (Data Dependent on Controlling Area)
    CSLA     Activity master
    FEBEP     Electronic Bank Statement Line Items
    FPLA     Billing Plan
    FPLT     Billing Plan- Dates
    GLPCT     EC-PCA- Totals Table
    KNA1     General Data in Customer Master
    KOMK     Pricing Communication Header
    MAHNV     Management Records for the Dunning Program
    REGUT     TemSe - Administration Data
    SKA1     G/L Account Master (Chart of Accounts)
    SKAT     G/L Account Master Record (Chart of Accounts- Description)
    SKB1     G/L account master (company code)
    T003T     Document Type Texts
    T007S     Tax Code Names
    T087J     Text
    TAPRFT     Text tab. for investment profile
    TKA01     Controlling Areas
    TKA09     Basic Settings for Versions
    TKVS     CO Versions
    TZB0T     Flow types text table
    TZPAT     Financial Assets Management product type texts
    VBSEGS     Document Segment for G/L Accounts Document Parking
    VTBFHA     Transaction
    VTBFHAPO     Transaction Flow
    VTBFHAZU     Transaction Activity
    VTBFINKO     Transaction Condition
    VTIDERI     Master Data Listed Options and Futures
    VTIFHA     Underlying transaction
    VTIFHAPO     Underlying transaction flows
    VTIFHAZU     Underlying transaction status table
    VTIOF     Options Additional Data
    VWPANLA     Asset master for securities

  • SAP Query : Save to file in XLS format in background

    Hello everybody,
    I used the enhancement SQUE0001 for saving result (an XLS file) of SAP query in background.
    I used also the ABAP commands 'OPEN DATASET', 'TRANSFER' and 'CLOSE DATASET' as described in the SAP note 537735.
    The execution of SAP query generated multiple columns. But when I go to see my downloaded file (.xls), all generated columns are condensed into 1  !!!
    How to save the file (.xls) and keep the separated columns, please?
    Thanks for your answers.

    For saving the file in Excel format in the App server you have to first convert the data in XLS format and then use the transfer statement.
    You can either use FM SAP_CONVERT_TO_XLS_FORMAT for that.
    OR
    Create a comma sepreated file which will open in excel.
      open dataset file for output in text mode.
      loop at itab.
        concatenate itab-field1 itab-field2 itab-field2 into str
                      separated by ','.
        transfer str to file.
      endloop.
      close dataset file.

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

  • Is it possible to use aggregation function in SQ Sap query?

    I need to create a sap query like using SELECT MAX(begda) statement.
    Please teach me how...
    Thank u in advance..

    Hi Ella,
    You can very well use the aggregate functions in sql which is usually a performance tuning technique.
    A calculation that is made on several records or cells of data. SUM, AVG, MAX, MIN and COUNT are examples of aggregate functions that are used in spreadsheets and database programs.
    SELECT ( ( ] ...
    MAX: returns the maximum value of the column
    MIN: returns the minimum value of the column
    AVG: returns the average value of the column
    SUM: returns the sum value of the column
    COUNT: counts values or lines as follows:
    · COUNT( DISTINCT ) returns the number of different values in the column.
    · COUNT( * ) returns the total number of lines in the selection.
    Ex:    DATA: fldate LIKE sbook-fldate,
          count  TYPE i,
          avg    TYPE p DECIMALS 2,
          max    TYPE p DECIMALS 2.
    SELECT fldate COUNT( * ) AVG( luggweight ) MAX( luggweight )
           FROM sbook
           INTO (fldate, count, avg, max)
           WHERE carrid = 'LH' AND
                 connid = '0400'
           GROUP BY fldate.
      WRITE: / fldate, count, avg, max.
    ENDSELECT.
    For further info:
    http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3990358411d1829f0000e829fbfe/content.htm
    http://help.sap.com/abapdocu/en/ABAPSELECT_AGGREGATE.htm
    Thanks and Regards
    Srikant.P
    Edited by: SRIKANTH P on May 27, 2009 9:41 AM

  • 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

  • Concatenate 2 fields in SAP Query

    Hello,
    We have a requirement where we have developed a report in SAP query, but we require a local field to basically give the concatenation of two fields detailed in the info set (EKPO-EBELP & EKET-ETENR)
    Can you help me with how to learn to do this?
    Many thanks
    Steve

    Hi Rich,
    Yes, I figured the code would be something like that, however, when I generate the infoset, I get the following:
    Global syntax check
    Additional Fields
    Error in code for additional field ITSCH
    The last statement is not complete (period missing)
    I have placed the following code in the Additional fields/structure section
    Concatenate EKET-EBELP EKET-ETENR into ITSCH
    Can you help with what is probably a simple issue?
    Many thanks
    Steve

  • Sap Query sq01: how to combine substrings in complex calculations

    I made a query with sap query. I made 1 local field: name1. I have 2 fields firstname and lastname and a field named class.
    In the complex calculations screen I made the following calculation for that field:
    Condition: CLASS='1'
    Formula: firstname' 'lastname
    When I try to run this query I get an Abap error saying "unable to interpret [firstname] as a number". It looks like the + expression can only be used here for numeric calculations.
    Does anyone know how to solve this?
    Edited by: J S on Jan 27, 2009 11:52 AM

    Hi,
    i think its better to concatenate in the infoset code section.... you create a local filed in infoset of type char and then write the concatenate statement of abap and keep first name and last name in the local field .... write this code in the record processing section and take this local filed and display it in the  query i think this clears you ..
    by the way if you still want any information let me know

  • Sap Query Additional Fields using  Abap Code

    Hi Experts,
    I am relatively new to the world of SAP query (Log Database PNPCE), I have written a number of additional fields to retrieve previous info-type data using the select statement E.G
    prev_endda = p0008-begda - 1.
    SELECT  single bsgrd
          INTO FTE1
          FROM
            pa0008
          WHERE pernr EQ  P0008-pernr
          AND   endda EQ prev_endda
    Although I can retrieve the previous info-type data , I was wondering if there was a easy way where I could take this a step further and show the Previous , Previous record. I.E
    Pernr     FTE Current    FTE1      FTE2
    101              60%          30%       75%
    I guess what I am asking is , is there a way to loop through the HR info-type records, does anybody know if there is a standard function or macro I can use to achieve this.
    Your help is much appreciated.

    Hi ,
    Thanks for our reply.
    I have pasted some example code into my additional field which I have created in SAP Query But im not sure how the loop bit works and how I can populate the additional fields that I have created , could you please explain this
    CALL FUNCTION 'HR_READ_INFOTYPE'
      EXPORTING
        pernr                 = '000000019'
        infty                 = '01'
        BEGDA                 = '18000101'
        ENDDA                 = '99991231'
      tables
        infty_tab             = p0008
      EXCEPTIONS
        INFTY_NOT_FOUND       = 1
        OTHERS                = 2
        LOOP AT p0008.
    NOT SURE WHAT TO PUT IN THIS SECTION *****
      ENDLOOP.
    I have created 3 additional Fields in the infoset Current FTE ,FTE1 FTE2 , and I want to loop through the records and populate the relevant Additional field with the employees FTE  (I only want to populate  where there is a change)
    Sample Data
    Begda              Endda             FTE        Salary
    1/1/2010         31/12/999       60%         19K          (Current  FTE)
    01/08/2009     31/12/2009     100%       27k           (FTE1)
    01/07/2008     31/7/2009         50%       17K          (FTE2)
    Thanks in anticipation
    DM

  • 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

  • Question regarding SAP query (SQ01& SQ02)

    Hello everyone,
    I have been assigned a task of creating a SAP query in SQ01. The report requires me to incorporate a drill down functionality.
    i.e. when I double click on a material I should be able to see the components of that material.
    My question is "Is it possible to incorporate a drill down functionality in a Query through SQ01".
    If yes then how.
    Please provide me with some documentations or example codes for this.
    Regards,
    Deepti Jain.

    Deepti,
    There are 2 ways to get the output  From SAP query.
    1.Under record processing :
          if you don't write any code in Start of selection event for output
         (WRITE statements)  we can not have any control on that.
    2. Under start of selection event :
         If you write any code in START OF SELECTION event like
         get the data in internal table and loop the internal table
         In loop WRITE statement to display with format and try to use
        Interactive report commands Here. I think it will work fine.

  • Want to delete Rows from SAP Query which have u20180u2019 or blank values

    Hi Experts,
    I have made one sap-query,  in that I have added some additional fields, after that I am getting some blank or u20180u2019 values in some rows, can anyone tell me how to delete those rows which have u20180u2019 or blank values.
    Regards
    Mahadev Roy

    Hi mahadev
    You must be fetching data from SQ02 in some internal table.Delete values from that internal table.
    Also as you are fetching records from SQ02 then in the select statement you can put this condition of '0' and blank
    so that you will get appropriate result.
    Thanks
    Khushboo

Maybe you are looking for

  • PO SMS to vendor

    Dear All,               I want to send sms to vendor at the time of purchase order creation (ME21N). but issue is no user exit or BADI (ME_PROCESS_PO_CUST ) works (hit) in ME21N. Pls suggest me for sending sms........ Thanks in advance, Tarun

  • Transfering music from iphone 4 to an iphone 5 help

    I recently upgraded my iphone 4 to an iphone 5. I tried to transfer my music to the new phone from itunes and my music will not transfer. What can i do to fix this issue.

  • Help Tic Tac Toe beginner

    A Tic Tac Toe board is represented as an array of 9 chars. Write a program that will allow two users to play tic tac toe. The player should ask for moves alternately from players X and O. The program is too dumb to check whether anyone has won or los

  • SPEL for Home Page

    Hi, I need to hide notification region on some conditions. Is there any way that I create one new profile and according to profile value I use SPEL to display region or not to display region. How I can use profile values in SPEL. Can some one provide

  • GnuCash 2.6.6 and custom reports

    I've just spent a bit of time trying to figure out why 2.6.5 -> 2.6.6 had caused custom reports to fail. I'm not fluent with Guile or Scheme, and my custom reports are just hacks of files copied from those supplied with the package with help from Gnu