如何使用SAP C4C Repository Explorer里的BO test shell

举报
Jerry Wang 发表于 2022/05/14 20:25:02 2022/05/14
【摘要】 在SAP研究院做过SAP Business ByDesign和SAP Cloud for Customer后台开发的小伙伴们,都知道ABAP 里 BO test shell这个工具。在C4C Cloud Application Studio里也存在类似工具。打开repository exploerer:以CustomerQuote为例,找到要执行的Query节点,右键:从SAP C4C UI...

在SAP研究院做过SAP Business ByDesign和SAP Cloud for Customer后台开发的小伙伴们,都知道ABAP 里 BO test shell这个工具。

在C4C Cloud Application Studio里也存在类似工具。

打开repository exploerer:

以CustomerQuote为例,找到要执行的Query节点,右键:

从SAP C4C UI上找一个Sales Order的ID复制下来:9000000490

填到query参数里:

执行的结果:

在执行结果里,也可以顺着Association,访问该BO实例其他子节点的数据,非常方便:

点击Generate Code按钮,可以看到自动生成的使用Query访问该BO实例数据的ABSL代码:

The user roles are Studio Administrator, Developer, and Business User.

  • PDI_ADMINISTRATION / Administration
  • PDI_DEVELOPMENT / Development

对于Sales Order creation来说,Buyer Party以及行项目的Product维护是必须的。

通过TypeCode区分CustomerQuote是Sales Order还是Sales Quote:

使用ABSL创建Sales Order的代码:

import ABSL;
import AP.CRM.Global;

// ABSL example for CustomerQuote

// define CustomerQuote root node
var elCustomerQuote_Root: elementsof CustomerQuote;
var instCustomerQuote;

// define CustomerQuote item node
var elCustomerQuote_Item: elementsof CustomerQuote.Item;
var instCustomerQuote_Item;

// CustomerQuote: maintain Business Object type - optional (default value: 30 = Sales Quote set by system; other values: 2059 = Sales Order)
elCustomerQuote_Root.TypeCode = "30";

// CustomerQuote: maintain description - optional
elCustomerQuote_Root.Name.content = "PSM CRM ABSL Test - CallCustomerQuoteExample";

// CustomerQuote: maintain external reference - optional
elCustomerQuote_Root.BuyerID.content = "PSM CRM ABSL Test - Example_01";
	
// CustomerQuote: create new instance 
instCustomerQuote = CustomerQuote.Create(elCustomerQuote_Root);
    
// CustomerQuote: maintain buyer party - mandatory
//             the instance of node Party is created automatically by the system
instCustomerQuote.BuyerParty.PartyKey.PartyID.content = "MC9785";
		
// CustomerQuote: maintain item with product
	
// CustomerQuote: set item ID or any other attribute of the node Item in order
//             to be able to enter a product later on
elCustomerQuote_Item.ID = "10";
	 
// CustomerQuote: create item instance
instCustomerQuote_Item = instCustomerQuote.Item.Create(elCustomerQuote_Item);
	
// set product identifier - mandatory
instCustomerQuote_Item.ItemProduct.ProductKey.ProductID.content = "MCF-0001";		

// change quantity - optional 
if ( instCustomerQuote_Item.FirstRequestedItemScheduleLine.IsSet()) { 
	// set product quantity and UOM (will be defaulted by the system if not set) 
	instCustomerQuote_Item.FirstRequestedItemScheduleLine.Quantity.content  = 2;
	instCustomerQuote_Item.FirstRequestedItemScheduleLine.Quantity.unitCode = "EA";
}

读取CustomerQuote的ABSL代码:

import ABSL;
import AP.CRM.Global;

// ABSL example for CustomerQuote

// Define variables to query CustomerQuote
var qryCustomerQuote_QueryByElements;
var selParamsCustomerQuote_QueryByElements;
var colQryResult;
var instCustomerQuote;

// CustomerQuote: define query and parameters to be used for retrieval of data
qryCustomerQuote_QueryByElements 
	= CustomerQuote.QueryByElements;
selParamsCustomerQuote_QueryByElements 
	= qryCustomerQuote_QueryByElements.CreateSelectionParams();

// CustomerQuote: set Business Object type - optional (default value: 30 = Sales Quote set by system; other values: 2059 = Sales Order)
selParamsCustomerQuote_QueryByElements.Add(qryCustomerQuote_QueryByElements.TypeCode, "I","EQ","30");

// CustomerQuote: fill the query parameter values - in this example search via the external reference
selParamsCustomerQuote_QueryByElements.Add(qryCustomerQuote_QueryByElements.BuyerID.content, "I","EQ","PSM CRM ABSL Test - Example_01");

