S/4系统中对某些表如(MARC、MBEW、COBL)进行增强的时候,需要同时更新CDSVIEW的DDL,否则就会报如下的错误导致标准表无法激活。
SAP在NOTE 2242679 - Redirect inconsistency - Proxy Substitution 中介绍了原因和各个版本的变化,把NOTE原文放到最下面作参考:
https://sapyard.com/how-to-append-standard-tables-having-replacement-objects-in-s-4hana/ 这篇文章有介绍详细的操作步骤
大概总结一下:
1.首先按照传统的方法去APPEND STRUCTRUE,激活, 这个时候会有报错,不用管
2.新建一个EXTEND VIEW,代码如下: 示例中MARC APPEND的 structrue:zzapend01 包含字段zzflag
@AbapCatalog.sqlViewAppendName: 'ZZAPPEND01_V'
@EndUserText.label: 'Extension view for Append ZZAPPEND01'
extend view nsdm_e_marc with Zzappend01_E {
t.zzflag
}
激活,如果没有报错的话应该问题不大
3.检查一下NSDM_V_MARC,增强字段是否已经插入了。
4.重新激活MARC
注意:涉及到表的调整,操作请一定按照步骤来,如果需要做删除的操作,应该先删除DDL,再删除APPEND STRUCTRUE,如果有遇到无法激活或者未知的报错,
可以用SE14对表进行调整或者重构。以下是SAP提供NOTE的内容。
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Symptom
After migration to S/4HANA OP1511 you get the runtime error DBSQL_REDIRECT_INCONSISTENCY 'A table could not be redirected' while accessing table MARC, MBEW, EBEW, OBEW, QBEW, MKPF or MSEG in ABAP.
This error message may also be thrown for the tables MARD, MCHB, MSSQ, MSSL, MSSA, MSPR, MSLB, MSKU, MSKA or MKOL after migration to S/4HANA OP1610 or higher.
The error analysis describes that a setting in the dictionary stipulates that proxy data object "<AbapCatalogViewName>" is used to execute table "<table>" at runtime. The definition of "<table>" and "<AbapCatalogViewName>" are not consistent however, meaning that the operation had to be terminated.
If you check the table in the dictionary via SE11 you get an error message like:
- DT 342 MSEG and proxy object NSDM_V_MSEG have different numbers of columns
- DT 338 Column ZZFIELD exists in MSEG but not in NSDM_V_MSEG or has a different position there
Other Terms
MKPF, MSEG, MARC, MBEW, EBEW, OBEW, QBEW, MARD, MCHB, MSSQ, MSSL, MSSA, MSPR, MSLB, MSKU, MSKA, MKOL, CDS proxy view; Append, $EXTENSION, EXTEND VIEW, DT342, DT338
Reason and Prerequisites
Background information:
The MM-IM data model in S/4HANA has been changed compared to ERP/SoH. Actual stock data will not be stored anymore in the former key figure material master data tables and the material document will not be stored anymore in the tables MKPF (header data) and MSEG (item data). Instead the single table MATDOC has been introduced which stores the material document and from which the actual stock data will be calculated on-the-fly because each material document is a change of stock. More details are described in note 2206980.
To ensure compatibility for customer coding there are proxy objects assigned to the former document tables and the material master key figure tables (use SE11 -> Extras -> Proxy object). These proxy objects are CDS views which read the data from table MATDOC instead from the "old" tables. The assignment requires that the proxy view is identical to the table regarding fields and the sequence of fields.
Issues may occur if the tables have been enhanced by APPENDs because in this case the structure compatibility between table and assigned proxy obejct is broken.
For S/4HANA OP1511 all support and feature packages:
For most of the tables the structural compatibility is still ensured because the delivered proxy CDS view uses the $EXTENSION keyword at the end which adds fields from APPENDs at the end of a table also at the end of the proxy CDS view. This is the case for the proxy CDS views for the tables MARD, MCHB, MSSQ, MSSL, MSSA, MSPR, MSLB, MSKU, MSKA or MKOL.
Affected are customer appends on tables MARC, MBEW, EBEW, OBEW, QBEW, MKPF or MSEG or implementation of include structure CI_COBL in MSEG because for those tables the $EXTENSION mechanism does not work in any case due to:
-
MARC and xBEW are build of a structure which itself is build by structures and fields. If the APPEND is done in one of those sub-structures then the consequence is that the fields from the APPEND is somewhere in between in the table and hence appending fields at the end of the assigned proxy view will lead to a structure mismatch.
-
MSEG contains the custumer include CI_COBL somewhere in the middle of the table definition. Hence by implementing CI_COBL the fields are also somehwere in the middle of the table and hence appending fields at the end of the assigned proxy view will lead to a structure mismatch.
For S/4HANA OP1610 and higher:
For S/4HANA OP1610 the $EXTENSION keyword has been removed from the proxy CDS views of tables MARD, MCHB, MSSQ, MSSL, MSSA, MSPR, MSLB, MSKU, MSKA or MKOL. This has been done due to too many side effects like unpredictable sequence of fields from APPENDs.
Hence, additionally to the OP1511 case, customer appends on tables MARD, MCHB, MSSQ, MSSL, MSSA, MSPR, MSLB, MSKU, MSKA or MKOL are affected.
Solution
Follow the instructions given in the next blocks and import the program NSDM_PROXY_SUBSTITUTION via SNOTE if this program is not available in your system (delivered with S/4HANA OP1511 SP01).
For S/4HANA OP1511:
To make it pretty clear: the below mentioned steps are not required if you have an APPEND structure directly at the end of the tables MARC or xBEW in the table. This case is automatically handled by the $EXTENSION keyword in the CDS proxy views delivered by SAP. If SE11 reports inconsistency between table and proxy object then please do a re-activation of the proxy view (use ABAP Development Tools for this) and then a re-activation of the table.
The steps 1 and 2.1 as well as 2.2 below must be executed in cases where:
-
the APPEND is in some of the structures building MARC or xBEW.
-
or there is an APPEND in table MKPF or MSEG.
-
or for table MSEG with implemented CI_COBL include.
For S/4HANA OP1610 and higher:
Only the step 1 below must be executed in cases where:
-
the APPEND is in some of the structures building MARC or xBEW.
-
or there is an APPEND structure in the tables MKPF, MSEG, MARC (at the end of table MARC itself), MARD, MCHB, MSSQ, MSSL, MSSA, MSPR, MSLB, MSKU, MSKA or MKOL.
-
or for table MSEG with implemented CI_COBL include.
1. Create an EXTEND VIEW
For APPENDs on structures of tables for the above described cases use ABAP Development Tools (ADT) Core Data Services (CDS) and create a new DDL source (ABAP Core Data Services - Data Definition) with name <Name of your append>_DDL (how to install ABAP in Eclipse is described in note 1718399). Enter a description like 'Extension view for Append <Name of your append>'. Select the template 'Extend View' and adopt the proposed coding EXTEND VIEW <proxy view name for table> with <Name of your append>_E .
- The <proxy view name for MARC> is NSDM_E_MARC.
- The <proxy view name for xBEW> is MBV_xBEW.
- The <proxy view name for MSEG> is NSDM_E_MSEG.
- The <proxy view name for MKPF> is NSDM_E_MKPF.
- The <proxy view name for Mxyz> is NSDM_E_Mxyz.
Enter all the fields from the APPEND in this extend proxy view. If you have several APPENDs in one table (may happen if a table is composed by sub-structures or for MSEG an implemented CI_COBL include as well as an APPEND on table MSEG), then all fields from all your APPENDs shall be inserted in the customer CDS proxy view.
Example for MARC:
@AbapCatalog.sqlViewAppendName:'<Name of your append>_V' |
@EndUserText.label:'Extension view for Append <Name of your append>' |
@AccessControl.authorizationCheck:#NOT_REQUIRED |
EXTEND VIEW NSDM_E_MARC with <Name of your append>_E |
{ |
<your field list> |
} |
If you have implemented the CI_COBL customer include structure of table MSEG than do the same as above. Additionally you need note 2240878 to migrate the CI_COBL data of MSEG to MATDOC. If you later on like to make use of one of the fields in EXTEND VIEW for CI_COBL in the app "Custom fields and logic" then you need to follow the instructions given in this article in the SAP Help portal. Basically you need to remove the field from the EXTEND VIEW for CI_COBL, save without activate and then add the field in the app "Custom fields and logic" (valid for release 1709 and higher).
2. Correct sequence of fields for S/4HANA OP1511
The below mentioned steps shall be executed only in the case described above where
- an APPEND exist in the sub-structures building the tables MARC, xBEW
- or if there is an APPEND on table MKPF or MSEG
- or in case of the CI_COBL implementation for table MSEG.
These steps shall not be executed in case of an APPEND directly in tables MARC, MARD, MCHB, MSSQ, MSSL, MSSA, MSPR, MSLB, MSKU, MSKA or MKOL.
2.1. Implement the program NSDM_PROXY_SUBSTITUTION
Implement the new program NSDM_PROXY_SUBSTITUTION delivered with this note as below if it is not available in your system (S/4HANA OP1511 SP00).
2.2. Execute the program NSDM_PROXY_SUBSTITUTION
Run the report to perform the additional manual adjustments.
Select the table to adjust, enter a <name> with customer namespace for the new CDS view and an explanatory text which will become part of the short description '<table>: <explanatory text>'.
This adjustment program creates a new CDS proxy view <name>_E with AbapCatalog name <name>_V and DDL <name>_DDL, which SELECTs data from the underlying delivered CDS proxy view but where the fields are sequenced according to their order in the table to ensure compatibility between table and proxy object. This new CDS proxy view will then be assigned to the table thereafter. The new CDS proxy view will be inserted in a workbench transport request if necessary.