Quantcast
Channel: SAP Business One SDK
Viewing all 49 articles
Browse latest View live

SAP Business One Service Layer, what's new in version 9.2 PL03?

$
0
0

Hi,

 

There are some interesting new features available in SAP Business One Service Layer version for SAP HANA 9.2 PL03 version that I will like to shortly highlight in this blog.

 

  1. Service Layer supports grouping on oData query
    Grouping behavior is triggered using the query option apply and the groupby keyword. This keyword specifies the grouping properties, a comma-separated list of one or more single-valued property paths that is enclosed in parentheses.

    For example, to group the orders by CardCode, DocEntry, send a request like:
         
        GET /b1s/v1/Orders?$apply=groupby((CardCode, DocEntry))
         
        GET /b1s/v1/Orders?$apply=groupby((Orders/CardCode, Orders/DocEntry))

  2. Service Layer supports simple aggregation on oData query
    Aggregation behavior is triggered using the query option $apply. Any aggregate expression that specifies an aggregation method MUST define an alias for the resulting aggregated value. Aggregate expressions define the alias using the as keyword, followed by a SimpleIdentifier. The alias will introduce a dynamic property in the aggregated result set. The introduced dynamic property is added to the type containing the original expression.
    Currently, the supported aggregation methods include sum, avg, min, max, count and distinctcount.

    For example, to sum the DocRate of the Orders, send a request like:
         GET /b1s/v1/Orders?$apply=aggregate(DocRate with sum as TotalDocRate)

    Of course many other query options are available already in Service Layer ($filter, $select, $orderby, $top, $skip,...). Please check Service Layer documentation for more details.

  3. Attachment manipulation
    You can create attachments via Service Layer, source can be Linux or Windows machine. You can also update and download attachments via Service Layer.


For more details on these new features please have a look to the User Manual document always available in your SAP Business One Service Layer installation:

https://your_hana_server:50000/


SAP Business One Service Layer version for SAP HANA 9.2 PL03 is already available for download, don't wait for testing all these new features!


Regards,

Trinidad.


Leaving the SAP World

$
0
0

Well, my tenure in the SAP world is just about up. I'll be doing work in the future that has nothing to do with SAP. It's been a crazy 9+ months, and I think that I learned a lot along the way. I hope that I also helped some others along the way in the same way that I'd been helped. I'd like to take a moment to thank everyone that's helped me on this wild ride going from not knowing that SAP even exists, to becoming a moderately proficient SAP programmer:

 

 

I'd also like to thank my coworkers at ASAP, TL and TS. They've been immense help in my growth as a programmer. It's been fun.

 

Final words: We Need Better Documentation!

SAP Business One Service Layer - SSO with UI API

$
0
0

As of SAP Business One 9.2, version for SAP HANA, besides the normal login, Service Layer supports SSO with SAP Business One SDK UI API.

 

In order to use Service Layer SSO you just have to connect as usual to the UI API and use the UI API SBO_Application object to get the Service Layer B1SESSION and ROUTEID cookies.


Here you have a very simple sample getting Service Layer context from UI API:

 

           string serviceLayerAddress = "https://hanaserver:50000/b1s/v1";           string sConnectionContext = SBO_Application.Company.GetServiceLayerConnectionContext(serviceLayerAddress);

         