// CustomerQuote: execute the query
colQryResult = qryCustomerQuote_QueryByElements.Execute(selParamsCustomerQuote_QueryByElements);
   
// CustomerQuote: loop all found instances
foreach (instCustomerQuote in colQryResult) { 
	break; // take only first instance in case multiple are found
}

修改customer quote的代码:

import ABSL;
import AP.CRM.Global;

// ABSL example for CustomerQuote

// Define variables to query CustomerQuote
var qryCustomerQuote_QueryByElements;
var selParamsCustomerQuote_QueryByElements;
var colQryResult;
var instCustomerQuote;
var instCustomerQuote_Item;

// CustomerQuote: define query and parameters to be used for retrieval of data
qryCustomerQuote_QueryByElements 
	= CustomerQuote.QueryByElements;
selParamsCustomerQuote_QueryByElements 
	= qryCustomerQuote_QueryByElements.CreateSelectionParams();

// CustomerQuote: set Business Object type - optional (default value: 30 = Sales Quote set by system; other values: 2059 = Sales Order)
selParamsCustomerQuote_QueryByElements.Add(qryCustomerQuote_QueryByElements.TypeCode, "I","EQ","30");

// CustomerQuote: fill the query parameter values - in this example search via the external reference
selParamsCustomerQuote_QueryByElements.Add(qryCustomerQuote_QueryByElements.BuyerID.content, "I","EQ","PSM CRM ABSL Test - Example_01");

// CustomerQuote: execute the query
colQryResult = qryCustomerQuote_QueryByElements.Execute(selParamsCustomerQuote_QueryByElements);
   
// CustomerQuote: loop all found instances
foreach (instCustomerQuote in colQryResult) { 
	break; // take only first instance in case multiple are found
}

// CustomerQuote: update quantity for item product
foreach (instCustomerQuote_Item in instCustomerQuote.Item) {
  // get item with a certain ID to be changed
  if (instCustomerQuote_Item.ID.Contains("10")) {
    break;
  };
}
if ( instCustomerQuote_Item.IsSet()) { 
	// set product quantity and UOM (will be defaulted by the system if not set) 
	instCustomerQuote_Item.FirstRequestedItemScheduleLine.Quantity.content  = 5;
	instCustomerQuote_Item.FirstRequestedItemScheduleLine.Quantity.unitCode = "EA";
}

Item Schedule Lines

The requested delivery date is defaulted automatically when a customer quote is created.

当Customer Quote被创建时,requested delivery date被默认逻辑填充。

It can be changed using the association RequestedFulfillmentPeriod.

这个默认值可以被RequestedFulfillmentPeriod这个association修改。

This date is taken over as requested delivery date for the items.

item级别的requested delivery date从订单抬头的对应字段带过来。

On item level the requested delivery date can be set using the association FirstRequestedItemScheduleLine.

带过来的值也可以通过FirstRequestedItemScheduleLine修改。

Price and Tax Calculation Item

When interacting with the Price And Tax Calculation Item node the following specifics have to be considered using the public model.

Prices are derived automatically from the price lists maintained for the products and customers.

通过product和customer主数据上维护的price list,行项目的价格被自动决定出来。

In order to set or get the automatically determined prices the following associations can be used:

  • Item Main Price
  • Item Main Discount
  • Item Main Surcharge
  • Item Main Total
  • Operational Item Price Component

Address

The address of a Party can be accessed via the following associations:

  • AddressSnapshot (read-only)
  • UsedAddress (read/write)

In case address data of a Party node instance is changed via association UsedAddress a document specific address will be created.

我们每次通过association UsedAddress 修改 Party的地址时,一个新的Document specific address会被创建。

This means, the address change is exclusively applied to the party instance in the respective transactional document.

只是文档的party transaction 数据的地址被修改了,而party主数据地址保持不变。

The master data address of the party remains unchanged.

// ABSL example to create a document-specific address for a party, for example the product recipient: 

....
if ( this.ProductRecipientParty.UsedAddress.DefaultPostalAddressRepresentation.IsSet( ) ) {

/ * 
    For performance reasons DO NOT update every single attribute by using the association path:
    this.UsedAddress.DefaultPostalAddressRepresentation.CityName = " Document City";
    this.UsedAddress.DefaultPostalAddressRepresentation.HouseID = "217";
    ....
*/

//...to improve performance retrieve the address via association once and update afterwards the respective attributes:
    var elPartyAddress =  this.ProductRecipientParty.UsedAddress.DefaultPostalAddressRepresentation;
    elPartyAddress.CityName = "Document City";
    elPartyAddress.HouseID = "217";
    elPartyAddress.StreetName = "Doc Street";
    elPartyAddress.StreetPostalCode = "27272";

}
....
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。