简体   繁体   English

从客户端javascript发送数据SAP Fiori启动板webapp / SAPUI5 webapp

[英]Sending data SAP Fiori launchpad webapp/SAPUI5 webapp from client side javascript

This is a general question I have as I am exploring the world of automating some tasks in my workplace. 这是我在探索工作场所中某些任务的自动化世界时遇到的一个普遍问题。

We have a portal/launchpad environment on our businesses website which has apps shown as tiles. 我们的企业网站上有一个门户/启动板环境,其中的应用程序显示为图块。

One of these apps when opened has a homepage that has a bunch of search fields and selectors to interface with (I assume) SAP data. 这些应用程序之一在打开时具有一个主页,该主页具有一堆搜索字段和用于与(我假设)SAP数据交互的选择器。

Ultimately my goal is to be able to send a number to a specific search field on a client-side local webapp (just plain old HTML/jquery stuff) and execute a search for that number in the sapui webapp. 最终,我的目标是能够将数字发送到客户端本地Web应用程序上的特定搜索字段(只是普通的旧HTML / jquery内容),并在sapui Web应用程序中对该数字执行搜索。

I am getting to an competent level with javascript/HTML/CSS but am completely lost as to where to start with this type of issue as the MVC stuff is completely alien to me. 我对javascript / HTML / CSS的掌握水平提高了,但是完全不知道从哪里开始这类问题,因为MVC的东西对我来说完全陌生。

All my experience has been in creating completely client-side web apps with mostly interface with a local MS Access database. 我所有的经验都是在创建完全与本地MS Access数据库交互的完全客户端的Web应用程序。

Is what I am suggesting even possible? 我的建议甚至可能吗?

So far I can open the homepage by executing the following code that someone else in the organization used: 到目前为止,我可以通过执行组织中其他人使用的以下代码来打开主页:

