Skip to Content
author's profile photo Former Member
Former Member

why we need parameter, diff between single up to 1row, select single

why we need parameter, diff between single up to 1row, select single

Edited by: Alvaro Tejada Galindo on Mar 4, 2008 3:15 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 04, 2008 at 08:01 AM

    If U want to take only one value in the INPUT screen U'll define it to

    be a parameter.

    Select single should be used if U know the entire key .. i.e. U have

    all the key fields in the where condition ..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 04, 2008 at 08:01 AM

    hi,

    look at this

    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only

    the first one will be returned and therefore may not be unique.

    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause or lack of,

    applies any aggregate, ordering or grouping functions to them and then returns the first record of the resultant result set.

    Get the difference ??

    If not, then create a Ztable called ZDifference with 2 fields in it, MANDT of type MANDT and POSNR of type POSNR. Make sure both of these are keys. Also

    create a table maintenance dialog for it (SE11->Utilities->Table Maintenance Generator). Fill the table with ten rows 000001-000010.

    Then run the program shown below:

    Code:

    Program: Z_Difference

    Purpose: A program that demonstrates the difference

    between SELECT SINGLE and SELECT UP TO n ROWS.

    This program requires the data table Z_DIFFERENCE

    to have been created according to the structure

    outlined in the text above and populated with

    at least 10 records.

    Creation Date: 21/04/2004

    Requested By:

    Reference Doc:

    Author: R Harper

    Modification History:

    Date Reason Transport Who

    Report Z_Difference

    Message-id 38

    Line-Size 80

    Line-Count 0

    No Standard Page Heading.

    Start-Of-Selection.

    Data: w_Single type Posnr,

    t_Rows type standard table of Posnr

    initial size 0

    with header line.

    Select single Posnr

    from zDifference

    into w_Single.

    Select Posnr

    into table t_Rows

    from zDifference

    up to 1 rows

    order by Posnr descending.

    Write :/ 'Select single:', w_Single.

    Skip 1.

    Write :/ 'Up to 1 rows :'.

    Loop at t_Rows.

    Write t_Rows.

    EndLoop.

    You should see the output:

    Code:

    Select single: 000001

    Up to 1 rows : 000010

    The first 'SELECT' statement has selected the first record in the database according to any selection criteria in the 'WHERE' clause. This is what a

    'SELECT SINGLE' does. The second 'SELECT' has asked the database to reverse the order of the records before returning the first row of the result.

    In order to be able to do this the database has read the entire table, sort it and then return the first record. If there was no ORDER BY clause then the

    results would have been identical (ie both '000001') but the second select if given a big enough table to look at would be far slower.

    <REMOVED BY MODERATOR>

    Edited by: Alvaro Tejada Galindo on Mar 4, 2008 3:16 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 04, 2008 at 08:06 AM

    HI

    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.

    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.

    Mainly: to read data from

    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.

    Mainly: to check if entries exist.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 04, 2008 at 08:12 AM

    HI,

    1) 'select single .... up to 1 rows' CANNOT be used.

    If u use, "SELECT SINGLE", "up to" clause cannot be used. Bcoz, the 'select single' is used to retrieve ONLY ONE record out of all the records which satisfies the condtion given in WHERE clause.

    2) If u use 'SELECT' statement, u need put 'INTO TABLE'. Bcoz it can retrieve MANY records from the given condition.

    <REMOVED BY MODERATOR>

    Regards,

    Shanthi.

    Edited by: Alvaro Tejada Galindo on Mar 4, 2008 3:16 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 04, 2008 at 08:52 AM

    Hi,

    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.

    select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.

    The best way to find out is through sql trace or runtime analysis.

    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.

    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.

    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.

    Mainly: to read data from

    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.

    Mainly: to check if entries exist.

    Regards,

    Priya.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 04, 2008 at 10:04 AM

    why we use classical reports

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Classical Reports

      These are the most simple reports. Programmers learn this one first. It is just an output of data using the Write statement inside a loop.

      Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT.

      Events In Classical Reports.

      INTIALIZATION: This event triggers before selection screen display.

      AT-SELECTION-SCREEN: This event triggers after proccesing user input still selection screen is in active mode.

      START OF SELECTION: Start of selection screen triggers after proceesing selection screen.

      END-OF-SELECTION : It is for Logical Database Reporting.

      Edit section Interactive Reports

      Regards,

      Chandru

  • author's profile photo Former Member
    Former Member
    Posted on Mar 04, 2008 at 10:09 AM

    Hi,

    CLASSICAL REPORTS:

    -


    Fetching records from one table or more than one table according to client's requirements is called as classical reporting.

    Classical Unformatted reporting:

    -


    No colors, header, footer or outlines are drawn for the list.

    Classical Formatted reporting:

    -


    A constant header, footer, colors are added to field values in the list.

    eg. code:

    -


    REPORT Z_REPORTS NO STANDARD PAGE HEADING LINE-COUNT 20(2) .

    DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

    SELECT * FROM KNA1 INTO TABLE ITAB.

    LOOP AT ITAB.

    WRITE :/ ITAB-KUNNR, ITAB-NAME1, ITAB-LAND1, ITAB-ORT01.

    ENDLOOP.

    TOP-OF-PAGE. * Event is used to create constant header area for the list

    WRITE :/40(40) 'CUSTOMER MASTER DETAILS' COLOR 5.

    SKIP 1.

    END-OF-PAGE. * Event is used to create constant footer area for the list

    WRITE :/50(40) 'THE CURRENT PAGE NUMBER IS' COLOR 6, SY-PAGNO COLOR 6.

    Regards,

    Priya.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.