Skip to Content

Some weeks ago I published a blog explaining how to consume Service Layer oData services from .NET via WC, please read it as introduction to this blog and sample:

How to consume Service Layer oData services from .NET via WCF

In this new blog I want to announce that we published a .NET sample code connecting to SAP Business One version for SAP HANA Service Layer and doing some operations like:

– Login/Logout

– Retreive the list of Business Partners and Items

– Add a Sales Order Document

– Update a Sales Order Document

– Get a specific Sales Order Document

– Close a Sales Order Document

– Get information via query filters to reduce the amount of data to be retrieved (for example not all fields but only CardCode, CardName fields required but the UI) to improve performances

– Send several queries via Batch in only one request

– Use pagination to retrieve all Orders page by page (user will not be able to see all pages at once and performances will be better if you retrieve page by page).

With this sample you will see how easy is to consume Service Layer Entities (what we are using to call objects in COM interface) and Actions (somehow equivalent to the DI API Services) by getting directly your hands in real .NET C# code.

Please use our standard SDK forum for questions/remarks on the SAP Business One version for SAP HANA Service Layer.

DOWNLOAD IT FROM HERE

Enjoy it!

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. Sun David

    Hi, i am using service layer to add sales order documnet from an addon program.

    and now i got some problem.so i want to refer to your sample code.

    But i can not open  the download link . can you send me a copy. David.Sun@sapsoft.net .

    Thank you very much,

    (0) 
    1. Maria Trinidad MARTINEZ GEA Post author

      Hi Jhonmar,

      The Service Layer metadata generates entitites for each one of your UDTs and UDOs. Please check the generated objects in WCF and verify the corresponding objects have been generated for each one of your UDTs and UDOs.

      Regards,

      Trinidad.

      (0) 
  2. Deepak Salhotra

    I have been facing same challenge as mentioned in the original post. I have made all recommended changes in “b1s.conf” file & also restarted the service but still I am not able to have service reference in my application. Getting below mentioned error:

    Metadata contains a reference that cannot be resolved: ‘https://hanaaisi2:50000/b1s/v1‘.

    The HTTP request is unauthorized with client authentication scheme ‘Anonymous’. The authentication header received from the server was ”.

    The remote server returned an error: (401) Unauthorized.

    (0) 
  3. Irina Regne

    Hi,

    I used a ServiceLayer in my C# Add-on

    I have a problem with Cyrillic symbols.

    I try to this query:

    currentServiceContainer.ServiceCalls.Where(cursor => cursor.CustomerCode.Equals("Абвгде")).ToArray();

    And I have an error:

    “{…\”message\”…: \”Query string error – no matched single quote is found\”…”

    /wp-content/uploads/2016/05/1111_957680.jpg

    Please, help me

    Thanks,

    Irina

    (0) 
  4. Felipe Loyola

    Hi

    This client have 13 databases on 3 HANA servers

    Ramdomly the conexion failed at least one database.

    System.Data.Services.Client.DataServiceQueryException: Error al procesar esta solicitud. —> System.Data.Services.Client.DataServiceClientException: {
    “error” : {
    “code” : -111,
    “message” : {
    “lang” : “en-us”,
    value” : “Unable to access SBO-Common database”
    }
    }
    }

    System.Data.Services.Client.DataServiceQueryException: Error al procesar esta solicitud. —> System.Data.Services.Client.DataServiceClientException: {
    “error” : {
    “code” : -1,
    “message” : {
    “lang” : “en-us”,
             “value” : “Unknown error”
    }
    }
    }

    Best regards

    (0) 
    1. Maria Trinidad MARTINEZ GEA Post author

      Hi Jose,

      Yes, if you look at the metadata file you will see UserObjects object is available and works the same as for the DI API.
      As soon as a UDF is added to a B1 object the corresponding properties will be available on Service Layer.

      Regards,
      Trinidad.

      (0) 
      1. José Amaya

        Hello Maria,

        Great contribution you have here, unfortunately I couldn’t make it work, it gives me this error after login in and retrieving initial data

        {
           "error" : {
              "code" : -1001,
              "message" : {
                 "lang" : "en-us",
                 "value" : "Authorization header not found"
              }
           }
        }

         

        Any idea what it might be? Hope you can put me in the right direction here

         

        Best Regards,

        Jose

        (0) 

Leave a Reply