And a method getting Service Layer context and using it to call Service Layer via HttpWebRequest class:

 

       private int PlayServiceLayer()        {            string serviceLayerAddress = "https://hanaserver:50000/b1s/v1";            string sConnectionContext = null;            //Step 1: Get a session cookie from service layer            try            {                  sConnectionContext = SBO_Application.Company.GetServiceLayerConnectionContext(serviceLayerAddress);            }            catch (System.Exception ex)            {                  continue;            }                   if (sConnectionContext == null)            {                SBO_Application.MessageBox("Get service layer connection context error", 1, "Err", "", "");                return -1;            }            //Step 2: Send requests with session cookie            try            {                var request = WebRequest.Create(serviceLayerAddress + "/Items?$top=1") as HttpWebRequest;                request.AllowAutoRedirect = false;                request.Timeout = 30 * 1000;                request.ServicePoint.Expect100Continue = false;                request.CookieContainer = new CookieContainer();                ServicePointManager.ServerCertificateValidationCallback += BypassSslCallback;                string[] cookieItems = sConnectionContext.Split(';');                foreach (var cookieItem in cookieItems)                {                    string[] parts = cookieItem.Split('=');                    if (parts.Length == 2)                    {                        request.CookieContainer.Add(request.RequestUri, new Cookie(parts[0].Trim(), parts[1].Trim()));                    }                }                HttpWebResponse response = request.GetResponse() as HttpWebResponse;                if (response.StatusCode != HttpStatusCode.OK)                {                    SBO_Application.MessageBox("Get item error", 1, "Err", "", "");                    return -1;                }                string responseContent = null;                using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))                {                    responseContent = reader.ReadToEnd();                }                SBO_Application.MessageBox(responseContent, 1, "Ok", "", "");            }            catch (System.Exception ex)            {                SBO_Application.MessageBox(ex.ToString(), 1, "Err", "", "");            }            return 0;        }

 

Hope it helps

Trinidad.

How to build Fiori apps for SAP Business One, version for SAP HANA - part3

$
0
0

This blog explains the part3 of how to build B1 Fiori apps running on top of SAP HANA, with the help of the WEB IDE for HCP.

 

Please follow part1&2 for basic understnading of Fiori:

 

In order to make it simpler for you, I have attahced in this blog a ppt presenation here B1_Fiori_Presentation where it explain all details about how to build an B1 Fiori app on HANA in two different backend connectivity methods:



  1. using the HANA XS based OData service - reading purpose.
  2. using the B1 Service Layer on HANA - reading and posting purposes.

 

I have attached two samples here Samples, and and as well inside the ppt presenation so you can import them in your HANA System and try them as per instructions provided in the ppt;

  1. Sample_A
    • This is an B1 Fioriappthatshows Business Partners details.
    • Itcanrun on HCP andaswell on HANA Platfrom "On-Premise“.
    • Itisbased on an ODataservice, which is onlyforreadingpurpose.sample1.png
  2. Sample_B
    • This is an B1 FioriappthatshowsSales Orders details.
    • Itcanrunon HANA Platfrom "On-Premise“.
    • Itisbased on the B1 Service Layer on HANA.
    • Itshowssalesorderdetails, and allowtocancelorclose a specificopenedsalesorder via the B1 Service Layer on HANA. sample2.png

Guidelines for Modifying SAP Business One Data

$
0
0

We can always see customers/partners using several direct updates in some form of Add-Ons/TransactionNotification. Below are some guidelines:

Question1: Is it permit to INSERT/UPDATE/DELETE on UDTs through HANA Studio, Coding, B1if?
Answer: Direct updates not allowed. It is ok for UDTs of type [no object] only.

Question2: Is it permit to INSERT/UPDATE/DELETE on UDFs from System table through HANA Studio, Coding, B1if?
Answer: Not allowed in Business One system tables.

Question3: Is it allowed to CREATE/ALTER/DROP in SAP Business One Database but not as UDTs?
Answer: It is not allowed to create tables in Business One other than via SDK UDTs.

Examples:

Question1: Is it allowed to do: UPDATE OPOR SET Printed = 'Y'?
Answer: No


Question2: Is it allowed to do: UPDATE OPOR SET U_DSIC_ParentDoc = '1234'?
Answer: No


Question3: Is it allowed to do: INSERT INTO [@DS_TESTUDT]?

Answer: No(If UDT is registered for UDO]
             Yes for UDTs of type [no object] only.

These rules are described in the B1 certification page:http://scn.sap.com/docs/DOC-8590 and specifically the Test Plan document:http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/206767e1-8f64-2c10-49ba-aeacbfdd528c?quicklink=index&overridelayout=true section 3.4 Modifying SAP Business One Data.

 

The same applies while doing all these modifications in SBO_SP_PostTransactionNotice andSBO_SP_TransactionNotification. Refer to SAP Note 1320484 for the same.

"Project Management" object is exposed from SAP Business One Version 9.2 PL03

$
0
0

"Project Management" object is exposed as a Service Type Object from SAP Business One Version 9.2 PL03. It is yet to be implemented in DTW.


You can refer to below sample:


1. Add a Project:


int absEntryOfCreatedProject = -1;

 

 

            SAPbobsCOM.CompanyService oCompServ = null;

            SAPbobsCOM.ProjectManagementService pmgService = null;

 

 

            try

            {

                // Company service

                oCompServ = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();

 

 

                // ProjectManagementService

                pmgService = (SAPbobsCOM.ProjectManagementService)oCompServ.GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectManagementService);

 

 

                // Add project

                SAPbobsCOM.PM_ProjectDocumentData project = (SAPbobsCOM.PM_ProjectDocumentData)pmgService.GetDataInterface(SAPbobsCOM.ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentData);

                project.ProjectName = "ProjectByDI_01";

                project.Owner = 1;

                project.StartDate = new DateTime(2016, 2, 1);

                project.DueDate = new DateTime(2016, 11, 30);

                project.ClosingDate = new DateTime(2016, 12, 31);

                project.ProjectType = SAPbobsCOM.ProjectTypeEnum.pt_External;

                project.BusinessPartner = "C20000";              

                project.ContactPerson = 2;

                project.Territory = 1;

                project.SalesEmployee = 5;

                project.AllowSubprojects = SAPbobsCOM.BoYesNoEnum.tYES;

                project.ProjectStatus = SAPbobsCOM.ProjectStatusTypeEnum.pst_Started;

                project.FinancialProject = "PRJ01";

                project.RiskLevel = SAPbobsCOM.RiskLevelTypeEnum.rlt_High;

                project.Industry = 1;

                project.Reason = "Test comment";

                project.AttachmentEntry = 1;

 

 

                SAPbobsCOM.PM_ProjectDocumentParams projectParam = pmgService.AddProject(project);

                absEntryOfCreatedProject = projectParam.AbsEntry;

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

            finally

            {

                if (pmgService != null)

                {

                    MessageBox.Show(absEntryOfCreatedProject.ToString());

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pmgService);

                }

            }

 

 

