Creation of ABAP query

Dear All,
This may be a technical question.  I am trying to create the ABAP query by using 2 tables.  Went to SQ02, entered the  description of Infoset and given the first table name in the "Table join in the basis table" row.  When i entered to type the second table name, the program is getting terminated. (If I want to create a query by using one table, then the system accepts)
If possible, can anybody explain me what could be the proble,?
Regards
Manivannan R

You can post u r req in Expert Forums  » Application Server  » SAP GUI forum
7.10 is now released, you can get it at
ftp://ftp.sap.com/pub/sapgui/win/710/compilation1/
and on
ftp://ftp.sap.com/pub/sapgui/win/710/patches
there are the newest patches available.
http://iris.tennessee.edu/sapgui_vista.htm
Message was edited by:
        SHESAGIRI.G

Similar Messages

  • Creation of ABAP Query- with SQ01.

    Dear Friends,
    Please provide the full notes to create ABAP Queries with the T.code SQ01.
    Thanks & Regards
    Sreehari.

    Dear Frind,
    My Mail ID - [email protected]
    Thanks & Regards,
    Sreehari

  • Regarding ABAP Query authorization group

    Hi Team,
    This is regarding ABAP Query!
    I have created one authorization group, for testing i have assigned my id in authorization group.
    After creation of ABAP query,standard program got generated. Now i have created one transaction code at the last for the ABAP Query.
    Now the isse is even though i have deleted my id from the authorization group. I am able to execute the query from SQ01 and with the Transaction code .
    It should not happen...i want who soever id is mapped to the transaction code ...that member should only be able to run that query, otherwise there is no use of authorization group.
    Please help me out in this case.
    Thanks & Regards,
    Anil Kumar Sahni

    Are you sure that you don't have access to that authorisation group? Execute report RSUSR002. In the 'Authorization Object 1' block inform  S_TABU_DIS in 'Auth.Object' and accept. Then inform Activity=03 and Auth.Gruop= your group.
    You will get a list of all the users which, theoretically, will be able to execute the query. If you press 'Roles' or 'Profiles' in the toolbar of the listing you will get to know why you have authorisation. May be you have the SAP_ALL profile.
    Also, one more thing to take into account: how have you created your transaction? Is it referring directly to the generated report? Then it is an error, you should execute program SAP_QUERY_CALL. Read this post: [Relate transaction to query;

  • ABAP QUERY STEPS

    Hi Friends,
    can i send me Creation of ABAP QUERY...
    REGARDS,

    What Is SAP Queries
    Many times a need arises for SAP Users and Functional Consultants to generate quick reports without getting any ABAP coding done – time taken to complete the coding in development, transport and test it in QA system and then transport to production – is sometimes too long. In such cases, ABAP/4 query is a tool provided by SAP for generating these kind of reports.
    Type of Report Desired:
    Before starting to write an ABAP query, its advisable to decide the type of report that the user wants. ABAP query provides the following type of reports:
    Basic List Simple report
    Statistics Report containing statistical functions like Average &Percentage
    Ranked List Report written for analytical purpose
    The output is always seen in the order of Basic List, then Statistics and then Ranked List if any. One ABAP query can have one basic list, maximum of 9 statistics and maximum of 9 ranked lists.
    In a nutshell, an ABAP/4 query can be designed in four steps
    - Creation of a user group
    - Creation of functional area
    - Assignment of user group to functional area
    - Creation of the query based on functional area
    The various objects that form an ABAP query can be created in the following 2 ways:
    - Tools => ABAP/4 Workbench => Utilities => ABAP/4 Query
    OR
    - By executing the transaction codes mentioned below:
    SQ01 ABAP/4 Query
    SQ02 Functional Area
    SQ03 User group
    Step I - Create Functional Area
    In the functional area section, the user indicates from which part of the SAP database the data is going to be retrieved and how the data is to be retrieved by the query. One functional area can be assigned to many user groups. A functional area can be created with or without a logical database. To create a functional area with a logical database, one has to mention the name of the database and then select the fields from the tables that form the logical database.
    ABAP Query Authorizations: To use an ABAP query, the user must have appropriate authorizations. Two ways of providing authorizations to the users are as follows:
    - User groups
    The user should be a part of at least one user group to run the corresponding ABAP query. This automatically restricts the access of the user to specific functional areas, and thus the corresponding underlying logical databases.
    - Authorizations
    The authorization object S_QUERY should be used to give proper authorizations to the user for a query. This authorization object has a field named ACTVT which can take values 02 for Change, 23 for Maintain and 67 for Translate.
    This value determines whether the user can create and modify the query. The possible authorizations in the object are as follows:
    S_QUERY_ALL Change, maintain and translate query
    S_QUERY_UPD Change and Translate
    Though the general concept of an ABAP query is moderately difficult, the results and the long term use of the ABAP query is worth the effort.
    Creating the ABAP Query
    To create the query use the menu path Environment => Queries
    · Give a name to the query and click on the Create button
    · Give the description of the query in the next screen. Specify the output length and select the processing option from the Further Processing Options box. The data can be displayed in various formats such as table, download to a file, and display in Word etc.
    · Click on the Next screen icon. Select the functional group screen. All the functional groups created in the functional area are displayed. Select the groups that you desire – fields from only these groups will be displayed in the output. Click on the respective check boxes and click on the Next Screen icon.
    · The Select Field screen gets displayed. Select all the fields from the user group that you need to display on the output of the query. If required, specify the short names for the fields using the menu path Edit => Short Names => Switch On/Off or you can also change the selection text contains in the order you want to appear on the selection screen. You can also maintain column headers for the fields by using the menu path Edit => Column Header => Maintain. 
    ·         Click on the Next Screen icon to get the Selections Screen. Here you can check against the fields that you require to be shown on the selection screen.
    ·         Now we need to specify the output type for the query as Basic List, Statistics or Ranked List. Choose the option Basic List.
    ·         On the Basic List line structure screen the following things can be done
    o        Specify the report layout in detail – lines on which the fields will appear.
    o        Order in which the fields will appear in the output
    o        Sort order for the fields – this is optional.
    o        For the numeric fields you can check against the fields for which you require totals in the output.
    o        Beautify the output according to the options provided.
    ·         Click on the next screen icon, to specify the control levels as mentioned below
    o        Specify the sort order. The default sort order is ascending and can be changed to descending if required.
    o        Totals for each field selected for sorting can be displayed
    o        To display the output of a field in a box click on the check box against box. To display a line after the output of a field, click on the check box against BlnkLn
    o        To display the output of a field on a new page click on the check box against New Page
    ·         Click on the next screen icon to get the List Line options Screen. Here you can specify the background color for displaying the output.
    ·         Click on the next screen icon to get the Field Output Option screen. In this you can specify the following:
    o        Change the output length or the display positions of the fields
    o        Specify the display position of the unit for quantity or currency fields. Click left radio button to display it before the figure, middle radio button to display it after the figure while last radio button to hide the unit altogether.
    o        Specify color for the column of every field under the Format option.
    o        Specify the label against the output of sort fields.
    ·         Click on the Next screen option to go to the Basic List Header screen. Here you can specify
    o        Give page header and page footer for the output
    o        Include user name and date by specifying &N and &D respectively.
    After providing all the above options you can save the query and execute it by clicking the Execute button twice
    Regards,
    Maha

  • ABAP Query: creation of local field (Subtraction between 2 dates)

    Hi,
    I want to create a local field which will calculate the number of days between 2 dates (for example, document date - posting date).
    What I did:
    1) Created the user group in SQ03
    2) Created the infoset in SQ02
    3) I'm stucked at the creation of the Query in SQ01. I'm at the «Create Query: Select field screen». I clicked on Edit --> Local Field --> Create. I selected the «calculation field» attribute. I clicked on the «Complex calculation button», but I don't know how to write my formulate DOCUMENT DATE - POSTING DATE.
    Thanks a lot for your help.
    Julien

    Try these FM's to calculate difference between two dates..
    DAYS_BETWEEN_TWO_DATES
    LEAP_DAYS_BETWEEN_TWO_DATES
    HR_SEN_CALE_DAYS_DATE
    ISB_DAYS_BETWEEN_TWO_DATES
    FIMA_DAYS_BETWEEN_TWO_DATES
    FIMA_DAYS_BETWEEN_TWO_DATES_2
    FIMA_LEAP_DAYS_BETWEEN_2_DATES
    SD_DATETIME_DIFFERENCE

  • Abap Query - Creation of Report

    Hi guys,
    I do have a question to ABAP Query:
    I want to create a report that shows me all current active employees and all of their corresponding positions from Infotype 1.
    I have got it to the part where the report gives me all employees (active and withdrawn).
    The question is:
    How can I show only active employees as of todays date?
    Thanks,
    Sascha

    Thanks for your reply,
    but if I enter date 31.12.9999 and status of active. it gives me for some the latest record and for some two - though I could not find out why?!
    I should say, I am using logical database PNP for this query
    null

  • Creation of local field in ABAP Query

    Hi
    Please let me know how to create a local field in ABAP query. I am finding the option inactive in SQ01.
    Regards
    Priyadarshini

    hi priya,
         *__Adding u201CLocal Fieldu201D (user defined field) in SAP Query_ :
    There is also facility to add the user defined fields in SAP query output. Also we can provide calculation formula for calculating values for this user defined field.
    Calculation formula consists of standard fields from standard SAP tables. So the values fetched for particular standard SAP fields from standard SAP tables get calculated as per the calculation formula defined for the user defined field and displays the value accordingly.
    To do this first go to change mode for Query which automatically takes you to screen shown below and click on icon   , as below :
    Then further screen will appears. So select the Field group and again click on the same icon button   .
    Then switch on the Short names for the fields and give the short names to fields which we need to use in Calculation formula.
    Give the short names and then created u201CLocal Fieldu201D, as shown in below screen shot. Also Short names are given to fields, which can be used further for calculation.
    Defining Local Field u201CREM_QTYu201D along with its field type and Calculation formula.
      In this case we have 
      defined field type for new  
      field as similar to
      ORD_QTY and
      Calculation formula is  
      defined.
    Also its possible to have Conditional logic for Local field by putting Condition in u201CConditionu201D line.
    Now activate this newly added Local field for coming it in output screen. To do the same again go to u201CBasic Listu201D and activate the Local Field as shown below :
    i think this will help u
    regards,
    sindhu.

  • Pnp- logical db in abap query

    hi.
    i need to create an ABAP/sap query. when i created the InfoSet i used logical db-pnp.
    if i want to get only the employees which entered my organization during the last month where should i add the ABAP code,  under which section => extras -> code. i have there several options - data, initialization, at selection-screen output etc, what to choose??????????
    thanks,
    Ami

    Hi
    Welcome to SDN forum
    query has got some limitatins compared to Reports which we write using SE38
    these queries are user specific and client specific and can't be transportable and you can't write your own code as you wish like reports
    see the doc
    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
    Regards
    Anji

  • How to make output of ABAp query interactive(drill down)..?

    Hi All,
    I have developed one ABAP query which shows the output in which there is a coloumm 'order number'.
    I want to make this coloumn interactive ,that means after double clicking on any row of this colomn ,it should go to transaction KO02.
    Where do i have to write the code  in ABAP query ?
    I am very new to ABAP query..this is the first query i have deloped till now.
    points will be rewarded.
    Thnks in advance.
    Regards,
    Sanjay.

    <b>The below sample code is one such example of Drill down reporting...
    Make the necessary modifications, change the statement CALL TRANSACTION to whatever you want to CALL. Proceed further.</b>
    *"Table declarations...................................................
    TABLES:
      EKKO,                                " Purchasing Document Header
      CDHDR,                               " Change document header
      SSCRFIELDS.                          " Fields on selection screens
    *"Selection screen elements............................................
    SELECT-OPTIONS:
      S_EBELN FOR EKKO-EBELN,              " Purchasing Document Number
      S_LIFNR FOR EKKO-LIFNR,              " Vendor's account number
      S_EKGRP FOR EKKO-EKGRP,              " Purchasing group
      S_BEDAT FOR EKKO-BEDAT,              " Purchasing Document Date
      S_UDATE FOR CDHDR-UDATE.             " Creation date of the change
                                           " document
    *" Data declarations...................................................
    Field String to hold Purchase Document Number                       *
    DATA:
      BEGIN OF FS_EBELN,
        EBELN(90) TYPE C,                  " Purchase Document Number
        ERNAM     TYPE EKKO-ERNAM,         " Name of Person who Created
                                           " the Object
        LIFNR     TYPE EKKO-LIFNR,         " Vendor's account number
        EKGRP     TYPE EKKO-EKGRP,         " Purchasing group
        BEDAT     TYPE EKKO-BEDAT,         " Purchasing Document Date
      END OF FS_EBELN,
    Field String to hold Purchase Document Header                       *
      BEGIN OF FS_EKKO,
        EBELN TYPE EKKO-EBELN,             " Purchasing Document Number
        ERNAM TYPE EKKO-ERNAM,             " Name of Person who Created the
                                           " Object
        LIFNR TYPE EKKO-LIFNR,             " Vendor's account number
        EKGRP TYPE EKKO-EKGRP,             " Purchasing group
        BEDAT TYPE EKKO-BEDAT,             " Purchasing Document Date
      END OF FS_EKKO,
    Field String to hold Account Number and name of the Vendor          *
      BEGIN OF FS_LFA1,
        LIFNR TYPE LFA1-LIFNR,             " Account Number of Vendor
        NAME1 TYPE LFA1-NAME1,             " Name1
      END OF FS_LFA1,
    Field String to hold Change date and the name of the user           *
      BEGIN OF FS_CDHDR,
        OBJECTCLAS TYPE CDHDR-OBJECTCLAS,  " Object Class
        OBJECTID   TYPE CDHDR-OBJECTID,    " Object value
        CHANGENR   TYPE CDHDR-CHANGENR,    " Document change number
        USERNAME   TYPE CDHDR-USERNAME,    " User name
        UDATE      TYPE CDHDR-UDATE,       " Creation date of the change
                                           " document
      END OF FS_CDHDR,
    Field String to hold Change document items                          *
      BEGIN OF FS_CDPOS,
        OBJECTCLAS   TYPE CDPOS-OBJECTCLAS," Object class
        OBJECTID(10) TYPE C,               " Object Value
        CHANGENR     TYPE CDPOS-CHANGENR,  " Document change number
        TABNAME      TYPE CDPOS-TABNAME,   " Table Name
        FNAME        TYPE CDPOS-FNAME,     " Field Name
        VALUE_NEW    TYPE CDPOS-VALUE_NEW, " New contents of changed field
        VALUE_OLD    TYPE CDPOS-VALUE_OLD, " Old contents of changed field
      END OF FS_CDPOS,
    Field String to hold Date Element Name                              *
      BEGIN OF FS_DATAELE,
        TABNAME   TYPE DD03L-TABNAME,      " Table Name
        FIELDNAME TYPE DD03L-FIELDNAME,    " Field Name
        ROLLNAME  TYPE DD03L-ROLLNAME,     " Data element (semantic domain)
      END OF FS_DATAELE,
    Field String to hold Short Text of the Date Element                 *
      BEGIN OF FS_TEXT,
        ROLLNAME TYPE DD04T-ROLLNAME,      " Data element (semantic domain)
        DDTEXT   TYPE DD04T-DDTEXT,        " Short Text Describing R/3
                                           " Repository Objects
      END OF FS_TEXT,
    Field String to hold data to be displayed on the ALV grid           *
      BEGIN OF FS_OUTTAB,
        EBELN      TYPE EKKO-EBELN,        " Purchasing Document Number
        ERNAM      TYPE EKKO-ERNAM,        " Name of Person who Created the
                                           " Object
        LIFNR      TYPE EKKO-LIFNR,        " Vendor's account number
        EKGRP      TYPE EKKO-EKGRP,        " Purchasing group
        BEDAT      TYPE EKKO-BEDAT,        " Purchasing Document Date
        WERKS      TYPE LFA1-WERKS,        " Plant
        NAME1      TYPE LFA1-NAME1,        " Name1
        USERNAME   TYPE CDHDR-USERNAME,    " User name
        UDATE      TYPE CDHDR-UDATE,       " Creation date of the change
                                           " document
        DDTEXT     TYPE DD04T-DDTEXT,      " Short Text Describing R/3
                                           " Repository Objects
        VALUE_NEW  TYPE CDPOS-VALUE_NEW,   " New contents of changed field
        VALUE_OLD  TYPE CDPOS-VALUE_OLD,   " Old contents of changed field
      END OF FS_OUTTAB,
    Internal table to hold Purchase Document Number                     *
      T_EBELN LIKE STANDARD TABLE
                OF FS_EBELN,
    Internal table to hold Purchase Document Header                     *
    T_EKKO LIKE STANDARD TABLE
              OF FS_EKKO,
    Temp Internal table to hold Purchase Document Header                *
    T_EKKO_TEMP LIKE STANDARD TABLE
                   OF FS_EKKO,
    Internal table to hold Account number and Name of the Vendor        *
      T_LFA1 LIKE STANDARD TABLE
               OF FS_LFA1,
    Internal Table to hold Change date and the name of the user         *
      T_CDHDR LIKE STANDARD TABLE
                OF FS_CDHDR,
    Internal Table to hold Change document items                        *
      T_CDPOS LIKE STANDARD TABLE
                OF FS_CDPOS,
    Temp. Internal Table to hold Change document items                  *
      T_CDPOS_TEMP LIKE STANDARD TABLE
                     OF FS_CDPOS,
    Internal Table to hold Data Element Name                            *
      T_DATAELE LIKE STANDARD TABLE
                  OF FS_DATAELE,
    Temp. Internal Table to hold Data Element Name                      *
      T_DATAELE_TEMP LIKE STANDARD TABLE
                       OF FS_DATAELE,
    Internal Table to hold Short Text of the Date Element               *
      T_TEXT LIKE STANDARD TABLE
               OF FS_TEXT,
    Internal Table to hold data to be displayed on the ALV grid         *
      T_OUTTAB LIKE STANDARD TABLE
                 OF FS_OUTTAB.
                   C L A S S   D E F I N I T I O N                      *
      CLASS LCL_EVENT_HANDLER  DEFINITION DEFERRED.
    *" Data declarations...................................................
    Work variables                                                      *
      DATA:
        W_EBELN       TYPE EKKO-EBELN,     " Purchasing Document Number
        W_LIFNR       TYPE EKKO-LIFNR,     " Vendor's account number
        W_EKGRP       TYPE EKKO-EKGRP,     " Purchasing group
        W_VALUE       TYPE EKKO-EBELN,     " Reflected Value
        W_SPACE       VALUE ' ',           " Space
        W_FLAG        TYPE I,              " Flag Variable
        W_VARIANT     TYPE DISVARIANT,     " Variant
    *--- ALV Grid
        W_GRID        TYPE REF TO CL_GUI_ALV_GRID,
    *--- Event Handler
        W_EVENT_CLICK TYPE REF TO LCL_EVENT_HANDLER,
    *--- Field catalog table
        T_FIELDCAT    TYPE LVC_T_FCAT.
                          AT SELECTION-SCREEN EVENT                     *
    AT SELECTION-SCREEN ON S_EBELN.
    Subroutine to validate Purchase Document Number.
      PERFORM VALIDATE_PD_NUM.
    AT SELECTION-SCREEN ON S_LIFNR.
    Subroutine to validate Vendor Number.
      PERFORM VALIDATE_VEN_NUM.
    AT SELECTION-SCREEN ON S_EKGRP.
    Subroutine to validate Purchase Group.
      PERFORM VALIDATE_PUR_GRP.
                          START-OF-SELECTION EVENT                      *
    START-OF-SELECTION.
    Subroutine to select all Purchase orders.
      PERFORM SELECT_PO.
      CHECK W_FLAG EQ 0.
    Subroutine to select Object values.
        PERFORM SELECT_OBJ_ID.
      CHECK W_FLAG EQ 0.
    Subroutine to select Changed values.
        PERFORM SELECT_CHANGED_VALUE.
      CHECK W_FLAG EQ 0.
    Subroutine to Select Purchase Orders.
        PERFORM SELECT_PUR_DOC.
    Subroutine to select Vendor Details.
        PERFORM SELECT_VENDOR.
    Subroutine to select Text for the Changed values.
        PERFORM DESCRIPTION.
                          END-OF-SELECTION EVENT                        *
    END-OF-SELECTION.
      IF NOT T_EKKO IS INITIAL.
    Subroutine to populate the Output Table.
        PERFORM FILL_OUTTAB.
    Subroutine to build Field Catalog.
        PERFORM PREPARE_FIELD_CATALOG CHANGING T_FIELDCAT.
        CALL SCREEN 100.
      ENDIF.                               " IF NOT T_EKKO...
    CLASS LCL_EVENT_HANDLER DEFINITION
    Defining Class which handles events
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
            HANDLE_HOTSPOT_CLICK
                 FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                           IMPORTING E_ROW_ID E_COLUMN_ID.
    ENDCLASS.                              " LCL_EVENT_HANDLER DEFINITION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION
    Implementing the Class which can handle events
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION .
    *---Handle Double Click
      METHOD HANDLE_HOTSPOT_CLICK .
    Subroutine to get the HotSpot Cell information.
        PERFORM GET_CELL_INFO.
        SET PARAMETER ID 'BES' FIELD W_VALUE.
        CALL TRANSACTION 'ME23N'.
      ENDMETHOD.                           " HANDLE_HOTSPOT_CLICK
    ENDCLASS.                              " LCL_EVENT_HANDLER
    *&      Module  STATUS_0100  OUTPUT
          PBO Event
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'OOPS'.
      SET TITLEBAR 'TIT'.
    Subroutine to fill the Variant Structure
      PERFORM FILL_VARIANT.
      IF W_GRID IS INITIAL.
        CREATE OBJECT W_GRID
          EXPORTING
       I_SHELLSTYLE      = 0
       I_LIFETIME        =
            I_PARENT       = CL_GUI_CONTAINER=>SCREEN0
       I_APPL_EVENTS     =
       I_PARENTDBG       =
       I_APPLOGPARENT    =
       I_GRAPHICSPARENT  =
       I_NAME            =
       I_FCAT_COMPLETE   = SPACE
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4
            OTHERS            = 5.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.                             " IF SY-SUBRC <> 0
        CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
           I_BUFFER_ACTIVE               =
           I_BYPASSING_BUFFER            =
           I_CONSISTENCY_CHECK           =
           I_STRUCTURE_NAME              =
            IS_VARIANT                    = W_VARIANT
            I_SAVE                        = 'A'
           I_DEFAULT                     = 'X'
           IS_LAYOUT                     =
           IS_PRINT                      =
           IT_SPECIAL_GROUPS             =
           IT_TOOLBAR_EXCLUDING          =
           IT_HYPERLINK                  =
           IT_ALV_GRAPHICS               =
           IT_EXCEPT_QINFO               =
           IR_SALV_ADAPTER               =
          CHANGING
            IT_OUTTAB                     = T_OUTTAB
            IT_FIELDCATALOG               = T_FIELDCAT
           IT_SORT                       =
           IT_FILTER                     =
          EXCEPTIONS
            INVALID_PARAMETER_COMBINATION = 1
            PROGRAM_ERROR                 = 2
            TOO_MANY_LINES                = 3
            OTHERS                        = 4
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.                             " IF SY-SUBRC <> 0.
      ENDIF.                               " IF W_GRID IS INITIAL
      CREATE OBJECT W_EVENT_CLICK.
      SET HANDLER W_EVENT_CLICK->HANDLE_HOTSPOT_CLICK FOR W_GRID.
    ENDMODULE.                             " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          PAI Event
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                             " USER_COMMAND_0100  INPUT
    *&      Form  PREPARE_FIELD_CATALOG
          Subroutine to build the Field catalog
          <--P_T_FIELDCAT  Field Catalog Table
    FORM PREPARE_FIELD_CATALOG  CHANGING PT_FIELDCAT TYPE LVC_T_FCAT .
      DATA LS_FCAT TYPE LVC_S_FCAT.
    Purchasing group...
      LS_FCAT-FIELDNAME = 'EKGRP'.
      LS_FCAT-REF_TABLE = 'EKKO'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '10'.
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    Purchasing Document Number...
      LS_FCAT-FIELDNAME = 'EBELN'.
      LS_FCAT-REF_TABLE = 'EKKO' .
      LS_FCAT-EMPHASIZE = 'C411'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '10'.
      LS_FCAT-HOTSPOT   = 'X'.
      APPEND LS_FCAT TO PT_FIELDCAT .
      CLEAR LS_FCAT .
    Name of Person who Created the Object...
      LS_FCAT-FIELDNAME = 'ERNAM'.
      LS_FCAT-REF_TABLE = 'EKKO'.
      LS_FCAT-OUTPUTLEN = '15' .
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    Purchasing Document Date...
      LS_FCAT-FIELDNAME = 'BEDAT'.
      LS_FCAT-REF_TABLE = 'EKKO'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '10'.
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    Vendor's account number...
      LS_FCAT-FIELDNAME = 'LIFNR'.
      LS_FCAT-REF_TABLE = 'EKKO'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '10'.
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    Account Number of Vendor or Creditor...
      LS_FCAT-FIELDNAME = 'NAME1'.
      LS_FCAT-REF_TABLE = 'LFA1'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '10'.
      LS_FCAT-COLTEXT   = 'Vendor Name'(001).
      LS_FCAT-SELTEXT   = 'Vendor Name'(001).
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    Creation date of the change document...
      LS_FCAT-FIELDNAME = 'UDATE'.
      LS_FCAT-REF_TABLE = 'CDHDR'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '10'.
      LS_FCAT-COLTEXT   = 'Change Date'(002).
      LS_FCAT-SELTEXT   = 'Change Date'(002).
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    User name of the person responsible in change document...
      LS_FCAT-FIELDNAME = 'USERNAME'.
      LS_FCAT-REF_TABLE = 'CDHDR'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '10'.
      LS_FCAT-COLTEXT   = 'Modified by'(003).
      LS_FCAT-SELTEXT   = 'Modified by'(003).
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    Short Text Describing R/3 Repository Objects...
      LS_FCAT-FIELDNAME = 'DDTEXT'.
      LS_FCAT-REF_TABLE = 'DD04T'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '15'.
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    Old contents of changed field...
      LS_FCAT-FIELDNAME = 'VALUE_OLD'.
      LS_FCAT-REF_TABLE = 'CDPOS'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '12'.
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    New contents of changed field...
      LS_FCAT-FIELDNAME = 'VALUE_NEW'.
      LS_FCAT-REF_TABLE = 'CDPOS'.
      LS_FCAT-INTTYPE   = 'C'.
      LS_FCAT-OUTPUTLEN = '12'.
      APPEND LS_FCAT TO PT_FIELDCAT.
      CLEAR LS_FCAT.
    ENDFORM.                               " PREPARE_FIELD_CATALOG
    *& Form  SELECT_PO
    Subroutine to select all the Purchase Orders
    There are no interface parameters to be passed to this subroutine.
    FORM SELECT_PO .
       SELECT EBELN                        " Purchasing Document Number
              ERNAM                        " Name of Person who Created
                                           " the Object
              LIFNR                        " Vendor's account number
              EKGRP                        " Purchasing group
              BEDAT                        " Purchasing Document Date
         FROM EKKO
      PACKAGE SIZE 10000
    APPENDING TABLE T_EBELN
        WHERE EBELN IN S_EBELN
          AND BEDAT IN S_BEDAT.
       ENDSELECT.
    IF SY-SUBRC NE 0.
       W_FLAG = 1.
       MESSAGE S401(M8).
    ENDIF.                                " IF SY-SUBRC NE 0
    ENDFORM.                               " SELECT_PO
    *&  Form  SELECT_OBJ_ID
      Subroutine to select Object ID
      There are no interface parameters to be passed to this subroutine.
    FORM SELECT_OBJ_ID .
    IF NOT T_EBELN IS INITIAL.
        SELECT OBJECTCLAS                  " Object Class
               OBJECTID                    " Object value
               CHANGENR                    " Document change number
               USERNAME                    " User name
               UDATE                       " Creation date
          FROM CDHDR
          INTO TABLE T_CDHDR
       FOR ALL ENTRIES IN T_EBELN
         WHERE OBJECTID EQ T_EBELN-EBELN
           AND UDATE IN S_UDATE
           AND TCODE IN ('ME21N','ME22N','ME23N').
       ENDSELECT.
       IF SY-SUBRC NE 0.
         W_FLAG = 1.
         MESSAGE S833(M8) WITH 'Header Not Found'(031).
       ENDIF.                              " IF SY-SUBRC NE 0.
    ENDIF.                                " IF NOT T_EBELN IS INITIAL
    ENDFORM.                               " SELECT_OBJ_ID
    *&  Form  SELECT_CHANGED_VALUE
      Subroutine to select Changed Values
      There are no interface parameters to be passed to this subroutine.
    FORM SELECT_CHANGED_VALUE .
    IF NOT T_CDHDR IS INITIAL.
        SELECT OBJECTCLAS                  " Object class
               OBJECTID                    " Object value
               CHANGENR                    " Document change number
               TABNAME                     " Table Name
               FNAME                       " Field Name
               VALUE_NEW                   " New contents of changed field
               VALUE_OLD                   " Old contents of changed field
          FROM CDPOS
       PACKAGE SIZE 10000
    APPENDING TABLE T_CDPOS
       FOR ALL ENTRIES IN T_CDHDR
         WHERE OBJECTCLAS EQ T_CDHDR-OBJECTCLAS
           AND OBJECTID   EQ T_CDHDR-OBJECTID
           AND CHANGENR   EQ T_CDHDR-CHANGENR.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          W_FLAG = 1.
          MESSAGE S833(M8) WITH 'Item Not Found'(032).
        ENDIF.                             " IF SY-SUBRC NE 0.
    ENDIF.                               " IF NOT T_CDHDR IS INITIAL
      T_CDPOS_TEMP[] = T_CDPOS[].
    ENDFORM.                               " SELECT_CHANGED_VALUE
    *&   Form  SELECT_PUR_DOC
       Subroutine to select Purchase Order Details
       There are no interface parameters to be passed to this subroutine.
    FORM SELECT_PUR_DOC .
    IF NOT T_CDPOS IS INITIAL.
        SORT T_EBELN BY EBELN.
        LOOP AT T_CDPOS INTO FS_CDPOS.
          READ TABLE T_EBELN INTO FS_EBELN WITH KEY EBELN =
                                          FS_CDPOS-OBJECTID BINARY SEARCH.
          IF SY-SUBRC NE 0.
            DELETE TABLE T_EBELN FROM FS_EBELN.
          ENDIF.                           " IF SY-SUBRC NE 0.
        ENDLOOP.                           " LOOP AT T_CDPOS...
        LOOP AT T_EBELN INTO FS_EBELN.
          MOVE FS_EBELN-EBELN TO FS_EKKO-EBELN.
          MOVE FS_EBELN-ERNAM TO FS_EKKO-ERNAM.
          MOVE FS_EBELN-LIFNR TO FS_EKKO-LIFNR.
          MOVE FS_EBELN-EKGRP TO FS_EKKO-EKGRP.
          MOVE FS_EBELN-BEDAT TO FS_EKKO-BEDAT.
          APPEND FS_EKKO TO T_EKKO.
        ENDLOOP.                           " LOOP AT T_EBELN...
        T_EKKO_TEMP[] = T_EKKO[].
    ENDIF.                               " IF NOT T_CDPOS IS INITIAL
    ENDFORM.                               " SELECT_PUR_DOC
    *&  Form  SELECT_VENDOR
      Subroutine to select Vendor details
      There are no interface parameters to be passed to this subroutine.
    FORM SELECT_VENDOR .
      IF NOT T_EKKO IS INITIAL.
        SORT T_EKKO_TEMP BY LIFNR.
        DELETE ADJACENT DUPLICATES FROM T_EKKO_TEMP COMPARING LIFNR.
        SELECT LIFNR                       " Account Number of Vendor or
                                           " Creditor
               NAME1                       " Name 1
          FROM LFA1
          INTO TABLE T_LFA1
       FOR ALL ENTRIES IN T_EKKO_TEMP
         WHERE LIFNR EQ T_EKKO_TEMP-LIFNR.
       IF SY-SUBRC NE 0.
         MESSAGE S002(M8) WITH 'Master Details'(033).
       ENDIF.                              " IF SY-SUBRC NE 0.
      ENDIF.                               " IF NOT T_EKKO IS INITIAL
    ENDFORM.                               " SELECT_VENDOR
    *&  Form  DESCRIPTION
      Subroutine to get the description
      There are no interface parameters to be passed to this subroutine.
    FORM DESCRIPTION .
    IF NOT T_CDPOS IS INITIAL.
        SORT T_CDPOS_TEMP BY TABNAME FNAME.
        DELETE ADJACENT DUPLICATES FROM T_CDPOS_TEMP COMPARING TABNAME FNAME
        SELECT TABNAME                     " Table Name
               FIELDNAME                   " Field Name
               ROLLNAME                    " Data element
          FROM DD03L
          INTO TABLE T_DATAELE
       FOR ALL ENTRIES IN T_CDPOS_TEMP
         WHERE TABNAME EQ T_CDPOS_TEMP-TABNAME
           AND FIELDNAME EQ T_CDPOS_TEMP-FNAME.
        IF NOT T_DATAELE IS INITIAL.
        T_DATAELE_TEMP[] = T_DATAELE[].
        SORT T_DATAELE_TEMP BY ROLLNAME.
        DELETE ADJACENT DUPLICATES FROM T_DATAELE_TEMP COMPARING ROLLNAME.
          SELECT ROLLNAME                  " Data element
                 DDTEXT                    " Short Text Describing R/3
                                           " Repository Objects
            FROM DD04T
            INTO TABLE T_TEXT
         FOR ALL ENTRIES IN T_DATAELE_TEMP
           WHERE ROLLNAME EQ T_DATAELE_TEMP-ROLLNAME
             AND DDLANGUAGE EQ SY-LANGU.
          IF SY-SUBRC NE 0.
            EXIT.
          ENDIF.                           " IF SY-SUBRC NE 0.
        ENDIF.                             " IF NOT T_DATAELE IS INITIAL.
    ENDIF.                               " IF NOT T_CDPOS IS INITIAL.
    ENDFORM.                               " DESCRIPTION
    *&  Form  FILL_OUTTAB
      Subroutine to populate the Outtab
      There are no interface parameters to be passed to this subroutine.
    FORM FILL_OUTTAB .
      SORT T_CDHDR   BY OBJECTCLAS OBJECTID CHANGENR.
      SORT T_EKKO    BY EBELN.
      SORT T_LFA1    BY LIFNR.
      SORT T_DATAELE BY TABNAME FIELDNAME.
      SORT T_TEXT    BY ROLLNAME.
      LOOP AT T_CDPOS INTO FS_CDPOS.
        READ TABLE T_CDHDR INTO FS_CDHDR WITH KEY
                                       OBJECTCLAS = FS_CDPOS-OBJECTCLAS
                                       OBJECTID = FS_CDPOS-OBJECTID
                                       CHANGENR = FS_CDPOS-CHANGENR
                                       BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            MOVE FS_CDHDR-USERNAME TO FS_OUTTAB-USERNAME.
            MOVE FS_CDHDR-UDATE    TO FS_OUTTAB-UDATE.
            READ TABLE T_EKKO INTO FS_EKKO WITH KEY
                                           EBELN = FS_CDHDR-OBJECTID
                                           BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                MOVE FS_EKKO-EBELN TO FS_OUTTAB-EBELN.
                MOVE FS_EKKO-ERNAM TO FS_OUTTAB-ERNAM.
                MOVE FS_EKKO-LIFNR TO FS_OUTTAB-LIFNR.
                MOVE FS_EKKO-EKGRP TO FS_OUTTAB-EKGRP.
                MOVE FS_EKKO-BEDAT TO FS_OUTTAB-BEDAT.
                READ TABLE T_LFA1 INTO FS_LFA1 WITH KEY
                                               LIFNR = FS_EKKO-LIFNR
                                               BINARY SEARCH.
                  IF SY-SUBRC EQ 0.
                    MOVE FS_LFA1-NAME1 TO FS_OUTTAB-NAME1.
                  ENDIF.                   " IF SY-SUBRC EQ 0.
              ENDIF.                       " IF SY-SUBRC EQ 0.
          ENDIF.                           " IF SY-SUBRC EQ 0.
        MOVE FS_CDPOS-VALUE_NEW TO FS_OUTTAB-VALUE_NEW.
        MOVE FS_CDPOS-VALUE_OLD TO FS_OUTTAB-VALUE_OLD.
        READ TABLE T_DATAELE INTO FS_DATAELE WITH KEY
                                             TABNAME = FS_CDPOS-TABNAME
                                             FIELDNAME = FS_CDPOS-FNAME
                                             BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            READ TABLE T_TEXT INTO FS_TEXT WITH KEY
                                           ROLLNAME = FS_DATAELE-ROLLNAME
                                           BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                MOVE FS_TEXT-DDTEXT TO FS_OUTTAB-DDTEXT.
              ENDIF.                       " IF SY-SUBRC EQ 0.
          ENDIF.                           " IF SY-SUBRC EQ 0.
        APPEND FS_OUTTAB TO T_OUTTAB.
        CLEAR FS_OUTTAB.
      ENDLOOP.
    ENDFORM.                               " FILL_OUTTAB
    *&   Form  GET_CELL_INFO
       Subroutine to get the Cell Information
    -->  W_VALUE   Holds the value of Hotspot clicked
    FORM GET_CELL_INFO .
      CALL METHOD W_GRID->GET_CURRENT_CELL
        IMPORTING
         E_ROW     =
          E_VALUE   = W_VALUE
         E_COL     =
         ES_ROW_ID =
         ES_COL_ID =
         ES_ROW_NO =
    ENDFORM.                               " GET_CELL_INFO
    *&   Form  VALIDATE_PD_NUM
       Subroutine to validate Purchase Document Number
       There are no interface parameters to be passed to this subroutine.
    FORM VALIDATE_PD_NUM .
      IF NOT S_EBELN[] IS INITIAL.
        SELECT EBELN                       " Purchase Document Number
          FROM EKKO
          INTO W_EBELN
         UP TO 1 ROWS
         WHERE EBELN IN S_EBELN.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          CLEAR SSCRFIELDS-UCOMM.
          MESSAGE E717(M8).
        ENDIF.                             " IF SY-SUBRC NE 0
      ENDIF.                               " IF NOT S_EBELN[]...
    ENDFORM.                               " VALIDATE_PD_NUM
    *&   Form  VALIDATE_VEN_NUM
       Subroutine to validate Vendor Number
       There are no interface parameters to be passed to this subroutine.
    FORM VALIDATE_VEN_NUM .
      IF NOT S_LIFNR[] IS INITIAL.
        SELECT LIFNR                       " Vendor Number
          FROM LFA1
          INTO W_LIFNR
         UP TO 1 ROWS
         WHERE LIFNR IN S_LIFNR.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          CLEAR SSCRFIELDS-UCOMM.
          MESSAGE E002(M8) WITH W_SPACE.
        ENDIF.                             " IF SY-SUBRC NE 0
      ENDIF.                               " IF NOT S_LIFNR[]...
    ENDFORM.                               " VALIDATE_VEN_NUM
    *&   Form  VALIDATE_PUR_GRP
       Subroutine to validate the Purchase Group
       There are no interface parameters to be passed to this subroutine.
    FORM VALIDATE_PUR_GRP .
      IF NOT S_EKGRP[] IS INITIAL.
        SELECT EKGRP                       " Purchase Group
          FROM T024
          INTO W_EKGRP
         UP TO 1 ROWS
         WHERE EKGRP IN S_EKGRP.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          CLEAR SSCRFIELDS-UCOMM.
          MESSAGE E622(M8) WITH W_SPACE.
        ENDIF.                             " IF SY-SUBRC NE 0
      ENDIF.                               " IF NOT S_EKFRP[]...
    ENDFORM.                               " VALIDATE_PUR_GRP
    *& Form  FILL_VARIANT
    Subroutine to fill the Variant Structure
    There are no interface parameters to be passed to this subroutine
    FORM FILL_VARIANT .
    Filling the Variant structure
      W_VARIANT-REPORT = SY-REPID.
      W_VARIANT-USERNAME = SY-UNAME.
    ENDFORM.                               " FILL_VARIANT
    Regards,
    Pavan

  • Performance of ABAP query program

    Hi All,
    A custom program AQNWZ_TALAT=====TCS_AP_ITEMS== is taking lot of time running. And when checked the cost of the select statement is very high.
    I guessed it must be some custom abap query. Correct me if I am wrong.
    Also please let me know how to do the performance tuning on this code? Should I be editing the program directly or should I edit at the abap query level.
    Regards,
    Pooja
    Moderator message: Please Read before Posting in the Performance and Tuning Forum
    Edited by: Thomas Zloch on Dec 3, 2010 11:01 AM

    >A few tips you can use for finetuning a Report
    The actually a good collection of the most important pain points. But the recommendations are unfortunately quite poor, and even wrong. I have updated them a little bit.
    And for German speaking people I have added a reference to a textbook, where arll my recommendations are explained in detail.
    Siegfried
    1) Use mostly primary key to access data.
    ... nonsense, the task determines the WHERE clause, it is not your choice
    2) Before READ u sort the itab
    No
    3) use mostly the indexes fields in ur where clause.
    ... as 1, it is the other way, the task determines the WHERE-clause, make surwe that there is an index which
    supports it
    4) Restrict the the fields retrieved by your select sentences to the minimal set. (Avoid select *)
    nonsense, most SELECT use and must use *, use field list in wide tables
    5) try to use specify where clause so the abap sql optimizer chooses the right index.
    o.k., but who understands that in depth?
    6) Avoid sentences like select lifnr name1 into corresponding fields of lfa1 from lfa1 where....
    feel free to use if required
    (You should declare a working area and select into the working area, is twice faster)
    ... such general statements are always incorrect
    7) use hashed tables instead of standard tables. They are faster
    no, use sorted tables, hashed are very special and can only be used if there is a unique key
    8) avoid the use of collect as much as you can.
    total nonsense, use collect with hashed tables, works perfect, if you use it with standard tables, do not mix it with other statements
    1 Always check the driver internal tables is not empty , while using FOR ALL ENTRIES
    100% correct
    2 Avoid for all entries in JOINS
    ... not generally true
    3 Try to avoid joins and use FOR ALL ENTRIES.
    ... hmmm, there are pages of discussions, this statement was wrong, is wrong and will be wrong!!!
    4 Try to restrict the joins to 1 level only ie only for 2 tables
    nonsense, joins are complicated, you must know hw indexes are used, if everything is fine, then 10 or 20 tables can be joined
    5 Avoid using Select *.
    see 4)
    6 Avoid having multiple Selects from the same table in the same object.
    ... try to avoid to SELECT the same data, different criteria can be necessary
    7 Try to minimize the number of variables to save memory.
    ... obvious,
    8 The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
    ... no is must not the optimizer will not be influenced be the order , but do it, it increases readability
    9 Avoid creation of index as far as possible
    ... no, o.k. if you are not experienced than avoid ... otherwise the creation of the required indexes is absolutely mandatory for new tables, for SAP standard tables most indexes are already there. But still if very new accesses are added, then new indexes can become necessary.
    10 Avoid operators like , > , < & like % in where clause conditions
    ... no, you must add them, but be aware that the search is only poorly supported by them, but the result set is reduced.
    11 Avoid select/select single statements in loops.
    ... if they are going to the database! If the tables are buffered, then these statements are perfect!
    12 Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
    .... Actually try to avoid standard tables, use sorted tables instead. If you must use a standard table, than the recommendation is true.
    13 Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
    .... no, use them if required. Again, if table is buffered, then they MUST be avoided.
    14 Avoid using ORDER BY in selects
    ... if it is not ORDER BY PRIMARY KEY. Again, if the table is buffered, then other orders MUST be avoided.
    15 Avoid Nested Selects
    ... use join. Again, if the tables are buffered, then Nested SELECTs are fine!
    16 Avoid Nested Loops of Internal Tables
    .... impossible, there is no other option. Use sorted tables and verything is fine!
    17 Try to use FIELD SYMBOLS.
    ... what means try? Use ASSIGNING fieldsymbol in LOOPs, but use it in READs only for very wide tables (>1kB). Use it always for tables with tables in the workarea!
    18 Try to avoid into Corresponding Fields of
    ... see 6) is wrong!
    19 Avoid using Select Distinct, Use DELETE ADJACENT.
    .... no, use it if required and if it can reduce the result set by a factor of 2 or more. Again, if table is buffered, then it MUST be avoided.
    Wenn Sie mit der Performance Ihres ABAP Programms nicht zufrieden sind, werfen Sie doch einen Blick in mein neues Buch:
    Siegfried Boes: Performance-Optimierung von ABAP®-Programmen Nov. 2009 464 Seiten  59u20AC
    Leseproben und weitere Informationen: http://www.dpunkt.de/buecher/3096.html
    Edited by: Thomas Zloch on Dec 3, 2010 10:53 AM

  • ABAP QUERY(sq02)

    Hi friends,
         I am using PNP LDB in SQ02 .
         i am selecting AT SELECTION-SCREEN in "CODE tab" but it's not selected
         How to use "F4 help function module" in ABAP Query(SQ02).
    Thanks & Regards,
    Vallamuthu.M

    Hi
    Why you are using SQ01/02 query? you can't get all the facilities what you use in general abap program report
    Query is basically intended for functional consultants to get the data by joining the tables
    it is Client specific and user specific
    You can't use all the events and F4 help like thing in them.
    see the doc
    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
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • ABAP QUERY PROGRAM OUTPUT SHOULD DISPLAY FROM SAP SCRIPT.

    THIS IS MY URGENT REQUIREMENT ...
    I DONT KNOW ABAP QUERY PROGRAM ..
    PLEASE SUGGEST ME A WAY ON THIS ....
    Functional requirements
    Introduction
    The wish of the customer is a printable customer overview. All desired fields will be shown in a new query called ZZADDRSS_CO. Double entries are taken for granted because of the data taken from the sales area and because of multiple contact persons. The customer accepts this. It should be made possible that the user creates and saves its own variant.
    A second overview is needed, another ABAP will be developed for this requirement. This ABAP will show all the customer data and this list will have the possibility to be printed.
    Solution
    New Query ZZADDRESS_CO
    The desired fields of attachment 1 need to be shown in the query.
    The selection criteria are shown in attachment 2.
    The column names of the additional data have to changed in the query.
    Customer Overview.
    Functional specification.
    On behalf of this customer overview a standard SAP transaction will be used (transaction VC/2).This transaction will be extended.
    The fields are shown on screen with the described headers. Printing of the overview will be done via SAP script. The script makes use of a fixed layout of the data.
    The selection criteria are specified in attachment 2.
    The layout of the customer overview and the SAP Script are specified in attachment 3.
    Specification.
    The next steps need to be performed.
    1.     A routine per infoblock need to be created in Include RV77UNNN. In this routine the data is retrieved and written down to the screen and script,
    Example LST1_901 . In include RV77SNNN you can find the standard infoblocks.
    2.     Adapt via transaction SE16 table TFRM.
    3.     Create a new view in the customizing (sales and distribution- Sales support-sales summary-Assign Reporting Views).Assign the new view to the infoblocks.(Example view 001 is assigned to block 901).
    4.     In customizing it is not possible to assign the correct window and element to the infoblock .so this is done via SE16 in table T182A.
    5.     Adapt script. Copy script SD-SALES-SUMMARY to a Z-SALES_SUMM.
    Assign this new version to the new view in customizing. Create in the main window the element who writes the data on behalf of the print.
    Attachment 1 Desired fields
    Header: Address
    ~ Customer number                          KNA1-KUNNR
    ~ Title                                               KAN1-ANRED
    ~ Name1                                           ADRC-NAME1
    ~ Name2                        ADRC-NAME2
    ~ Name3                                           ADRC-NAME3
    ~ Name4                                           ADRC-NAME4
    ~ PO Box                                         ADRC-PO_BOX
    ~ PO Box POSTAL CODE             ADRC-POST_CODE2
    ~ PO Box city                                  ADRC-PO_BOX_LOC
    ~ Telephone no1                              ADR2-TEL_NUMBER   1ST RECORD
    ~ Telephone no2                              ADR2-TEL_NUMBER   2ND RECORD
    ~ Fax number1                                 ADR3-FAX_NUMBER 1ST RECORD
    ~ Fax number2                                ADR3-FAX_NUMBER 2ND RECORD
    ~ E-mail                                            ADR6-SMTP_ADDR
    ~ Search item                                   ADRC-SORT1
    ~ Notes                                            ADRT-REMARK
    Header: control data
    ~ VAT registration number              KAN1-STCEG
    Header: Payment transactions
    ~Bank country key                         KNBK-BANKS
    ~Bank key                                      KNBK-BANKL
    ~Bank Account number                 KNBK-BANKN
    Header: Marketing
    ~ Industry key                                   KNA1-BRSCH
    ~ Industry code 1                              KNA1-BRAN1
    ~ Industry code 2                              KNA1-BRAN2
    ~ Industry code 3                                KNA1-BRAN3
    ~ Industry code 4                                KNA1-BRAN4
    ~ Industry code 5                               KNA1-BRAN5
    ~Annual sales, currency, year           KNA1-UMSA1, KNA1-UWAER, KNA1-UMAH
    ~ Yearly no of employees, year      KAN1-JMZAH, KNA1-JMJAH       
    ~ Fiscal year variant                          KNA1-PERIV
    ~Legal status                                      KNA1-GFORM
    Header: Correspondence
    ~ Our account number at customer            KNB1-EIKTO
    Header: sales
    ~ Sales office                                              KNVV-VKBUR
    ~ Customer group                                       KNVV-KDGRP
    ~ ABC-classification                                  KNVV-KLABC
    Header: Invoice
    ~Tax classification                          KNVI-TAXKD
    ~Terms of payment key                    KNVV-ZTERM
    ~
    Header: Contact Persons
    ~Title                                   KNVK-ANRED
    ~Name                                   KNVK-NAME1
    ~Advertising material                         KNVK-NMAIL
    ~Martial Status                         KNVK-FAMST
    ~Notes                                   KNVK-PARAU
    ~Function                              KNVK-PAFKT
    ~Department                              KNVK-ABTNR
    Header: Partnerroles
    ~Personnel Number                         KNVP-PERNR
    ~Name of employee                         PA0001-ENAME
    Header: Additional Data
    ~Attribute 1                              KNA1-KATR1
    ~Creation date                              KNA1-ERDAT
    ~Attribute 2                              KNA1-KATR2
    ~Change date of field KNA1-KATR2          CDHDR-UDATE
    ~Attribute 3                              KNA1-KATR3
    ~Attribute 4                              KNA1-KATR4          
    ~Attribute 5                              KNA1-KATR5
    ~Attribute 6                              KNA1-KATR6
    Attachment 2 Selection fields
    ~Customer number
    ~Sales office
    ~Personnel Number
    ~Sales Organization (default NL01)
    ~Industry key
    ~Industry codes (1 till 5)
    ~ABC- classification
    ~Creation date
    ~Attribute 1
    ~Attribute 2
    ~Attribute 3
    ~Attribute 4
    ~Attribute 5
    Attachment 3 Customer overview + SAP Script
    Customer master data sheet: 11490                 Page1
    Requested by karen Dunnewold                Date: 25.08.2004
    Address
    (Default SAP script ADDRESS statement)
    Title
    Name1
    Street + number
    PO Box city
    Country
    Search term: ADRC-SORT1
    Telephone 1:      ADR2-TEL_NUMBER     2: ADR2-TEL_NUMBER
    Fax 1:          ADR3-FAX_NUMBER     2: ADR3-FAX_NUMBER
    E-mail:          ADR6-SMTP_ADDR     
    Notes:           ADRT-REMARK
    PO BOX
    ADRC-PO_BOX
    ADRC-POST_CODE2 ADRC-PO_BOX_LOC
    T005T-LANDX (T005T-LAND1 = ADRC-COUNTRY)
    Control data
    VAT registration number:     KNA1-STCEG
    Payment transactions
    Country: KNBK-BANKS Bank-key: KNBK u2013 BANKL Bank account: KNBK-BANKN
    Marketing
    Industry           KNA1-BRSCH     Industry Description
    Industry code1          KNA1-BRAN1     Industry Description
    Industry code2          KNA1-BRAN2     Industry Description
    Industry code3          KNA1-BRAN3     Industry Description
    Industry code4          KNA1-BRAN4     Industry Description
    Industry code5          KNA1-BRAN5     Industry Description
    Figures
    Annual Sales          KNA1-UMSA1, KNA1-UWAER in KNA1-UMAH
    Employees          KNA1-JMZAH                         in KNA1-JMJAH
    Legal status            KNA1-GFORM description
    Customer master data sheet 11490                         Page 2
    Requested by karen Dunnewold                         Date: 25.08.2004
    Contact Persons
    KNVK-ANRED
    Mailings: KNVK-NMAIL           Notes: KNVK-PARAU
    KNVK-ANRED
    Mailings: KNVK-NMAIL           Notes: KNVK-PARAU
    Correspondence
    Our account number at customer      KNB1-EIKTO
    Sales
    Sales office          KNVV-VKBUR     Description
    Customer group     KNVV-KDGRP     Description
    ABC-classify          KNVV-KLABC
    Currency          KNVV-WAERS
    Invoice
    Terms of payment key KNVV-ZTERM      Tax classification KNV1-TAXKD
                                  Description     
    Partner (Leave SAP default)
    Partnerrole               Number          Name
    KNVP-PARVW          KNVP-KUNNR     NAME1
    KNVP-PARVW          KNVP-KUNNR     NAME1
    Additional data
    Attribute1          kna1-katr1     Description
    Attribute2          kna1-katr2     Description
    Attribute3          kna1-katr3     Description
    Attribute4          kna1-katr4     Description
    Attribute5          kna1-katr5     Description
    Attribute6          kna1-katr6     Description

    hi narayana
    i think u need to write a driving program and a provided with a smatform u sit along with the SD consultant.
    ur further views can be shared.
    Rgs,
    Venkat.

  • Generation of program code for the ABAP Query

    Dear all,
    In the creation of the ABAP query, in the final step of SQ01, Query- more functions- generate program is made.
    Why the program code is generated for the ABAP query? please  give the logical explaination for the same.
    Thanks and Regards,
    Prash

    Prash,
    a) Do you mean Program code does not have significance in query creation?
    No it does not mean this.  All queries run based on an ABAP program.  In the standard query editing process, when you save and execute the query, you will automatically re-build the existing ABAP program as necessary.  You do not need, though, to execute the menu steps you outlined in order to build, maintain, or execute the query.  It is only there for special purposes, as outlined above by Jürgen
    b) Can we see the program code generated in any transaction?
    From any screen, System > Status.  Place your cursor on the field in "Program (screen)".  Double click.
    Rgds,
    DB49

  • Abap query tool

    Hi Anji,
    Pls send the procedure (steps) in abap query tool.How to generate a report by using query tool?
    thanks in advance
    ramu

    Hi
    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
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • ABAP Query and SAP quary

    What is the diff between ABAP Query and SAP quary?

    Balu,
    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.
    Check out these links.
    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.
    Kindly reward points by clicking the star on the left of reply,if it helps.Kindly close your previous threads if your problem is solved and reward points for helpful answers.
    Don't forget to reward if useful...

