For more detail about how product determination works in one order scenario, please refer to this blog: Product Alternative ID used in Opportunity Line item product determination.
As it is not possible to only create the test class for a given function module via ABAP unit test framework, but the test class has to be created on function group level:
For demonstration purpose I would not like to modify SAP standard function group, so I create a new local class as wrapper with a method name which is exactly equal to the function module name. As a result now I can just create local test class against this wrapper class by ABAP unit test wizard:
For determination failure case, it is easy to implement, just pass an non-existing ordered product as input parameter value for iv_ordered_product. If determination fails as expected, es_product_detail and cv_ordered_prod will remain initial.
For successful determination case, I expect that the standard product id ( gv_prod_id ) should be determined based on alternative ID ( gv_altid ).
In my unit test, the alternative ID value contained in gv_altid and the product id contained in gv_prod_id are fake, neither of them point to a real product in the system. When I debug the product determination based on real product performed in WebUI, I found these two database tables are joined for determination.
As a result, I plan to create corresponding dummy entry in these two database tables in the SETUP method of test class:
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = mv_fake_prod_guid.
ls_mock_alt_id = VALUE #( product_guid = mv_fake_prod_guid
upname = sy-uname
altvehno = gv_altid ).
INSERT isam_o_veh_ids FROM ls_mock_alt_id.
DATA(prod) = VALUE comm_product( product_guid = mv_fake_prod_guid
product_id = gv_prod_id
product_type = '01' upname = sy-uname ).
INSERT comm_product FROM prod.
COMMIT WORK AND WAIT.
And remove them in TEARDOWN:
METHOD teardown.
DELETE FROM isam_o_veh_ids WHERE product_guid = mv_fake_prod_guid.
DELETE FROM comm_product WHERE product_guid = mv_fake_prod_guid.
COMMIT WORK AND WAIT.
ENDMETHOD.
In the meantime, the determination function module needs a guid for one order header object ORDERADM_H. When the function module is executed, the header data will be read from buffer. In my unit test, in order to ensure that the header read from buffer succeed, I have to first insert the buffer of dummy object header via the following code in SETUP method:
DATA: ls_mock_header TYPE crmt_orderadm_h_wrk,
ls_mock_alt_id TYPE isam_o_veh_ids,
lt_link TYPE crmt_link_comt,
ls_link LIKE LINE OF lt_link.
CREATE OBJECT f_cut.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = mv_header.
ls_mock_header-guid = mv_header.
ls_mock_header-process_type = gv_oppt_proc_type.
CALL FUNCTION 'CRM_ORDERADM_H_PUT_OB'
EXPORTING
is_orderadm_h_wrk = ls_mock_header.
The unit test could successfully be executed and all tests pass:
However, when looking back about the unit test implementation, I find the test has dependency on the transaction type which must exist in current system and has been configured with Alternative ID correctly. Suppose my unit test code is transported to a testing system where type “ZJER” does not exist, the unit test will fail there.
As a result, the improvement would be:
(1) Change the constant value of process type from “ZJER” to a type which does not exist in any system, for example “ABCD”:
(2) Append the following source code to the end part of SETUP method, to create a temporary transaction type for unit test purpose:
(3) Remove the temporary transaction type in TEARDOWN method:
As displayed above, I have two test methods DETERMINE_OK and DETERMINE_FAIL to test these two boundary conditions.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关推荐
\[ f(x) = (x_1^2 + x_2^2 + \cdots + x_n^2)^4 - \prod_{i=1}^{n} (4x_i^3 - \frac{3}{5}x_i) \] 该函数的特点在于其复杂的形状,包括平坦区域、陡峭斜坡和多个局部极小值,这使得寻找全局最小值极具挑战性。在...
- `lv_bol_core->start_up('PROD_ALL')`:启动 SAP BOL Core,参数 `'PROD_ALL'` 指定了启动模式。 2. **创建 SAP BOL Query Service 实例** - `lv_query = cl_crm_bol_query_service=>get_instance(iv_query_...
\[ f(x) = \frac{1}{4000} \sum_{i=1}^{n} \frac{x_i^2}{\sqrt{i}} - \prod_{i=1}^{n} \cos(\frac{x_i}{\sqrt{i}}) + 1 \] 其中,\( n \)是问题的维度,\( x_i \)是第\( i \)个决策变量的值。函数的定义域通常是...
\[ f(x) = \frac{1}{4000} \sum_{i=1}^{n} x_i^2 - \prod_{i=1}^{n} \cos\left(\frac{x_i}{\sqrt{i}}\right) + 1 \] 这个函数在n维空间中定义,其中n是变量的数量。由于其复杂的性质,Griewank函数常被用来测试优化...
\[ H_{p,q}^{m,n}(z) = \int_0^{\infty} \frac{\prod_{j=1}^m \Gamma(b_j + B_j t)}{\prod_{i=1}^n \Gamma(a_i + A_i t)} \left(\frac{z}{t}\right)^{-B} t^{-A-1} dt \] 这里的\( \Gamma \)函数是Euler的Gamma函数...
SAP PI SLD 基础及配置 SAP PI SLD(System Landscape Directory)是 SAP NetWeaver 平台下的一个核心组件,负责管理和存储系统景观中的软件信息和系统信息。SLD 是一个标准化的信息库,提供了关于系统景观中的软件...
- \( g(x) = \prod_{j=1}^{n-m+1} x_j \) 是一个惩罚函数,确保了非支配解的存在, - \( \bar{x} = [x_{n-m+2}, ..., x_n] \) 是剩余的决策变量, - \( h_i(\bar{x}) = 1 - \sum_{j=1}^{n-m+1} (\bar{x}_j)^{m-i+1} ...
\[ L(\mu, \sigma, \alpha|x) = \prod_{i=1}^{n} f(x_i; \mu, \sigma, \alpha) \] 极大似然估计(Maximum Likelihood Estimation, MLE)是通过最大化似然函数来估计未知参数的方法。对于GGD,可以通过求解关于μ、...
在MATLAB中,内置函数分为多种类型,包括基本数学函数、数组和矩阵操作函数、统计与概率函数、绘图函数等。例如: 1. **基本数学函数**:如sin、cos、tan用于三角函数计算,exp用于指数运算,log和log10分别处理...
\[ f(\mathbf{x}) = \frac{1}{4000}\sum_{i=1}^{n} x_i^2 - \prod_{i=1}^{n} \cos\left(\frac{x_i}{\sqrt{i}}\right) + 1 \] 该函数具有全局最小值0,在 \(\mathbf{x} = [0, 0, \ldots, 0]\) 处取得。 ##### 2.9 ...
函数定义为\( f(x) = \frac{1}{4000}\sum x_i^2 - \prod\cos(\frac{x_i}{\sqrt{i}}) + 1 \)。 这些测试函数通常用于以下目的: - 验证优化算法能否找到全局最小值,而不是陷入局部最小。 - 比较不同优化算法的...
\[ f(x) = \frac{1}{4000} \sum_{i=1}^{n} x_i^2 - \prod_{i=1}^{n} \cos\left(\frac{x_i}{\sqrt{i}}\right) + 1 \] 其中,\( n \)表示问题的维度,\( x_i \)是第\( i \)个变量的值。函数的值在全局最小值处为0,而...
- `PROD_INST_ID`: 产品实例ID,可能指的是特定服务或产品的订阅实例。 - `ACCT_ID`: 账户ID,每个用户的唯一标识,用于跟踪和管理用户的各项活动和服务。 - `OWN_CUST_ID`: 拥有者客户ID,可能是主账户或负责人...
这份名为"matlab常用函数和规则.rar"的压缩包显然包含了MATLAB初学者所需的重要资源,特别是对于熟悉和掌握MATLAB的基本操作和常用函数非常有帮助。让我们详细探讨一下这个压缩包可能包含的内容。 首先,MATLAB的...
\[ L_i(x) = \prod_{j=0, j\neq i}^{n} \frac{x - x_j}{x_i - x_j} \] 接下来,我们转向牛顿插值。牛顿插值法与拉格朗日插值类似,也是构建一个多项式来逼近数据,但它使用的是差商而不是多项式的乘积。在MATLAB中...
\[ z = \frac{1}{4000} \sum_{i=1}^{d} u_i^2 - \prod_{i=1}^{d} \cos \left( \frac{u_i}{\sqrt{i}} \right) + 1 \] **MATLAB 实现代码:** ```matlab function z = GriewanksFunction(u) dim = size(u); sum_1 =...
\[ f(x) = \frac{1}{4000}\sum_{i=1}^{n}x_i^2 - \prod_{i=1}^{n}\cos\left(\frac{x_i}{\sqrt{i}}\right) + 1 \] 人工蜂群算法(ABC)由Karaboga在2005年提出,它模拟了蜜蜂寻找食物源的过程,包括工蜂、觅食蜂和...
\[ f(x) = \frac{1}{4000} \sum_{i=1}^{n} x_i^2 - \prod_{i=1}^{n} \cos\left(\frac{x_i}{\sqrt{i}}\right) + 1 \] 其中,\( x_i \) 是变量,\( n \) 是问题的维度。Griewank函数在原点处有一个全局最小值0,但在...
对于接收,传真/短信服务器或提供商将电子邮件发送到SAP系统的域名地址(例如FAX=+496227751624@crm-prod.company.com)。 要使用SAP邮件系统,需要满足以下前提条件: * 邮件服务器必须是SMTP兼容的。 * 如果要在...
5. **Griewank函数**:\( f(\mathbf{x}) = \frac{1}{4000}\sum_{i=1}^{n}(x_i^2) - \prod_{i=1}^{n}\cos\left(\frac{x_i}{\sqrt{i}}\right) + 1 \),全局最小值在原点,但具有平坦区域和许多局部极小值。 这些测试...