2. Add Document to Stages:


SAPbobsCOM.CompanyService oCompServ = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();

            SAPbobsCOM.ProjectManagementService pmgService = (SAPbobsCOM.ProjectManagementService)oCompServ.GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectManagementService);

 

 

            SAPbobsCOM.PM_ProjectDocumentParams projectToUpdateParam = pmgService.GetDataInterface(SAPbobsCOM.ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentParams);

 

 

            try

            {

              

                projectToUpdateParam.AbsEntry = 1;

                SAPbobsCOM.PM_ProjectDocumentData project = pmgService.GetProject(projectToUpdateParam);

 

 

                // add stage to the project

                SAPbobsCOM.PM_StagesCollection stagesCollection = project.PM_StagesCollection;

                SAPbobsCOM.PM_StageData stage = stagesCollection.Add();

                stage.StageType = 1;

                stage.StartDate = DateTime.Now;

                stage.CloseDate = stage.StartDate.AddDays(30);

                stage.Task = 1;

                stage.Description = "StageWithDocByDI_01";

                stage.ExpectedCosts = 150;

                stage.PercentualCompletness = 7;

                stage.IsFinished = SAPbobsCOM.BoYesNoEnum.tNO;

                stage.StageOwner = 5;

                stage.AttachmentEntry = 1;

 

 

                stage = stagesCollection.Add();

                stage.StageType = 2;

                stage.StartDate = DateTime.Now.AddMonths(1);

                stage.CloseDate = stage.StartDate.AddDays(30);

                stage.Task = 2;

                stage.Description = "StageWithDocByDI_02";

                stage.ExpectedCosts = 250;

                stage.PercentualCompletness = 8;

                stage.IsFinished = SAPbobsCOM.BoYesNoEnum.tNO;

                stage.StageOwner = 5;

                stage.DependsOnStage1 = 1;

                stage.StageDependency1Type = SAPbobsCOM.StageDepTypeEnum.sdt_Project;

                stage.DependsOnStageID1 = 1;

 

 

                // add document to the stage

                SAPbobsCOM.PM_DocumentsCollection documentsCollection = project.PM_DocumentsCollection;

                SAPbobsCOM.PM_DocumentData document = documentsCollection.Add();

                document.StageID = 1;

                document.DocType = SAPbobsCOM.PMDocumentTypeEnum.pmdt_APCreditMemo;

                document.DocEntry = 7;

 

 

                pmgService.UpdateProject(project);

                MessageBox.Show("OK");

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

            finally

            {

                if (pmgService != null)

                {

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pmgService);

                }

            }

SAP Business One Service Layer - TypeScript autogeneration

$
0
0

In a previous blog SAP Business One Service Layer HANA XS sample I shared with you a sample we have developed in HANA XS (Java Script) connecting to SAP Business One Service Layer. In this blog I’ll like to give you some details about the TypeScript auto generation source code that was used to create the client side proxy class “B1SLReference.js”.

 

The auto generation source code includes two C# .NET solutions:

 

  1. oDataClassesGenerator – Generates a TypeScript or Java Script file out of the SAP Business One Service Layer metadata file.

  2. TypeScript – .NET application using the TypeScript autogenerated file from oDataClassesGenerator.

 

 

How to get this application working in your environment

 

oDataClassesGenerator .NET solution

  • Extract and unzip the Autogeneration.zip file and open the oDataClassesGenerator solution.
  • Run the solution:
    • choose if you want to generate a Java Script or a Type Script file
    • select your xml file containing the Service Layer metadata.
      • To generate your Service Layer metadata establish a connection to Service Layer via Postman for example and retrieve the metadata file (after a successful login, use the metadata link to ask for the Service Layer full metadata, save the response as an xml file). For more details on metadata file please check the User Guide at: https://yourhanaserver:50000.
      • Read carefully the “ModifsMetadata.txt” file (inside the Autogeneration.zip, ODataClassesGenerator folder). Some small changes are required to be applied to the metadata original file in order to have the classes auto generated by this application.

 

