我正在尝试构建一个 CDS 视图,该视图使用 VBRK 和 VBRP 发票中的各种字段。另一个要求是显示原始采购订单中列出的价格(例如,我正在向某人出售猕猴桃,我想显示我支付的原始购买价格)。我应该使用参数批处理(MSEG-CHARG)与 MSEG 的连接。这里的假设是每批只有一个采购订单。不过,我不确定如何从发票中建立这种联系。
这是我的基本 CDS 视图:
@AbapCatalog.sqlViewName: <view_name>
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: '<text>'
@VDM.viewType: #BASIC
define view <view_name> as select distinct from I_BillingDocumentItemCube( P_ExchangeRateType: 'M', P_DisplayCurrency: 'EUR' )
{
key BillingDocument,
key BillingDocumentItem,
BillingDocumentType,
_BillingDocument._Item._PricingElement[ConditionType = 'XXX1'].ConditionRateValue as cost1,
_BillingDocument._Item._PricingElement[ConditionType = 'XXX2'].ConditionRateValue as cost2,
SoldToParty,
SoldToPartyName,
Material,
BillingDocumentItemText,
Batch,
BillingDocumentDate,
BillingQuantity,
BillingQuantityUnit,
SalesDocumentItemCategory
};
我尝试使用表函数从 MSEG 中选择响应批次,但我不确定如何将其连接到 CDS 视图。
@EndUserText.label: '<name>'
define table function <table_function>
with parameters @Environment.systemField: #CLIENT
clnt: abap.clnt,
charg: charg_d
returns {
clnt : abap.clnt;
charg_exp : charg_d;
dmbtr : dmbtr_cs;
menge : menge_d;
}
implemented by method <class> => <method>;
班级:
CLASS <class_name> DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
CLASS-METHODS <method_name> FOR TABLE FUNCTION <table_function>.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS <class_name> IMPLEMENTATION.
METHOD <method_name>
BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING nsdm_e_mseg.
RETURN select top 1 mandt as clnt, charg as charg_exp, dmbtr, menge
from nsdm_e_mseg
where mandt = :clnt
and charg = :charg
and dmbtr > 0
and menge > 0
order by mblnr;
ENDMETHOD.
ENDCLASS.
如何在我的基本 CDS 视图中使用此表函数将 VBRP 中的位置连接到 MSEG 中的位置?