DBSQL_REDIRECT_INCONSISTENCY –I have come across a lot of “dumps” during the years as an ABAP developer. But this was new. What had happened?
Maic, who is an ABAP cookbook author reports on hurdles and solutions for dealing with S / 4HANA-related changes in the data model of logistics.
In an S/4 system, the table for material documents, MSEG, had to be extended for a project by one field. In principle, that is not a problem: create an append structure, record the field, activate it and you are done. That would have been the case here too but only this time an error occurred during activation.
OK, so any dependent view now contains an inconsistency. Funny. Must be checked but it is not tragic at first. I am probably not even the culprit (spoiler: yes!). Firstly, test whether you can post material documents. Call MIGO, enter data – * wumms *. Oh no! The activation error doesn’t seem to have been so minor after all. Then we need to do some research.
New S / 4 HANA data model in logistics
I found the solution that is described in the form of various notes in the SAP support portal, after a short search. The data model in logistics was changed during the course of the introduction of S / 4 HANA. Although the known material master tables such as MARC, MARD or MCHB still exist, the semantics have been changed. The tables mentioned contain fields for inventory management. However, these are no longer maintained statically with S / 4 (when posting a material document). The values are rather determined dynamically at the time that the tables are read out by querying the material documents. Advantage: The material master tables do not need to be blocked at the time of booking. Disadvantage: The inventory determination costs performance.
To ensure compatibility with existing programs (which the stocks in the material master tables assume), a CDS view is delivered as a representative object for each table. This can be seen in the SAP GUI in the table display (SE11) via “Extras à Substitute object”, in the table definition in the ABAP Development Tools there is an annotation “@ AbapCatalog.replacementObject”. When the table is accessed from an ABAP program, the database layer of the SAP system forwards the queries to the substitute object. SAP note 2206980 <https://launchpad.support.sap.com/#/notes/2206980> provides an overview of the affected MM tables and the associated representative objects.
In the case of table MSEG, the data model has changed completely. Material documents are saved with S / 4 in the database table MATDOC. In order to ensure a smooth extension of the MSEG table, several steps are necessary:
- Extension of the basic table MATDOC
- Extension of the table MSEG
- Extension of the associated CDS view NSDM_E_MSEG
It is important to ensure the correct naming of the individual objects.
In the following example, the material document is expanded by the “Reference location” field. A standard data element is available for this. As usual with customer fields in SAP tables, the field name must begin with the prefix “ZZ”, “YY” or a namespace.
Step 1: create structure
To ensure that the structure is the same between the two tables, MATDOC and MSEG, a structure is created that contains the necessary fields. This structure is then used as an include in the table appends. In the example, the structure is named ZST_MM_INCL_MSEG_MATDOC.
Step 2: Extend the MATDOC table
Anyone who works in the SAP GUI follows the familiar route via the SE11. An append structure can be created in the ADT using the context menu for the table in the Project Explorer.
In the example, ZZA_MATDOC has been chosen as the name for the append structure. The definition is quite clear:
The append can be activated now.
Step 3: Extend table MSEG
The MSEG is extended in the same way as the MATDOC table by using an append structure. The name of the append should not exceed 14 digits, otherwise there will be problems with the extension of the CDS view: The maximum length of the name of a table in the ABAP Dictionary is 16 characters. The name of the append is extended by “_V” in the Extension View, which means that there are only 14 digits available for the actual name.
In the example, “ZZA_MSEG” has been used as the name:
If the append is activated at this time, this would lead to errors. Subsequent accesses to the MSEG table inevitably result in a dump. You should, therefore, wait until the activation.
Step 4: Extend CDS view
An extension of CDS views is possible without modification via the so-called “extension views”. This has now been created for the substitute object in table MSEG. It is important to pay attention to the naming. There are three for each object:
• Name of the DDL source
• Name of the view at database level
• Name of the view in the ABAP Dictionary
For our example, the names can be found in the following table:
Object DDL-Source Database Dictionary
CDS View NSDM_DDL_MSEG NSDM_E_MSEG NSDM_V_MSEG
Extension View ZZA_MSEG_DDL ZZA_MSEG_E ZZA_MSEG_V
CDS objects can only be created in the ABAP Development Tools (Eclipse).
Step 4.1: Create a new object
Press Ctrl + N and select the entry “Data Definition” under “ABAP à Core Data Services”. The list of object types can be restricted by using a filter condition, so they can be shortened.
Step 4.2: Enter name, description and package
Step 4.3: Select transport order
Attention: If you exit the dialog via “Enter”, the wizard will be closed and you will be redirected to the editor. However, there is a template for creating an extension view that can be used here. Make sure you continue with “Next>”!
Step 4.4: Select template
Select the “Extend View” template, complete the wizard with “Finish”.
Step 4.5: adjust template code
The DDL source already contains the correct keywords for extending a CDS view. You only need to enter the appropriate names (see table above) and the fields.
Finally, the Extension View and the MSEG-append are activated. There should not be any activation errors! In particular, there should be none that are related to the representative object NSDM_E_MSEG.
The table MSEG has now been extended to include a customer field and nothing stands in the way of displaying it in the data browser or in the material bookings.
Further help on the MSEG topic
There are some tips that highlight the problem and provide assistance in the SAP support portal:
Problems with the customer includeCI_COBL. At least for upgrade projects!
I believe that concludes today’s lesson.