TypeScript .NET solution

This solution provides a sample showing how simple it is to use TypeScript language and get JavaScript code as auto generated output.

 

Important notions

TypeScript

The oDataClassesGenerator .NET solution has the option to generate TypeScript code. TypeScript is a typed superset of JavaScript that compiles to clean, simple JavaScript code which runs on any browser, in Node.js, or in any JavaScript engine that supports ECMAScript 3 (or newer). 
You can find details about TypeScript at:
https://www.typescriptlang.org/

 

Download

You can download the source code of the full sample containing the different projects from here.

SAP Business One Service Layer HANA XS sample

$
0
0

I’ll like to share with you a sample we have developed in HANA XS (Java Script) connecting to SAP Business One Service Layer.

 

This sample uses a proxy class in order not to directly call SAP Business One Service Layer from the client side but from the server side. This option allows you to encapsulate your own business logic on the server side.

 

The sample provided contains a HANA XS application called ServiceLayerApp. This basic application shows you how to perform basic operations like Add/Update/Delete on Business Partners and Sales Orders entities via Service Layer.

 

 

How to get this application working in your environment

 

ServiceLayerApp HANA XS application

  • Extract from the zip file the source code corresponding to the ServiceLayerApp: SL_APP-SA.tgz.
    This package is a HANA XS Delivery Unit that you can directly import into your HANA development environment (via HANA Studio File -> Import Delivery Unit or HANA Web Workbench life cycle management tools).  As this delivery unit has been generated on a HANA SPS11 system, you require at least HANA SPS11 version to be able to import it.
  • Update the destination file and create the required trusted store for Service layer as explained in point 2 here below (Important notions section).
  • Run directly the project from the index.html main page

 

Note: The auto generated B1SLReference.js file has been generated based on SAP Business One 9.1 PL03 version for SAP HANA and will then maybe not contain the same entities your current Service Layer is exposing. Also your own UDOs, UDTs, UDFs will not be part of this reference class unless you regenerate this class with the oDataClassesGenerator .NET solution. Please check point 3 here below (Important notions section) for more details.

 

 

Important notions

In this sample several notions are consumed in order to structure the calls to Service Layer, please review them in advance:

  1. The HANA XS app client side doesn’t connect directly to Service Layer but calls a proxy server side JavaScript class (xsjs/B1SLProxy.xsjs) that filters the requests coming from the client side and calls the Service Layer. This proxy allows you to execute some extra server side checks and calculations before calling Service Layer.
  2. The server side of the application is calling SAP Business One Service Layer using HANA XS libraries allowing to directly call Service Layer.
    Check the following blog I published some time ago explaining how to setup HANA XS in order to be able to call SAP Business One Service Layer https oData interface:
    How to call SAP Business One Service Layer from HANA XS
  3. The “B1SLReference.js” class has been auto generated via TypeScript, please check the blog SAP Business One Service Layer - TypeScript autogenerationfor more details.

 

Download

You can download the source code of the full sample containing different projects from here.


Script Engine - new Service Layer feature!

$
0
0

With SAP Business One 9.2 PL04, version for SAP HANA the Service Layer has been enhanced with a new feature called Script Engine!

 

This new feature allows partners and customers to develop their own script extensions that can be embeded and executed by Service Layer. The script engine feature give a powerfull opportunity to build complex transactions in a single oData request being handled by the Service Layer Script Engine.

 

Main features of the Service Layer Script Engine are:

  • Embedded JavaScript parsing engine into Service Layer (Google Chrome V8)
  • Provided JavaScript SDK to develop extension applications.
  • Exposed SAP Business One CRUD API.
  • Exposed SAP Business One transaction API.
  • Exposed HTTP request and response API. Benefits
  • Allow partners to implement server-side JavaScript extensions hosted by Service Layer (UDOs and Business Objects customization and validation,…).
  • Share server-side customization among different applications (client and server side) on top of Service Layer.
  • Allow global transactions grouping several operations

 

Check the following blog B1 Service Layer:  Develop extensions by embedding JavaScript as well as the SAP Note 2343691 - Service Layer supports script engine (S-user required) for more details.

Detailed documentation of this Service Layer feature and all available features is of course available directly in your HANA server at https://hana-server:50000.

 

Hope you will enjoy this new great feature!

Trinidad.

Viewing all 49 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>