window.open('https://fiori.mycompany.com/sap/bc/ui5_ui5/sap/z_cs_ch/index.html

Is it possible to add some form of string after a ?.... at the end of the url? 是否可以在网址末尾的?....之后添加某种形式的字符串?

Again I am completely new to this and looking at the development guides in sapui website isn't shedding any light on it either. 再次,我对此完全陌生,并且在sapui网站上查看开发指南也同样不失所涉。 Possibly because I don't really know exactly what I am looking for! 可能是因为我不太清楚自己在寻找什么!

Any help /guidance is greatly appreciated. 任何帮助/指导都将不胜感激。

EDIT: After comments below I can see the request sent to server is in the following format: 编辑:在下面的注释后,我可以看到发送到服务器的请求的格式如下:

Request GET /sap/opu/odata/sap/someotherlocation/SearchTerm('<variable to search for>')?$format=json HTTP/1.1

Am I right in thinking I could potentially send an ajax request to do something similar? 我是否认为我可能会发送ajax请求来执行类似操作? If so, how do I go about it? 如果是这样,我该怎么做?

Thanks again 再次感谢

There are possibilties to achieve that but i think it's not a real good solution, to fill fields in another web application and to trigger the search. 有实现此目标的可能性,但我认为这不是一个真正好的解决方案,只能在另一个Web应用程序中填写字段并触发搜索。

It would be better if you know the backend service which is used by this Fiori App, and to integrate directly the service. 如果您知道此Fiori App使用的后端服务并直接集成该服务,那就更好了。 If it's an Fiori App i might be an OData /REST Service. 如果是Fiori应用程序,则我可能是OData / REST服务。 Odata/REST Service also can be called by HTML/jquery JavaScript stuff too. HTML / jquery JavaScript也可以调用Odata / REST服务。

In order to determine the Service URL and the payload which is used by the web app with the search field, just use Chrome Debugger Tools (or other Browser Debug Tools) and check under Network which server address and which payload parameters are sent to the server, when you trigger the search manually. 为了确定Web应用程序在搜索字段中使用的服务URL和有效负载,只需使用Chrome调试器工具(或其他浏览器调试工具),然后在“网络”下检查将哪个服务器地址和哪些有效负载参数发送到服务器,当您手动触发搜索时。 Hope that helps you little bit. 希望对您有所帮助。

In the whole Fiori concept, it is definitely possible to have applications to call other applications and to get them to open up exactly at the point the user expects it. 在整个Fiori概念中,绝对可以让应用程序调用其他应用程序,并使其完全在用户期望的位置打开。 Eg from a order click on a product to be brought to the material master, and have the material master app exactly show the product the user clicked on. 例如,从订单中单击要带到物料主数据的产品,然后让物料主数据应用准确显示用户单击的产品。

As you mentioned, this would indeed require the target application (that is navigated to) to support some parameters. 如您所述,这确实需要目标应用程序(已导航至)支持某些参数。 You mentioned in your question already that you wondered if it would be possible to add a "?...." section to the URL. 您已经在问题中提到,您想知道是否可以在URL中添加“?....”部分。 Fiori apps definitely support this concept, but how it is implemented depends very much on the app itself. Fiori应用程序肯定支持此概念,但是如何实现它在很大程度上取决于应用程序本身。 In my previous example it could be as easy as eg adding ?product_id=abcde though. 在我之前的示例中,它很容易,例如添加?product_id=abcde

Fiori also has very nice extensibility concepts built-in. Fiori还内置了非常不错的可扩展性概念。 So if your target app doesn't exactly support the parameters you intend to pass, you could easily extend the app to support it, without having to rewrite of copy the entire app (which would be a disaster when you receive updated from the original developer). 因此,如果您的目标应用程序不完全支持您打算传递的参数,则可以轻松扩展该应用程序以支持它,而不必重写整个应用程序的副本(当您收到原始开发者的更新时,这将是一场灾难。 )。

To navigate from one Fiori app to the other, it is advised to use the toExternal method of the CrossApplicationNavigation service, which comes with the Fiori launchpad. 要从一个Fiori应用程序导航到另一个,建议使用Fiori启动板随附的CrossApplicationNavigation服务的toExternal方法。 This service allows you to specify parameters such as the app you'd like to navigate to, the intent (display, create etc), parameters (such as product ID) and a app specific route (eg /supplierdetails to see the supplier details of a product). 这项服务可让您指定参数,例如您要导航的应用程序,意图(显示,创建等),参数(例如产品ID)和特定于应用程序的路线(例如/ supplierdetails以查看供应商的详细信息)一个产品)。

The CrossApplicationNavigation service is officially documented in the SAPUI5 SDK , but I'm afraid that the SDK doesn't contain a very elaborate description. CrossApplicationNavigation服务已正式记录在SAPUI5 SDK中 ,但恐怕该SDK没有包含非常详尽的描述。 However, if you Google for it, you'll find extensive information and examples on SCN and Stackoverflow on this topic as well. 但是,如果您使用Google,则会在此主题上找到有关SCN和Stackoverflow的大量信息和示例。

As promised here is what I got to work - actually got the overall method from an answer on here somewhere else. 正如我所承诺的,这就是我要做的工作-实际上是从其他地方的答案中获得了总体方法。

This will send back enough detail that I can at least show the user some updates however after searching around I believe what I really need to be able to do is batch requests... I'm looking into Apache Olingo to see if that's possible. 这将发送回足够的详细信息,至少我可以向用户显示一些更新,但是在搜索之后,我相信我真正需要做的是批处理请求……我正在研究Apache Olingo,以查看是否可行。

    function orderSmmary(SO) {
    var uri = "https://fiori.<company>.com/sap/opu/odata/sap/<environment>/Details('"+ SO + "')?$format=json";

    var http_request = new XMLHttpRequest();
    http_request.onreadystatechange  = function() {
        if (http_request.readyState == 4  ) {
            var data = JSON.parse(http_request.responseText);
            // Do lots of awesome stuff with response
        }
    }

    http_request.open('GET',uri, true);
    http_request.setRequestHeader("Authorization", "Negotiate");
    http_request.send();    
}

Again this is an entirely clientside solution from completely outside any flori environment so I am hoping to stay completely javascript based. 同样,这是一个完全不受任何flori环境影响的完全客户端解决方案,因此我希望完全基于javascript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM