How to select top one in CDS view ?

I have tried following logic to select top one in CDS view but its giving error -
define view Cds_View_First_Reference as select  top one CReferredObject from CDSVIEWCROSSREF

Hi Ruchi,
since you posted this question in "ABAP in Eclipse" I assume you are asking about CDS in ABAP. This is important because the CDS features sets in ABAP and (native) HANA are different.
Be that as it may,, SELECT TOP 1 is neither supported in the CDS implementation in ABAP nor in HANA.
In ABAP you might consider using the min() or max() function together with the appropriate GROUP BY clause in the CDS view (depending on what you want to achieve), but you can also easily "implement" this in the Open SQL statement which selects from your CDS view.
Using the additions SELECT SINGLE or UP TO 1 ROWS and an appropriate ORDER BY clause in Open SQL, you can achieve the same as SELECT TOP 1.
Unfortunately there is currently no possibility to define a view which delivers the TOP 1 which you can again use in another view ("view on view").
Kind regards
Chris

Similar Messages

  • How to select only one record at a time in ALV

    Hi all,
    I have to use ALV report.  Each record on the report output should have a button (or radio button) which will allow the record to be selected.  My requirement is to select only one record at a time.
    please guide me how to proceed further.
    regards
    manish

    hi
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/sampleCheckBoxProgram
    Regards
    Pavan

  • How to select top 10 records

    How can I use SQL to select the top 10 records (do not use cursor)

    ... not only that but the order by and rownum check cannot be done in the same select. You need an in-line view.
    select * from
    (select * from table
    order by whatever)
    where rownum < 11
    BEWARE: Incorrect use of rownum (which is very common) often returns the correct result by accident, but you cannot guarantee that the accident will continue to happen.

  • How to select the node in structure view from selected xml page item

    Hi All,
    I have imported the xml file. Now drag and dropped the root node in the documentt.Now i select a item from it.When i select an item, i need the node in the structure view to get selected.
    In Indesign we have an menu option "Select in structure".
    How to go about it?
    Regards
    Sakthi

    Hi All,
    I have imported the xml file. Now drag and dropped the root node in the documentt.Now i select a item from it.When i select an item, i need the node in the structure view to get selected.
    In Indesign we have an menu option "Select in structure".
    How to go about it?
    Regards
    Sakthi

  • How to select option to the particular view container

    Hi All,
    I am working on ALV , i have view container for search parameters, here i want to add select option in to the same view container.. anyone help me to achive the same.
    Thanks
    Ram

    As Tamil said above, you have to put the select options in the view that you are embedding in the view container. For help on how to use select options in webdynpro, you can have a look at the tutorial in the following link...
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c09fec07-0dab-2a10-dbbe-c9a26bdff03e

  • Have 2 Printers, How to select different one as default?

    Hi there,
    Our office has two printers, an HP officejet 8600 and an HP officejet 7500 E910. My colleague and I originally only had the driver software for the 8600, and are both connected wirelessly to both printers. In order to print A3 size paper, we downloaded the driver software for the 7500. Now both of our computers automatically use the 7500 printer as the default. This is no good because it is our bosses printer, which is often in a locked office and we don't want to waste the ink or paper if we can't access it etc. etc and aren't thinking to select the 8600 printer.
    So my question is, how can we make our computers automatically select the 8600 as our default printer?
    Thanks
    R
    This question was solved.
    View Solution.

    What operating system?  In Windows 7 you would click Start, Devices and Printers, right click on the Officejet Pro 8600 and select "Set as default printer".  Other Windows operaing systems would be similar, I do not know about Mac.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • How to select only one row

    hello,
    i've got a select query which returns a couple of rows.
    now i would like for the query to return only one row (the first match it can find).
    how do i do that?
    thank you!
    my sample of my data as below , the first and seconde record is equal and i want to display all the colomn for the first row and ignore the second row .
    84A8E46E8C97     9410     20110812
    84A8E46E8C97     9420     20110813
    84A8E46E8C6E     9410     20110816
    84A8E46E8AFA     9400     20110819

    876602 wrote:
    my sample of my data as below , the first and seconde record is equal and i want to display all the colomn for the first row and ignore the second rowThere is no row order in relational database tables. Same query canreturn rows in different order next time you run it unless you specify ORDER BY. Only ORDER BY guarantees order, so when you say first row/second row you must provide ordering criteria.
    SY.

  • How to Selectively Delete ONE Key Figure from Cube....

    Hi:
    On a Daily basis (Via Process Chain), I need to do the following:
    1.  DELETE Single Key Figure from my planning cube.  When the "PYMNT DATE" is greater than System Date, then delete the
         key Figure.
    2.  Once Deleted, LOAD the same Single Key Figure from another cube when the PYMNT DATE is GT  System Date. 
    How can I do this in a Program.  What would be the code for this?  Need help with ABAP.
    Thanks in advance.....  PBSW

    Hi,
    See Article on Selective Deltaion in
    http://wiki.sdn.sap.com/wiki/display/profile/Surendra+Reddy
    Using Selective Deletion in Process Chains
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/business-intelligence/s-u/using%20selective%20deletion%20in%20process%20chains.pdf
    Thanks
    Reddy

  • Multiple JREs installed - how to select correct one?

    Hi all
    I have multiple JREs installed on my computer, which I need to keep.
    I'm doing some development, and when I try to run the class, I get the following error:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorldApp
    (Unsupported major.minor version 50.0)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)java -version shows:
    java version "1.3.1_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
    Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)The reason I'm getting this error is because Eclipse is using the following JRE:
    C:\Program Files\Java\jre6\bin>java -version
    java version "1.6.0_17"
    Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
    Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)My Path environment variable is:
    C:\Program Files\Java\jre6;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Intel\DMIX;C:\Program Files\Gemalto\GACMy CLASSPATH environment variable is:
    C:\Program Files\Java\jre6;C:\Program Files\gemalto\gac\GATicket.jar;How do I force my Windows XP system to use the latest JRE installed?
    Thanks

    Thanks again.
    However, it appears the PATH variable may be a red herring.
    If I set the class path to exclude the jre6 directory, as follows:
    C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Intel\DMIX;C:\Program Files\Gemalto\GACThen the following error occurs:
    C:\Documents and Settings\Me\workspace\RegexTestProject\bin\regextest>java -
    version
    java version "1.3.1_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
    Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
    C:\Documents and Settings\Me\workspace\RegexTestProject\bin\regextest>dir
    Volume in drive C has no label.
    Volume Serial Number is 2806-C30D
    Directory of C:\Documents and Settings\Me\workspace\RegexTestProject\bin\re
    gextest
    03/09/2010  13:55    <DIR>          .
    03/09/2010  13:55    <DIR>          ..
    03/09/2010  13:56             1,707 RegexTestHarness.class
                   1 File(s)          1,707 bytes
                   2 Dir(s)  11,257,622,528 bytes free
    C:\Documents and Settings\Me\workspace\RegexTestProject\bin\regextest>java R
    egexTestHarness
    Exception in thread "main" java.lang.UnsupportedClassVersionError: RegexTestHarn
    ess (Unsupported major.minor version 50.0)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)This is expected as the class was compiled using a later version of the JDK.
    However, if I update the PATH, and add the JRE6 entry to the path as follows:
    C:\Program Files\Java\jre6\bin;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Intel\DMIX;C:\Program Files\Gemalto\GACI then get a class not found exception!!??
    C:\Documents and Settings\Me\workspace\RegexTestProject\bin\regextest>java -
    version
    java version "1.6.0_17"
    Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
    Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
    C:\Documents and Settings\Me\workspace\RegexTestProject\bin\regextest>dir
    Volume in drive C has no label.
    Volume Serial Number is 2806-C30D
    Directory of C:\Documents and Settings\Me\workspace\RegexTestProject\bin\re
    gextest
    03/09/2010  13:55    <DIR>          .
    03/09/2010  13:55    <DIR>          ..
    03/09/2010  13:56             1,707 RegexTestHarness.class
                   1 File(s)          1,707 bytes
                   2 Dir(s)  11,257,618,432 bytes free
    C:\Documents and Settings\Me\workspace\RegexTestProject\bin\regextest>java R
    egexTestHarness
    Exception in thread "main" java.lang.NoClassDefFoundError: RegexTestHarness (wro
    ng name: regextest/RegexTestHarness)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$000(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: RegexTestHarness.  Program will exit.Below is the code of the class:
    package regextest;
    import java.io.Console;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    public class RegexTestHarness {
        public static void main(String[] args){
            Console console = System.console();
            if (console == null) {
                System.err.println("No console.");
                System.exit(1);
            while (true) {
                Pattern pattern =
                Pattern.compile(console.readLine("%nEnter your regex: "));
                Matcher matcher =
                pattern.matcher(console.readLine("Enter input string to search: "));
                boolean found = false;
                while (matcher.find()) {
                    console.format("I found the text \"%s\" starting at " +
                       "index %d and ending at index %d.%n",
                        matcher.group(), matcher.start(), matcher.end());
                    found = true;
                if(!found){
                    console.format("No match found.%n");
    }Based on the above, I think the path is set correctly, but I'm doing something else wrong.
    Thanks for you help so far. :-)

  • Questions on CDS Views with input parameters

    Dear Experts,
    1. Can we call a CDS View (or generated database view) with input parameters inside an AMDP? I am looking for something similar to the feature in HANA where we can consume calculation view with filters inside SQL Script?
    2. I understand we can next CDS Views, but how we can next (call) a CDS View with input parameters inside another CDS View?
    Thanks,
    Giri

    Hi Thomas,
    I get the below error that the CDS View's generated table function cannot take field from AMDP.
    I have a requirement to query the CDS View using 2 timestamps (start & end). So, in AMDP I have used the TIME_STAMP and try to pass it to the CDS View
    View code:
    define view Z_Ngi_Cag_A
    with parameters start_ts:abap.dec( 15, 0 ) , end_ts:abap.dec( 15, 0 )
    as select from table {
    resource_key
    where
    (begtstmp > $parameters.start_ts or endtstmp > $parameters.start_ts )
    and
    (begtstmp < $parameters.end_ts or endtstmp < $parameters.end_ts )
    I am calling using the below AMDP:
    DECLARE iv_start_date TIMESTAMP;
    DECLARE iv_end_date TIMESTAMP;
    SELECT CURRENT_TIMESTAMP INTO iv_start_date from dummy;
    SELECT ADD_DAYS(CURRENT_TIMESTAMP, 30) INTO iv_end_date from dummy;
    et_data =      SELECT * FROM ZMR_H_CA ( start_ts => iv_start_date, end_ts =>  iv_end_date );
    What could be wrong ? Is this not supported?
    Thanks,
    Giri

  • Union in CDS View with different columns

    Hello,
    I have two entities E1 {a: Integer; b: Integer} and E2 {a: Integer; c: Integer} and I want to build a CDS view which does a union on both like:
    SELECT a, b, null as c FROM E1
    UNION SELECT a, null as b, c  FROM E2
    I have written the following:
    view UnionView as select from E1 {a, b, null as c} union select from E2 {a, null as b, c}
    Now I get the error message: Feature is not supported
    Has anybody an idea, how to model this with a CDS view? With a graphical calculation view, this is possible, but I want to build it as a CDS view.
    Regards,
    Michael

    What revision is your system on?  I show that UNION was new syntax in SPS 09.
    http://help.sap.com/hana/SAP_HANA_Core_Data_Services_CDS_Reference_en.pdf
    I tried the following in my system and it worked just fine:
    namespace playground;
    @Schema: 'PLAYGROUND'
    context unionDemo {
        entity E1 {
      key a : Integer;
      b : String(20);
      c : LocalDate;
    entity E2 {
      key x : String(20);
      y : LocalDate;
      z : Integer;
    view V as
      select from E1 { a, b, c}
      union
      select from E2 { z, x, y};

  • How to select correct size for publish media browser

    I have successfully imported and edited movie from my Sony cam. Now when I share it via idvd, the size of the video is large. It doesn't look the same as imovie preview.
    How to select the right size to view video threw idvd?

    The size that plays on the screen. I'm doing share->media browser-> medium(640x360). with idvd, import media browser, select theme and burn dvd. The problem is when I playback the video it's shows as widescreen (large) as oppose to the normal viewing threw imovie preview.

  • The Organizer – How to select a project

    I am new to the Organizer.In the SlideShow Editor, I created two test projects and saved them.
    I went back to the Photo Browser and under Edit I clicked "Show Project Items in Photo Browser." However I cannot figure out how to select just one project. I do not see a list of my saved projects names anywhere. I looked under all menus and checked all the bottons. The projects are saved. I tried to save them again and a pop up window shows the mesage "a prject with the same name already exists..." How to select a specific project?
    Furthermore the option "Show Project Items in Photo Browser" no longer shows. How do I remove this option?
    Please help,
    CarlosWA

    I found the saved projects. They are in
    Photo Browser > Find > By Media Types > Projects
    I find it incredible that I could not find this information in Help and other Internet resources.
    CarlosWA

  • How to specify key in CDS view?

    I defined a CDS view based on an entity. When I activate, it says:
    Missing specification of keys for view "sap.ms.data::DB.ApplicationView".
    However, I am at a lost how the specify key in CDS View. The developer guide did not mention anything. If I put a key before one of the attribute:
    Cannot find sub artifact "key" in "Application"
    My CDS view is as follows:
    view ApplicationView as select from Application {
      ApplicationId,
      AccountRef.AccountId,
      DisplayName,
      Version

    I found out how to do it, define the key in the service descriptor as:
    service {
    "sap.ms.data::DB.ApplicationView" as "App" key ("ApplicationId", "AcctId");

  • How to select one row in a table with radio button

    Hi all.
    I have a VO where there is an attribute (isDefault [String]) that identifies the default record in the view. The possible values are 'Y' for yes and 'N' for no. Obviously only one record can have the 'Y' value.
    In my page I have created an ADF Table (with the usual data control drag & drop). I would to transform the default inputText of "isDefault" field with a selectOneRadio component in order to permit the user to select (and save contextually in the DB) the default row of this table.
    Can you explain me how? I'm using JDeveloper 11.1.1.4.
    Thanks in advance.
    Baduel

    Baduel wrote:
    Cvele,
    thanks for your responses. Yes, it's easier to use af:selectBooleanCheckbox but I need that the selection is mutually exclusive (only one row can be selected). >If this is possible also with the boolean checkbox please tell me how.- Let's try with CheckBox :
    1. At the ViewObjectImpl level (for example, YourViewObjectImpl), add the following code:
      private oracle.jbo.Key currSelectedRowKey = null;
      public void doRowSelection(Key newKey) {
          // de-select old one
          if (currSelectedRowKey != null) {
              Row[] rows = findByKey(currSelectedRowKey,  1);
              if (rows != null && rows.length > 0)
                   rows[0].setStatusAsBoolean(Boolean.FALSE); // cast to the appropriate row Impl class if need !
         // remember a new selected row key:
        currSelectedRowKey = newKey;
      }In the ViewRowImpl, in the transient attr settter, do as follows:
      public void setStatusAsBoolean(Boolean value) {
         setStatus(value.booleanValue() ? ONE : ZERO);
         if (value.booleanValue()) {
             YourViewObjectImpl vo = (YourViewObjectImpl)getViewObject();
             vo.doRowSelection(getKey());
       }   P.S. The above was not tested at all, but should give you an idea

Maybe you are looking for

  • Can't back up using time machine...

    I am trying to back up my MBP (2010) running lion. Everytime i have tried to back it up over the last couple of weeks, i have returned to this message (shown below), and occasionallly a message telling me that my external drive (Western Digital 2TB)

  • SanDisk Extreme Pro ExpressCard wont install ... ?

    All, I have an older (2007) MacBook Pro lying around that I am attempting to turn into a "media" station for managing digital photos and whatnot. To make this work, I needed to (1) install Windows 7, and (2) get a reader that would let me access my S

  • Regarding LMW

    Hi Gurus    While I am uploading a file using LSMW technique in Batch Input method. I was stucked in 2 things. Please go thru this and suggest me ur views. While recording ,for some values for eg: KOMGG-KUNNR or KOMGG-KUNWE  from database it will com

  • Is there a way to zoom out the viewing window of mac applications?

    Is there a way to zoom out the viewing window of mac applications? I know for sure in safari I can zoom out, but it reverts to the original size as soon as I close out the window. I would really like to do this in safari and mail. Thank you.

  • Errors and incompetent staff

    Does anyone else find Bt business billing grossly incompetent?? I've had 10 months of billing errors, incurred hundreds of pounds of fees and constantly get calls to pay for a website that doesn't work. I've paid for changes and nobody has called me.