Maybe you are looking for

  • Can you synch two itunes accounts on the same computer?

    can you synch two itunes accounts on the same computer?

  • Firefox won't start (not even in Safe Mode) on Windows 7 x64

    I am Running Windows 7 x64 and Firefox 3.6.15. Since the day before yesterday I am unable to start Firefox. Even in Safe Mode it just won't start. I click the Firefox icon, the mouse cursor changes to indicate the computer is doing something. After 3

  • How to attach input file in the Test Script in SECATT in ECC6 ?

    Hi , How to attach input file in the Test Script in ECC6  in Tcode SECATT ? For Testing in SECATT in ECC6, how to attach input file which contains multiple records ? Best Regards, Padhy

  • 4:3 Anamorphic Q's

    Hi guys Trying to create a 4:3 anamorphic clip, the footage is shot 4:3. When I capture the footage in either 4:3 or 4:3 anamorphic it still needs to be slightly enlarged to prevent pillarboxing. I am after the 4:3 letterbox effect, (not true widescr

  • Is "out of box" Planning flawed?

    Hi, I just joined a company that is rolling out Planning v11.1 and noticed the same flaw in design that I found in Planning v9.3.1 over a year ago. In fact, Pillar was designed right - Take Forecasting of Payroll Taxes for example- Pillar calculates