Create a record using SAPUI5 and ODATA Service

Hi there,
since SPS6, SAP HANA should allow CRUD operations using an ODATA Service.
That sounds nice and so I wanted to give it a try.
I've started by creating a simple table and set up a tiny application that displays the data in a grid (using a JSON Model) and allows to insert new records by entering data into two textfields and save them as a new record to the databse. That works well, the grid shows the records which I have created using the SAP HANA Studio.
So I wanted to create new records, and the documentation says very clearly how to create a new record.
I've tried it this way, but when the request is send I get an 501 Not Implemented error.
Thats the code I'm using in my SAVE-Button:
btnSave.attachPress(function() {
   var entry = {};
   entry.id = tfUserId.getValue();
   entry.username = tfUserName.getValue();
   oData.create('/tbl_user', entry, null,
   function() {
      alert("Create successful");
   function() {
      alert("Create failed");
After that I've tried to create a record using the POSTMAN extension for Chrome browser as mentioned in this cool video by Thomas Jung.
Unfortunately, this also doesn't work for me. After sending the request I get as respone a sap hana xs login window with Status Code 200 instead of a status code "201 created".
Here's a screenshot:
I'm using SAP HANA Cloud Trial.
Anybody got an idea what I'm doing wrong? Or does ODATA CRUD not work an SAP HANA Cloud Trial?
Many thanks,
ben

Hi Jason,
exactly, it's the logon page returned that is opened when I open the service URL in the browser. After logging on I can see the results of the ODATA service call.
The URL must be correctly defined, the grid shows up the data from the ODATA Service.
And yes, the URL looks OK when expecting in Chrome developer tools...
Thanks,
ben

Similar Messages

  • REST and ODATA service

    Hi,
    I am using PI 7.4.
    I have few queries regarding REST and ODATA service -
    What is REST based services in PI?
    If there is an ODATA service in SAP, how can we use that in PI for mapping needs?
    Where we need to use BAPIs and where we can consume odata services that are being built for SAP UI5 project.

    Hi
    Kindly check the following links:
    REST Adapter on Advanced Adapter Engine (New) - What's New in SAP NetWeaver 7.4 (Release Notes) - SAP Library
    REST Adapter on Advanced Adapter Engine (New) - What's New in SAP NetWeaver 7.3 EHP1 (Release Notes) - SAP Library
    https://www.advantco.com/product/REST
    PI REST Adapter - Blog Overview
    Regards,
    Xineohpi

  • SAPUI5 and OData dynamic Login

    can anybody share some standard code that sapui5 and odata dynamic login screen navigation ?
    Means User has to pass input Username and Password atrun time and get login.
    Thank you in advanced

    I am getting error at validation time but in browser it is working fine.
    The error is Unauthorised credential.
    I want to pass the credential in the following fields when I enter login ,I want to pass the values to SAP.
    I am using the following code:
    var oLayout = new sap.ui.commons.layout.AbsoluteLayout({width:"340px",height:"150px"});
    oLayout.addStyleClass("CustomStyle"); //Add some additional styling for the border
    var oLabel = new sap.ui.commons.Label({text:"User Name"});
    var oNameInput = new sap.ui.commons.TextField({width:"190px"});
    oLabel.setLabelFor(oNameInput);
    oLayout.addContent(oLabel, {right:"248px",top:"20px"});
    oLayout.addContent(oNameInput, {left:"110px",top:"20px"});
    oLabel = new sap.ui.commons.Label({text:"Password"});
    oPWInput = new sap.ui.commons.PasswordField({width:"190px"});
    oLabel.setLabelFor(oPWInput);
    oLayout.addContent(oLabel, {right:"248px",top:"62px"});
    oLayout.addContent(oPWInput, {left:"110px",top:"62px"});
    var oLoginButton = new sap.ui.commons.Button({text:"Login",  press :"login", width:"133px"});
    //oLoginButton.attachPress(login());
    oLayout.addContent(oLoginButton, {left:"110px",top:"104px"});
    // Attach the layout to the page
    oLayout.placeAt("content");
    </script>
      <script>
      login : function(oEvent) {
          jQuery.sap.require("sap.ui.model.odata.datajs");
          var serviceURI = "http://192.168.0.7:8000/sap/opu/odata/sap/YNEW_SRV/";
                    var username = sap.ui.getCore().getControl("oNameInput") .getValue();
                    var password = sap.ui.getCore().getControl("oPWInput") .getValue();
          var request = {
                    headers : {
                                      "X-Requested-With" : "XMLHttpRequest",
                                       "Content-Type" : "application/atom+xml",
                                       "DataServiceVersion" : "2.0",
                                       "X-CSRF-Token" : "Fetch"
                                                                           requestUri : serviceURI,
                                                                           method : "GET",
                                                                           user : username,
                                                                           password : password
                                                                   OData.request(request, function(data) {
                                                                           alert("success");
                                                                 }, function(err) {
                                                                           alert('Error Code:'+ err.response.statusCode);
      </script>
    Thank you Naveenraj

  • How to create a user using XML and specifying addional attributes that are objects

    I'm trying to create a user using XML and specifying some attributes that are objects and not sure how to do it. How would I set the DirectoryUserAcl to Public?
    Here's the xml file:
    <?xml version = '1.0' standalone = 'yes'?>
    <SimpleUser>
    <UserName>mike2</UserName>
    <Password>abc123</Password>
    <AdminEnabled>false</AdminEnabled>
    <HomeFolderRoot>/home</HomeFolderRoot>
    <HasContentQuota>false</HasContentQuota>
    <DirectoryUserAcl> ??? </DirectoryUserAcl>
    <DefaultAclBundleAcl> ??? </DefaultAclBundleAcl>
    <HomeFolderPolicyBundleAcl> ??? </HomeFolderPolicyBundleAcl>
    </SimpleUser>

    I figured out the answer:
    <?xml version = '1.0' standalone = 'yes'?>
    <SimpleUser>
    <UserName>mike2</UserName>
    <Password>abc123</Password>
    <AdminEnabled>false</AdminEnabled>
    <HomeFolderRoot>/home</HomeFolderRoot>
    <HasContentQuota>false</HasContentQuota>
    <DirectoryUserAcl classname="SystemAccessControlList" refType="name">Public</DirectoryUserAcl>
    </SimpleUser>
    null

  • How can we create info record using IDOC INFREC?

    Hi Friends,
    Can we create info record using IDOC INFREC. If Yes. How?
    Regards,
    Narendra

    Using IDOC INFREC & FM IDOC_INBOUND_SINGLE

  • Want To create Zip file  using java,And Unzip without Java Program

    I want to create a zip text file using java, I know Using ZipOutputStream , we can create a zip file, , But i want to open that zip file without java program. suppose i use ZipOutputStream , then zip file is created But for unZip also difftrent program require. We cant open that zip file without writing diff java program.
    Actually i have one text file of big size want to create zip file using java , and unzip simply without java program.Its Possible??
    Here is one answer But I want to open that file normal way(
    For Exp. using winzip we can create a zip file and also open simply)
    http://forum.java.sun.com/thread.jspa?threadID=5182691&tstart=0

    Thanks for your Reply,
    I m creating a zip file using this program, Zip file Created successfully But when im trying to open .zip file i m getting error like "Canot open a zip file, it does not appear to be valid Archive"
    import java.io.*;
    import java.util.zip.*;
    public class ZipFileCreation
         public static void main (String argv[])
         try {
         FileOutputStream fos = new FileOutputStream ( "c:/a.zip" );
         ZipOutputStream zip = new ZipOutputStream ( fos );
         zip.setLevel( 9 );
         zip.setMethod( ZipOutputStream.DEFLATED );
    //     get the element file we are going to add, using slashes in name.
         String elementName = "c:/kalpesh/GetSigRoleInfo092702828.txt";
         File elementFile = new File ( elementName );
    //     create the entry
         ZipEntry entry = new ZipEntry( elementName );
         entry.setTime( elementFile.lastModified() );
    //     read contents of file we are going to put in the zip
         int fileLength = (int)elementFile.length();
         System.out.println("fileLength = " +fileLength);
         FileInputStream fis = new FileInputStream ( elementFile );
         byte[] wholeFile = new byte [fileLength];
         int bytesRead = fis.read( wholeFile , 0 /* offset */ , fileLength );
    //     checking bytesRead not shown.
         fis.close();
    //     no need to setCRC, or setSize as they are computed automatically.
         zip.putNextEntry( entry );
    //     write the contents into the zip element
         zip.write( wholeFile , 0, fileLength );
         zip.closeEntry(); System.out.println("Completed");
    //     close the entire zip
         catch(Exception e) {
    e.printStackTrace();
    }

  • Wich one best for Audio Recording using cubase and pro tools? MBP md102 or MBP md103? i often using a lot of VST

    wich one the best for Audio Recording using cubase and pro tools? MBP md102 or MBP md103? i often using a lot of VST too

    Well, I've been trying this for a while. By my calculations, at this rate, installing all the applications one by one and trying to restore all the data manually will take me about six years. I would finished just in time for the Tokyo 2020 Olympics.
    The main problem is, I don't know where all the bodies are buried. Just one example, I'm using Cornerstone for an svn client. I have working copies of multiple repositories on my computer. I really don't want to set them all up again, and I can't figure out where the Cornerstone preferences and all settings are stored. I couldn't find them in the Library anywhere.
    And that's just one case.
    I haven't done much with my MacBook Pro yet, I think in retrospect the easiest course of action is to reinstall OS X as though it were new MacBook Pro, start from scratch, and use my Time Machine backup with the migration assistant and go from there.
    And that's what I'm doing right now. I'm in the middle of reinstalling OS X.
    Afterwords I'll use a clean app uninstaller application to get rid of all the applications that I'm not using. And I'll just hack away at directories that I know I haven't looked at for years, with the confidence that I have a backup both in Time Machine and in CCC and also on my iMac. That's three backups.
    I would rather start out "light", but I can see it's just going to take forever and a day to get it done. Anyway, fortunately nothing is carved in stone, and I can always try again if I want to. But dealing with all the documents and all the applications one by one separately was just obviously going to take too much time.
    I'll report back on my results. And I appreciate your suggestion.
    Doug

  • RDE: Using an external ODATA service

    Hi,
    I'm trying to use an external oData service in a RDE "SAP Fiori Start application" Project.
    I've added the service to the HCP Destinations page as well as giving it the additional property "RDEEnabled=true" but it still doesn't appear in the RDE: Data Connection screen in the catalog.
    Any tips?
    Thanks,
    Dick

    Hello Richard,
    then this environment would have to provide an OData service /IWFND/CATALOGSERVICE with a collection ServiceCollection that has the same structure as the one provided by NetWeaver Gateway, because this is what the River RDE "SAP Fiori Start application" template uses to find applicable services.
    Best regards
    Frank

  • SAPUI5 and oData: Task completion problem

    Dear all,
    We've got a BPM process which is based on WDJ approval screens.
    Now I would like to replace WDJ by SAPUI5.
    I've succeeded to display some task input data in my SAPUI5 application:
    oPanel.bindElement("/InputData('"+taskId+"')", {expand:"ContextTypeINPUT/Context/Requester"});
    var oInputFirstName = new sap.ui.commons.TextField("textFirstName", {
        value : "{ContextTypeINPUT/Context/Requester/FirstName}"
    var oInputLastName = new sap.ui.commons.TextField("textLastName", {
        value : "{ContextTypeINPUT/Context/Requester/LastName}"
    But I can't manage to complete the task.
    For a simpler example that worked for me.
    It seems that I don't fill the output data correctly.
    Normally I should fill the Status (fields Action, ChangedBy, ChangedOn and Details) and the Request->ReferenceNumber:
    Please find attached the XSD of the task.
    I tried the following:
    var outputData = {};
    var status = odataModel.getProperty("/InputData('" + taskId "') " +
                      "/ContextTypeINPUT/Context/Status");
    status.Action = "approved";
    status.ChangedBy = "TEST";
    status.ChangedOn = "2014-07-29";
    outputData.HandleRequestCompleteEventTypeOUTPUT = status;
    // send request to BPM Task Data OData service to complete
    odataModel.create("/OutputData", outputData, null,
        function sendData_OnSuccess(oData, response) {
            alert("Task has been completed successfully");
        function sendData_OnError(oError) {
            alert("Task could not be completed");
    But it stops when executing the second statement (var status = odataModel.getProperty("/InputData('" + taskId "')...).
    I would really appreciate if you could help me!
    Thanks in advance.
    Best regards,
    Thorsten.
    P.S.: Our system is running NW 7.40 SP07.

    Hi again,
    As most of the time, I had to solve my issues published on SCN on my own
    My mistake was, that I've retrieved the 'handleRequestType' of my OutputData from the InputData.
    It seems that having all subtypes in the structure causes trouble, because I fill only to fill two fields.
    In the end I build OutputData myself and it works now...
    So in fact it's possible to create an proper OutputData without a binding of InputData.
    controller.js
    completeTask : function() {
    // Get TaskID and data model
    var taskId = getValueOfURLParameter("taskId");
    var odataModel = this.getView().getModel();
    // Create OutputData
    var outputData = {};
    // Create all needed subtypes
    var handleRequestType = {};
    var status = {};
    var request = {};
    // Fill values for fields that need to be sent
    status.ChangedBy = sap.ui.getCore().byId("inputStatus").getValue();
    request.ReferenceNumber = sap.ui.getCore().byId("inputRequest").getValue();
    // Build OutputData
    handleRequestType.Status = status;
    handleRequestType.Request = request;
    outputData.HandleRequestType = handleRequestType;
    // Complete task with built OutputData
    odataModel.create( "/OutputData", outputData, null,
         function sendData_OnSuccess(oData, response) {
              alert("Task has been completed successfully");
         function sendData_OnError(oError) {
              alert("Task could not be completed");
    view.js
    createContent : function(oController) {
    // Text input fields which will feed the OutputData
    var oInputStatus = new sap.ui.commons.TextField("inputStatus");
    var oInputRequest = new sap.ui.commons.TextField("inputRequest");
    // Button to complete the task
    var oButton = new sap.ui.commons.Button( {
         text : "Complete",
         style : sap.ui.commons.ButtonStyle.Accept,
         press : (function() {
         oController.completeTask();
    Just make sure that you explore your OuputData before via a tool like Postman (Chrome Addon).
    First do a GET request:
    http://<host>:<port>/bpmodata/taskdata.svc/<taskID>/OutputData
    Then look for a "/XYZ" part in the response.
    In my case it looked like that:
    <link href="OutputData('<TaskID>')" rel="edit" title="OutputData"/>
    <link href="OutputData('<TaskID>')/HandleRequestType" .../>
    So I could go on to explore my output data, by sending the following GET request in Postman:
    http://<host>:<port>/bpmodata/taskdata.svc/<taskID>/OutputData?$expand=HandleRequestType
    Now you have to repeat that until you find the data type that you want manipulate.
    If you found out how your OutputData looks like, you can build it easily on your own (see my controller.js).
    Maybe I'll write my first blog about it

  • Restricting User from creating new records using when-validate-record

    Hi,
    I have a requirement for which I have to restrict he user from creating a record in the Supplier Master form if the suppliier type is 'Affiliate Supplier'.
    I have done the following setups
    Seq 10
    Description Restricting user from creating Affiliate records
    Level Function
    Enabled Yes
    Condition:
    Trigger Event WHEN-VALIDATE-RECORD
    Trigger object VNDR
    Condition "${item.VNDR.VENDOR_TYPE_DISP_MIR.value} is NOT NULL
    and
    ${item.VNDR.VENDOR_TYPE_DISP_MIR.value} LIKE 'Affiliate%'
    Processing Mode BOTH
    Context
    Level User
    Value User Name
    Action Sequence 1
    Type Message
    Action Description Saving Affiliate record
    Language ALL
    Message Type Show
    Message Text You Cannot Create Affiliate records Here
    Action Sequence 2
    Type Builtin
    Action Description Stop Proceesing
    Language ALL
    Action Enabled Yes
    Builtin Type RAISE FORM_TRIGGER_FAILURE;
    This is working good on one instance but when I moved it to another instance
    when I query the form and try to navigate to the bank accounts tab of the form which is based on a differnt block i.e VNDR_USES block, the when-validate-record trigger fires there also and stops the processing.
    Any suggestions on this would be higly appriciated.
    Thanks in Advance.

    Hi Srini,
    Yes, it does work...but in a Form Session if i Create more then one Item, in some cases it fires for the first records and not sleeps for the second.
    Sometimes it doesn't give any response.
    Appreciated if you divert to the link to check the Pacthes for 11.5.10 on Form Personalization.
    Please share any ideas/example if yiou have to achieve the below requirement.
    Requirement:
    Once New record is created , a Custom Procedure should be invoked.
    with out closing Form i am able to create n number of Items, so for every Item it should invoke Custom PLSQL Code on Save.
    Let me know if i can achieve the same in Custom.pll .....as i can use either of Options.(Form Personalization/Custom.pll)
    Thanks & regards,
    Edited by: user632004 on Mar 16, 2010 7:50 PM
    Edited by: user632004 on Mar 16, 2010 8:09 PM

  • How to create multiple records using ADF

    Currently working on my first ADF BC and UIX project, and I basically want to create multiple records after a user makes a choice on the screen. I would like to know at what layer should this functionality be implemented?
    Would this be more at the Struts/Controller level, where I have a java class to perform the creation as part of a data action? I ask because, I am not sure if this is feasible at the ADF BC level (View objects and Entity Objects) via some sort of customization, and i am new to the different possibilies avail as part of the ADF framework
    Regards
    Anora
    (Jdeveloper 10.1.2.1 build 1913, Oracle DB 10.1.2)

    I'd put it into the application module. You then can call the method from the controller layer or from an other application module. This way you put it into the business logic, which helps if you ever decide to use a different client approach (like swing).

  • Call the webdynpro appl while creating one record using itemDetail iView

    Dear Expert,
    I have one scenario where in the user want to create one record in MDM table using itemDetai iView. When the user clicks on one custom button in this itemDetais iView say validate one webdynpro applicatio should be called and this applicaiton should  validate the user input depending on business requirement.
    Thanks and Regards,
    M.D.Sahu

    thanks John for your valuable input.
    In my requirement user don't want to touch the MDM repository or don't want the serve side eventing. After giving the user input in Item detail Iview the user will click on Validate button and one WDJ applicaiotn should be called to validate the users input. Please guide me in achieving this result.
    Thanks in advance.
    Regards,
    M.D.Sahu

  • How to create an InputSelect using ADF and JSP

    I looking for some docs/instructions on creating "an InputSelect using ADF with JSP".
    Thanks,
    BG...

    Ok here are the Steps
    1) Open the JSP editor for the page in Question.
    2) In the Data Control palette select the item that you want to become the poplist and change the "Drop As" poplist to "Single Select List"
    3) Drag the field into the page. You'll get an empty poplist which implements the <html:select> and <html:optionsCollection> tags.
    4) With the JSP editor still open click on the "UI Model" sub-tab in the Structure pane
    5) Select the field you've just dragged in - then right click to get the context menu and choose "edit"
    6) Change the List Binding Mode poplist to "LOV Mode"
    You're then taken into a couple of screens where you can select the Source VO for the poplist, and the destination dataset, along with the thing you want for the Label and the Value.

  • How to creating pdf documents using c# and Adobe SDK

    I downloaded Adobe SDK and go through the samples given in sdk. But i couldn't find any sample code how to create PDF file using C# code.
    Please, help me with this.
    Thanks.

    For desktop-based solutions, look at the Adobe Acrobat SDK which enables development around Acrobat itself. Or if you wish a stand-alone solution (for either desktop or server), we offer the Adobe PDFLibrary, which is the same technology used by all of Adobe's applications.
    For the server, we have our LiveCycle products including LC Generator.
    Leonard

  • How to create store procedure using cursor, and looping condition with exce

    Hi,
    I am new in pl/sql development , please help me for follwoing
    1. I have select query by joining few tables which returns lets say 100 records.
    2. I want to insert records into another table(lets say table name is tbl_sale).
    3. If first record is inserted into tbl_sale,and for next record if value is same as first then update into tbl_sale else
    insert new row
    4. I want to achieve this using store procedure.
    Please help me how to do looping,how to use cursor and all other necessary thing to achieve this.

    DECLARE
       b   NUMBER;
    BEGIN
       UPDATE tbl_sale
          SET a = b
        WHERE a = 1;
       IF SQL%ROWCOUNT = 0
       THEN
          INSERT INTO tbl_sale
                      (a
               VALUES (b
       END IF;
    END;note : handle exceptions where ever needed
    Regards,
    friend
    Edited by: most wanted!!!! on Mar 18, 2013 12:06 AM

Maybe you are looking for

  • Decoding IPS logs

    Hi, Need guidance on decoding IPS syslogs(alerts). We monitor IPS logs and there we could see some decoded messages appearing for cid.context.cid:fromTarget, cid.context.cid.fromAttacket, cid.triggerPacket fields. Would like to understand what these

  • Error in report "8.2 ORacle Essbase- Source Blending Page"

    Hi, I got an error in the report in "8.2 ORacle Essbase- Source Blending Page" after i deployed sample core and aslo configured with hyperion Essbase cubes related to this dashboard page. The main issue i was struggling is i have 2 more working insta

  • Logic 9 is quitting when entering serial code...any ideas?

    Hi, Logic 9 is "unexpectedly quitting" when entering serial code for the first time...any ideas?? I'm running OSX 10.6.8 on iMac Many thanks

  • Training project is auto-advancing instead of being student-driven.

    Using Captivate 5.0, I have developed some training simulations. I have set the click boxes with the following properties: So in other words, the user should be in control of advancing the slides, once they've clicked the right spot! The projects are

  • Reg  comparison of two  internal tables

    hi friends, please help me solving this. there are two internal tables t_zvs38 and t_value 1.t_value like seahlpres 2.t_zvs38 like zvs38. values in t_value will be like this. first line wil contain zmdtype(mandatory document) and second line will con