回答你的问题
现在我问自己:我如何获得客户 id / kunnr?我从当前登录的用户那里得到了什么?
它是通过标准定制在后端完成的,而不是像您打算那样通过 OData 方法完成。
Mikael 给了你一个粗略的想法,但没有完成,所以我会给出更全面的答案。
我们需要区分前端和后端授权,对于 Fiori 应用程序运行,您需要角色/授权类型:
- 定义向用户显示哪些 Fiori 应用程序的 SAP Fiori 角色
- 启动板授权
- 一般 OData 授权
- 受信任的 RFC 后端连接授权
- 包含显示相关业务数据的权限的后端权限和角色
下图描绘了这个概念:
这里描述了前端的分配,现在超出了范围。现在我们专注于第 2 点。
每个 Fiori 应用程序都有其角色模型,并且应该遵循应用程序描述中给出的实现。让我们根据销售订单创建应用程序 (F0018)示例来考虑它是如何完成的:
- 返回业务数据的 OData 服务是
SRA017_SALESORDER_CREATE_SRV
,因此要运行它需要前端角色SAP_SD_BCR_FIELDSALESREP_X1
和后端角色SAP_SD_SO_CRE_APP
- 应用程序描述还为我们提供了以下先决条件:
Before implementing the Create Sales Order app, you must ensure the following:
That an employee master record is created with the following attributes:
If you have implemented SAP ERP HCM and maintained employees in the HCM personnel records, ensure that the employee personnel record has the infotype Communication, with a subtype of System User Name (SY-UNAME) (Infotype 0105, Subtype 0001).
If you have not implemented SAP ERP HCM, implement the Sales and Distribution configuration around Use Sales Employees with HR (Tcode: PULT). This IMG setting copies the appropriate HCM tables from the 000 Client and allows the setup of the employee record with the Infotype Communication and a Subtype of System User Name (SY-UNAME) (Infotype 0105, Subtype 0001).
It associates the USERID of the employee with the personnel number assigned as a partner function sales employee in the customer master.
实施上述客户 SAP 用户 id 将绑定到他的员工 ID (PERNR),因此他的员工 ID 将绑定到 XD02 中的合作伙伴功能。
这还不是全部,接下来会发生什么?
- 以下订单参数应保存在
SIMGH
tcode 中,以便客户查看他的订单并创建新订单。
Call transaction SIMGH to open the Create Sales Orders node and configure user information in Customizing activity Define Configuration Parameters using the parameters listed below. For more information, see the documentation available for the Customizing activity.
Document Type (DOCTYPE)
By default, the app uses the standard order document type (technical key TA resp. OR). Changing this to something other than a sales order may significantly impact the functionality of the application.
Order Period (ORDPERIOD)
This defines how many days into the past sales orders are retrieved. The suggested value is 30 days.
Search Period (SEAPERIOD)
This defines how many days into the past a search must look for sales orders that match the search criteria. The suggested value is 90 days.
Ship To Party (SHIP_TO/PARTNER_ROLE)
This defines which partner role in the customer master is used for the ship-to party. The suggested value is WE.
Forwarding Agent (FORWARDING_AGENT/PARTNER_ROLE)
This defines which partner role in the customer master is used for the forwarding agent. The suggested value is SP.
甚至这还不是全部
- 应用程序描述提供了以下要实现的 BADI 以启用此类链接
Implement the following BAdIs:
Customer Association to Employee
You can use this BAdI to associate employees with specific customers.
只有在完成上述所有步骤后,客户才能订购和/或查看他的销售商品。
寓意:始终彻底检查应用程序描述,因为角色模型因应用程序而异。