简体   繁体   English

如何序列化 SAP 业务对象?

[英]How To Serialize SAP Business Objects?

First I have to clarify that I'm not referring to the company Business Objects recently acquired by SAP.首先,我必须澄清,我指的不是最近被 SAP 收购的Business Objects公司。 Instead I'm referring to business objects as defined in the SAP Business Object Repository (BOR), eg SalesOrder (BUS2032).相反,我指的是 SAP Business Object Repository (BOR) 中定义的业务对象,例如 SalesOrder (BUS2032)。

So what would be the preferred approach to serialize such a business object in the SAP system so that a third party system could deserialize the business object including all attributes that make up a specific business object instance?那么,在 SAP 系统中序列化此类业务对象以便第三方系统可以反序列化业务对象(包括构成特定业务对象实例的所有属性)的首选方法是什么?

According to this article you need to use the IF_SERIALIZABLE_OBJECT interface.根据这篇文章,您需要使用IF_SERIALIZABLE_OBJECT接口。 I'm guessing your business object doesn't already implement that interface so you may have to extend it to a custom business object and implement the IF_SERIALIZABLE_OBJECT interface there.我猜您的业务对象尚未实现该接口,因此您可能必须将其扩展到自定义业务对象并在那里实现IF_SERIALIZABLE_OBJECT接口。

I'd say IDocs, but I see you don't want to use the SAP generated representations.我会说 IDocs,但我看到您不想使用 SAP 生成的表示。 Which means you'll have to write your own implementation using ABAP.这意味着您必须使用 ABAP 编写自己的实现。 In a nutshell:简而言之:

  1. Retrieve the data you need using BAPIs and/or queries使用 BAPI 和/或查询检索您需要的数据
  2. Stick all the data onto one or more custom classes ( zcl_sales_order , zcl_sales_order_position , etc.), which you design according to your needs将所有数据粘贴到您根据需要设计的一个或多个自定义类( zcl_sales_orderzcl_sales_order_position等)上
  3. Serialize the instance into an XML representation using the call transformation statement (though this will still contain some SAP-specific formatting), or write your own serialization method (this is probably what you need)使用call transformation语句将实例序列化为 XML 表示(尽管这仍将包含一些特定于 SAP 的格式),或者编写您自己的序列化方法(这可能是您需要的)

The SAP Business Connector uses XML documents to exchange SAP objects (between SAP and non-SAP systems). SAP Business Connector 使用 XML 文档来交换 SAP 对象(在 SAP 和非 SAP 系统之间)。 Maybe you can find some help in this article.也许您可以在本文中找到一些帮助

I don't know of a simple way to serialize BOR objects.我不知道序列化 BOR 对象的简单方法。 However in many cases SAP have provided BAPI's that are Remote Enabled Function modules that can be called via the various SAP connectors or SOAP etc.然而,在许多情况下,SAP 提供了 BAPI,它们是可通过各种 SAP 连接器或 SOAP 等调用的远程启用功能模块。

Taking BUS2032 as an example:以BUS2032为例:

  • Run transaction SWO1运行事务 SWO1
  • Enter BUS2032输入BUS2032
  • Click the Program button单击程序按钮
  • Search on call function 'BAPI搜索call function 'BAPI

You will find various BAPI's - in this case they all belong to function group 2032 that can be accessed via transaction SE80您会发现各种 BAPI - 在这种情况下,它们都属于可通过事务 SE80 访问的功能组 2032

Note that SAP is not always this accomodating in their naming standards, but the more mature the module the better the chance that they've already made some form of RFC or Webservice available for the module.请注意,SAP 的命名标准并不总是如此包容,但是模块越成熟,他们已经为该模块提供某种形式的 RFC 或 Web 服务的可能性就越大。

Of course you can also write your own RFC or webservice, but then you need to understand the business model and which attributes are needed.当然你也可以自己写RFC或者webservice,但是这时候你需要了解业务模型以及需要哪些属性。

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

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