SAP Query - SQVI or SQ01 -- Implementing Group By

Hi,
Please advice on whether we can use GROUP BY and HAVING clauses in SAP Query.
For ex. I need to find all the customers in the system who have been defined for multiple company codes. In ABAP, I could do it using
Select kunnr count(*) from knb1
group by lifnr
having count(*) > 1
Is this possible to do this in SAP query?
Thanks,
Ani

Ani P,
   IN  ABAP Query you can  write this in  under  START-OF-SELECTION  event.
There are 2 options for out put
1. Out in ALV format in System itself
  This can be possible in RECORD PROCESSING.Here you don't have command on "main selection statement ".System will write this.
   If you want to do some validations OR want to delete some records you have write logic for this here. Process will be record by record.
2.Output in Excel format.
   If you want "GROUP BY or Having"  write code in START-OF-SELECTION event.
Extract all the data in one final internal table.
use Function Module WS_EXCEL.
3.Output in file format in application server.
   This is also you can do in START-OF-SELECTION  by using
OPEN DATASETS.
For your requirement better use " START-OF-SELECTION ".
Pls. reward if useful

Similar Messages

  • Require TCode used by user for sap query created through SQ01

    Hi All,
    I have number of SAP Query in production that currently are used by different-2 user & created through SQ01
    My question is how to know the TCode that used by user for SAP Query.
    Thanks In Advance
    Regards
    San

    Charlie
    You did not get the question.
    I knew the TCode of the query which I had created using tcode SQ01. user is using this query to see the report
    Like I created query named 'order_line_details'. This query is basically to see the order & other details. To use this by user one TCode'zncv_ord_item'  has been created.
    So in the system lots of query are available. So i want to know the Tcode for those query that are using by user.
    Thanks in advance
    San

  • Call screen in SAP Query selection screen (SQ01)

    Hi experts , in sq01 selection screen my requirement is: for one field  when the user call F4 the small screen should be appear and when they fill
    those 3 fields I should concatenate them and send it as a single field to query for process , the important thing is those 3 fields should be in '
    one line beside each other , is there a way like call screen or ... in  sq01 for this issue ??
    the screen that should be appear is something like this

    Hi,
    I dont think that ALV double click can be handles via SAP query. One possibility is that you can modify the report program that SAP generates for the query. Change the program to handle the double click evet on the ALV grid and call transaction ME23n using the PO number on the line selected.
    Regards
    Ajith

  • Regarding sap query(SQVI)

    hi champions,
                         i need ur help,i developed a query in HR module using sq02 ,sq03 and sq01.no doubt when i execute the query in sq01 the o/p is coming ,but i want to execute it with the help of tc SQVI ,frnds wat sud i do for this.i dnt have any idea about tc SQVI.plz help me.
    with regards,
    ravi gupta.
    ravi gupta

    Hi ,
    go to se93 .
    create u r tcode with the following properties;
    transaction type : parameter transaction
    Transaction text      Stock by analysis group                    
    Default values for :                                                            
    Transaction        START_REPORT                                                                               
    Obsolete: Use default values for transaction                    
    skip initial screen : check
    Screen             0                                            
    From module pool                                                
    check inherit gui attibutes.
    select the radiobutton professional user transaction under transaction classification tab.
    Transaction code   
    Transaction text    group                                                                               
    Transaction        START_REPORT                                                                               
    Obsolete: Use default values for transaction                    
    Screen             0                                            
    From module pool                                                                               
    Transaction        START_REPORT                                                                               
    Obsolete: Use default values for transaction                    
    Screen             0                                                                               
    parameters:
    d_srepovari-reporttype            AQ                                                                 
    d_srepovari-report                  ZF                                                                
    REGARDS
    Message was edited by:
            shishupalreddy ramreddy

  • SQ01 Sap Query - additional fields doesn't appear

    Hi everybody,
    i've created a SAP Query with transaction SQ01 but one of my additional fields doesn't appear when i execute my Query.
    My query shows the G/L account number and the field status Group (table SKB1)
    I just need to display equally the text field of "field status Group" but it doesn't work.
    When i look at the parameters i can see that it makes the link between the table T004G and SKB1 in order to find the textfield but the field stay blank.
    For information T004g is a Pooled table.
    Is someone could help me?
    Thank you

    Hi,
    First you need to create a structure in Data Dictionary - SE11. This structure will contain all the fields that you want to display in the query output.
    Example - Name the Strucutre as zz_infoset01
    fields of the structure( for your requirement )
    BUKRS
    SAKNR
    FSTAG
    FSTTX
    Go to T-code SQ02
    1) Enter the Infoset name - zinfoset01 press create
    2) Enter a Short Description - G/L Infoset - 01
    3) select radio button - "Data retrieval by program"
                   and in "data structure" enter   zz_infoset01
    4) select "Integrated program" radio button
    5) In the next screen click on the "Data reading program" push button(on the application toolbar)
    6) An Editor will open with the following code
    REPORT  rsaqdvp_template .
      declarations
      (insert your declarations in this section)
    DATA:
      zz_infoset01                          TYPE zz_infoset01                          ,
      it_data TYPE STANDARD TABLE OF zz_infoset01 WITH HEADER LINE.
      selection screen statements
      (define your selection-screen here)
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_HEAD>
      read data into IT_DATA
    (select your data here into internal table IT_DATA)
      output of the data
      (this section can be left unchanged)
    LOOP AT it_data.
      zq01  = it_data.                        .
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_BODY>
    ENDLOOP.     
    7) when you insert your code in the sections it will look like this
    REPORT  rsaqdvp_template .
      declarations
      (insert your declarations in this section)
    Tables:SKB1,
              t004g.          
    DATA:
      zz_infoset01                          TYPE zz_infoset01 ,
      it_data TYPE STANDARD TABLE OF zz_infoset01 WITH HEADER LINE.
      selection screen statements
      (define your selection-screen here)
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_HEAD>
    *These will be the input parameters for the query
    parameters: sp_bukrs like skb1-bukrs,
             sp_saknr like skb1-saknr.     
      read data into IT_DATA
    (select your data here into internal table IT_DATA)
    *get all the G/L for com code and G/L in selection screen
    SELECT bukrs saknr fstag
                INTO TABLE it_data
                FROM skb1
                WHERE bukrs = sp_bukrs
                AND   saknr = sp_saknr.
      output of the data
      (this section can be left unchanged)
    *for every G/L get the status text from t004g for lang 'EN'
    LOOP AT it_data.
    SELECT SINGLE fsttx
                    FROM t004g
                    INTO it_data-fsttx
                    WHERE spras = 'EN' "Language
                    AND   bukrs = it_data-bukrs
                    AND   fstag = it_data-fstag.
      zz_infoset01  = it_data.                        .
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_BODY>
    ENDLOOP.     
    8) Save and generate the Infoset.By clicking on the generate button.
    9) Now assign the Infoset to the query in SQ01 and select the output list fields.
    let me know if you need more info. Also award points if helpful.
    Regards,
    Santosh

  • Transaction code for SAP query reports

    Hi All,
    I am trying to create transaction code for sap query report but couldn't go further.
    1) Created User group in SQ03
    2) Created infoset in SQ03 and assigned that to the user group
    3) Created query in SQ01 using the infoset.
    I executed the report in SQ01 and it is working fine.
    Now I try to create a transaction code in SE93 using the steps mentioned in the following link:
    Assign transaction code to SAP Query (created via SQ01)
    But when try to execute the report using the transaction code, it is giving error message 'User group xxxxxx is not yet created'
    Could any one advice me if I miss something? Or please help me to create this transaction code and transport to production?
    Thanks in advance

    HI,
    based on the thread you've already mentioned:
    In SE93, Create a Paramter Transaction
    -> Transaction = Start_report
    -> In default values, give the below details:
    D_SREPOVARI-REPORTTYPE = AQ
    D_SREPOVARI-EXTDREPORT = Name of the Query
    D_SREPOVARI-REPORT = User Group
    So check if the user group is typed correct in SE93 and check also if the user group exits in the system where you are trying to run the transaction.
    best regards, Christian

  • Translation for SAP Query

    Hi,
    Is it posible to change the texts for coulmn in the report (ALV Grid) created though SAP Query (SQVI)?
    Ex: if the Column has Number -> it should be changed to Nummer. This will be done based on some conditions.
    Thanks,
    Prashanth

    Nummer = German?
    Did you translate the (custom?) data elements and  log in German?

  • SAP Query for Appriasal Report

    Hello Experts,
    Can we use SAP Query (SQ03, SQ02, SQ01) based on Appriasal tables ( HRHAP*) to fetch records similar to tcode phap_search_pa?
    I tried building an infoset making a direct read of table HRHAP and then joining tables like - HRHAP_T, HRHAP_APPEE, HRHAP_APPER, HRHAP_OTHERS and HRHAP_ACT_LOG.
    Finally, created a query based on this infoset, however, it does not retreive any results. Seems, it requires more details as app templates...
    Can anyone give inputs on this?
    Regards,
    Sarvesh Hasija

    Hi Sarvesh
    SAP Query may not work here. Because more than often, the data available in PHAP tables need to be first brought into temporary tables using a match condition and then shown on screen. There are a lot of sub queries required between PHAP and HRPnnnn tables to see some meaningful results. Imagine how many Table joins the End User needs to do.
    SAP Query are ideal if we are pooling data from one or two tables using a match condition. I am not dening that InfoSet is not possible. Getting desired output from such InfoSet will be challenging.
    You mentioned you supplied Doc ID/Number to PHAP_Search_PA, which is incorrect. It is a report which works on Template not Document. I hope you know the difference between Template and Document in PMS/OSA. I cannot stress enough on how much important is PHAP_Search_PA. What this standard report can do, custom designed report will take huge time to get close to it.
    I am sorry, I am also going to recommend Z Reports in case desired output is not possible in PHAP_Search_PA. In one of my recent assignments we had "Trainer's Feedback Report for any training programme/programmes between any two dates" requirement, and we opted for a Z Report.
    Regards
    Yash

  • SAP Query (SQ01) - create and save queryies

    Hi Expert;
    We wanted to implement SAP query reporting (SQ01) tool, and already developed custom HR infoset and user groups and transported to QAS.  We experienced the problem that we can not directly "save" any queries in SQ01. We pretty much have the client opened up and set at "Changes without automatic recording".  But keep getting a "transport object create" dialog upon "save" query.  But in Adhoc (PQAH), we don't encounter same problem.    We wanted our users be able to create and save any queries directly without creating any local objects. Is there another setting that needs to be set? 
    Thanks for any information that you can provide.  Points will be awarded.
    Helen

    Hello Helen,
    in SQ01 you can save queries like in HR Ad Hoc Query (or Infoset query as it is called outside HR).
    However this is only possible in the "Standard Area" not in the "Global Area". However as Ad Hoc Query is based on the SQ0x basics it only hides this effect.
    If you are doing HR specifics you should consider the documetnation on the special HR switches:
    http://service.sap.com/~form/sapnet?_SHORTKEY=01200252310000076208&
    In general if you are new to the topic you should consider the courses BC407 for Query Basics and HR580 for reporting in HR.
    Also to get a feeling for the different types of reporting with the InfoSet Query you can look at the following documentation:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/a8/2e7237a323427ee10000009b38f8cf/frameset.htm
    HR Reporting Tools -> Sap Query -> InfoSet Query -> Calling InfoSet Query.
    Or you can book a special training if you need a contact let me know your email adress
    Best regards,
    Michael

  • SAP Query in SQVI transaction

    Hi All,
    I have created a Query in SQVI transaction, How to assign a transaction code for it.
    Thanks in advance
    Raju

    hi,
    follow the link:
    http://help.sap.com/saphelp_erp2005/helpdata/en/b7/26ddebb1f311d295f40000e82de14a/frameset.htm
    you will get full information about SAP Query.
    There is no SQV1 transaction.
    SQ01 --> maintain query
    SQ02 --> maintain info set
    SQ03 --> maintain user groups
    he SAP Query application is used to create reports not already contained in the default. 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 reports and create different types of reports such as basic lists, statistics, and ranked lists.
    Features
    The SAP Query comprises five components: Queries, InfoSet Query, InfoSets, User Groups and Translation/Query.
    hope this may help you,
    regards,
    srinivas

  • SAP query in Grand Totalling in SQ01 wrongly calculation

    Dear All,
    I have created a  SAP query for getting few ledger accounts data in the clients specified format.
    But I am having a problem, that debit and credit amounts are getting added in the 'Total' field.
    The credit amounts are not getting substracted from the debit amount.
    For eg :
    CoCd     G/L          Year     DocumentNo      Amount in LC     Crcy     D/C
    1000     4071101020          2007     9600000002     3,300.00          H
    1000     4071101021          2007     9600001413     40,000.00          S
    1000     4071101022          2007     8000000000     2,020,012.80     H     
    Grand Total                                                                2,063,312.80     
    Where as total should be -1,983,312.80, where 'H' is credit and 'S' is debit.
    rgds

    Hiya,
    You may need to:
    1. Either group by the Debit/Credit Indicator (SHKZG), create two subtotals for each and then subtract one from the other, or,
    2. Multiply the Credits by -1 (again use the Debit / Credit Indicator to sort this for you) and then get a total field.
    This is an inbuilt problem with queries (SQ01, SQVI, etc.).
    Cheers.

  • SAP Query, user groups, revoking 'change' rights

    Hi,
    I have a problem regarding SAP Queries and revoking the change rights. This is what I have done:
    1. Created the new user group in SQ03
    2. Created the new InfoSet (SQ02), assigned it to the above UG (SQ03)
    3. Created the new user, assigned it to the UG in SQ03 and removed the Change checkbox (revoke change rights)
    4. Logged on as the new user
    5. Started SQ01, switched user group to the new one
    6. Created the new SAP query based on the new InfoSet, run the query
    As I understand the principles of user groups and queries, I wasn't supposed to be allowed to do the step 6 as the new user, as it was revoked the change rights. Why wasn't I stopped?
    I searched for reply in previous posts - everybody agrees on principles, but I didn't find explanation on why it doesn't work.
    Thanks in advance!
    KR,
    Igor

    The table AQGDBBN seems to display a mapping of User Group with use rindeed but the results are less than the actual assignment. And the mapping does not have the Z query usergroups that have users assigned in SQ03.
    Anything that I may be missing?
    Thanks,
    Kashif

  • Sap Query custom field assigned to wrong field group (in extract)

    Hello,
    I want to add an extra field to InfoSet /SAPQUERY/MEBANF at EBAN level. I added a field in a normal way:
    I fill it with a constant value. I adapted Sap Query:
    In result, I got the value in new column but only for certain rows:
    The value is there only for EBAN rows which have EBKN entries related.
    I checked the program, and my new field is added to field group %fg07 with some other fields from table EBKN (not EBAN):
    Fields from field group %fg07 are inserted to extract only in event get EBKN, so if there is no entries in EBKN, my field will not be inserted into extract:
    I tried a lot of things (assigning my field to new field group in InfoSource, adding a field on EBKN level). I can say that every extra field created by me was assigned to field group &fg07.
    Am I doing something wrong?
    The target is to add new field in the document overview panel in ME2xN transaction. I know that there is user-exit EXIT_SAPLMEQUERY_002 where I can specify a Z* query. But this solution requires a copy of InfoSet and query to Z*. Adding a new field to standard Sap query is the fastest way.
    Message was edited by: Rafal Matuszewski
    Now I tried to append EBAN table with my Z* field. I regenerated InfoSet and query but the result is still wrong:
    insert EBAN-GSFRG into %fg06.
    insert EBAN-ZUGBA into %fg06.
    insert EBKN-VBELN into %fg07.
    insert EBKN-AUFNR into %fg07.
    insert EBKN-KOSTL into %fg07.
    insert EBAN-ZZDELIV_DATE_MRP into %fg07.   <-- here again the Z* field is assigned to field group related to EBKN table

    Thanks Sandra

  • How to Hide Empty Column In SAP Query (SQ01)

    I was crated a report in sq01 based on business requirements , but there are some fields without any content , in sq01 if you select one of output fields in the right side of the screen in the left side you can see  "List Fields" T in the list fields there is a check box , the name is "Only display field if <> 0 " , but when i check it, it doesn't work  , guys is there any one to help me to eliminate column without content , in the result of sap query (sq01) ??

    Please give reference (or hyperlink) to 10 Useful Tips on Infoset Queries (original document)
    Regards,
    Raymond

  • Sap query report sq01

    Hello all
    I want to create new sap query in sq01 , the requirement is like this eg:- customer a/b/c , I want to generate the  list of last created sales order for the customers a/b/c here I have given 3 customers but I have to execute for 1500 customers
    If customer A creates 3 sales order in that 3 sales orders I want to pick last sales order on 12.09.2010 / 15.09.2010 /17.09.2010 in that I wnat to pick the last sales order 17.09.2010
    So in query report sq01 how to create, plz provide step by step procedure with this logic
    With regards
    Rahul
    Moderator Message: Search.
    Edited by: kishan P on Sep 17, 2010 4:47 PM

    Hi,
      better search in Google with the keyword 'SAP query tutorials',
    you will get lots of tutorials in the net with step by step approach.

Maybe you are looking for

  • Reading a large file?  I created an Applescript to read an XML document...

    I created an Applescript to read an XML document that had been exported from Final Cut Pro but it has trouble reading anything larger than a 1mb. Even 500kb takes a long time. My code is most likely very ineffecient, but I have little experience with

  • Upgrade Siebel Analytics 7.8.5 AN6927 (Build 6927) to OBIEE 11g

    Hi, Currently m running Siebel Analytics 7.8.5 on siebel crm.I want to upgrade to OBIEE11g with OBIA 7.6. Is direct upgrade to OBIEE 11g available? Can anyone guide on upgradation process? Is is better to upgrade directly to OBIEE 11g or redevelop al

  • Issue with "at sign" - @

    I have tried to create a databaselink to a SQL SERVER but I'm facing issues with the username. When I use the following command the dblink is created but I am unable to connect to the dblink: CREATE DATABASE LINK mydblink CONNECT TO *"[email protecte

  • Help with close buttons

    I have been reading the forums and scouring the internet to find a way to either write a button in flash or creating one in captivate 3 using the on click execute javascript function javascript:self.close() and I have tried the actionscript on (relea

  • Converting modbus data from two registers into float

    I am reading modbus data from a DUT from two holding registers- 40609 and 40610. The register content I get is an array of two elements (12458, 14019). I want to convert these numbers into a floating point value. Does modbus library has a VI that doe