CRM Table Changes For S4 HANA - Coding Impact
CRM Table Changes For S4 HANA - Coding Impact
Architecture Team
S/4HANA Service Software Design Description
Management
SELECT Statements on
Business Transaction Tables
in Custom Code: Migration
from CRM 7.0 to S4CRM
Contents
1 Introduction and General Remarks ________________________________________ 3
2 Accesses to Business Transaction Data ___________________________________ 3
2.1 General Remarks ___________________________________________________________ 3
2.2 Basic Principles of the Persistency Redesign ____________________________________ 3
2.3 Analysis of SELECT Statements _______________________________________________ 4
2.4 Determination of Header/Item Table ____________________________________________ 5
2.4.1 Unknown business object type _______________________________________________ 5
2.4.2 Known business object type _________________________________________________ 5
2.5 Renamed and Unsupported Fields _____________________________________________ 5
2.6 Special Cases ______________________________________________________________ 5
2.6.1 Shadow Tables ___________________________________________________________ 5
2.6.2 SELECT Statements Involving CRMD_ORDER_INDEX ___________________________ 6
2.6.3 Selection of Partners on Item Level ___________________________________________ 6
2.7 Examples _________________________________________________________________ 7
3 Technical Details ______________________________________________________ 9
3.1 Extensions and Sets ________________________________________________________ 9
3.2 List of New Complex Tables _________________________________________________ 11
3.3 List of Renamed Fields _____________________________________________________ 11
3.4 New Partner, Status and Appointment Fields ___________________________________ 12
3.4.1 Partner Fields ___________________________________________________________ 12
3.4.2 Status Fields ____________________________________________________________ 12
3.4.3 Appointment Fields _______________________________________________________ 13
3.5 List of Fields in CRMD_ORDER_INDEX ________________________________________ 14
This document describes the required changes in custom code that accesses business transaction data
via direct SELECT statements on the underlying database tables. These adaptations are necessary
since the persistency of CRM business transactions has been redesigned, resulting in new database
tables.
Disclaimer: SAP does not guarantee that the information contained, especially the lists in section 3, is
complete and 100% error-free. Corrections and enhancements might be performed in future versions of
this document.
1. For each object type (aka business transaction category, entity table CRMC_SUBOB_CAT),
there is one database table for the header. Likewise, for each item object type (entity table
CRMC_SUBOB_CAT_I), there is one database table for the item. Some header or item object
types are combined in a common table. The assignment of the database table to a business
object is accomplished through the so-called acronym which is a four-character abbreviation of
the business object. This relation is stored in table CRMS4C_ACRONYM. The names of the
new database tables follow the naming convention CRMS4D_<acronym>_H for the header
tables and CRMS4D_<acronym>_I for the item tables. The key of the new tables consists of:
• header object type + header object ID for the header table, and
• header object type + header object ID + item number for the item table.
The (header/item) GUID is still available in the data part of the table.
2. Simple header extensions (i.e., those with a 1:1 correspondence to the header, for example
SERVICE_H) are completely integrated into the header table, i.e., the fields are genuine part of
the new table. Similarly, simple item extensions (for example, PRODUCT_I) are integrated into
the item table. There is no separate database table any more for a simple extension.
3. For a simple set (for example, SHIPPING), the fields are appended both to the header and the
item table. This means that each item has its own set of, e.g., shipping attributes. There is no
link handler or set logic any longer for these sets.
4. A selected set of header attributes (those which are relevant in queries or analytical
applications) is redundantly included in the item table, in order to avoid an expensive JOIN
operation between header and item table.
5. Complex sets and extensions (i.e., those with a 1:n relationship to header or item) usually
remain in a separate table (one exception: CUMULATED_I). However, two simplifications are
performed:
• Selected records from certain complex components are extracted as individual fields to
the header and/or item table, because these are frequently used in queries or analytical
applications. This applies, in particular, to the sets PARTNER, STATUS and
APPOINTMENT. For example, there are individual fields for the sold-to and ship-to
party, the life cycle and the billing status, or the contract start and end date. These fields
are redundant, i.e., the complete set of partners, statuses, dates, etc. is still available in
an extra database table.
• The key structure of the separate tables for the complex components is
changed. Instead of a single record GUID, the key of a header or item extension now
consists of the key fields of the header or item table, plus additional key fields. Similarly,
the key of a new set table contains the key of the item table, plus additional key fields.
Records which belong to the header have an initial item number. The link handler (table
CRMD_LINK) is not used any longer.
Note: This does not apply to components which use a database table from a lower
software layer. In particular, the persistence of the segments APPOINTMENT,
STATUS, TEXT is unchanged.
An overview over the tables for the complex components in the new data model is given in
section 3.2.
The shadow tables can be viewed as reduced versions of the original root tables
CRMD_ORDERADM_H and CRMD_ORDERADM_I. They contain only the very basic attributes and
mainly serve to determine the business object type from the GUID.
lv_table_name =
cl_crms4_acronym_cb=>get_table_name( lv_object_type ).
SELECT … FROM (lv_table_name) WHERE …
Fields which are neither contained in the new database tables, nor in the list of renamed fields, are not
supported in S4CRM 2.0. This applies, for example, to the database field CRMD_ORDERADM_H-
SCENARIO.
Regarding the partner fields, the logic of CRMD_ORDER_INDEX was that the partner function category
is indicated by the field PFT_nn, where nn is the number of the partner function category (according to
table CRMC_PARTNER_PFT), and the partner number is contained in field PARTNER_NO. In the new
design, dedicated fields are available for the individual partner function categories. The correspondence
is given in the list in section 3.5. Those fields PFT_nn which are not listed in the table have no
counterpart in one of the flat tables. In this case, a JOIN with CRMS4D_PARTNER is required. Example
3 in section 2.7 illustrates the new logic.
Finally, another two frequently used fields from CRMD_ORDER_INDEX are the two date fields DATE_1
and DATE_2. These two fields capture the most important business object specific dates. The
calculation differs from object type to object type. Section 3.5 contains a table with the detailed logic and
the correspondence to the new database tables.
2.7 Examples
Example 1: This example shows how a SELECT statement involving three different tables can be
simplified in S4CRM. At the same time, it demonstrates how the keyword AS can be utilized for renamed
fields in order to keep the internal table definitions stable.
SELECT a~guid
a~header
a~product
a~ordered_prod
a~description
b~process_qty_unit
c~net_value
c~net_value_man
FROM crmd_orderadm_i AS a
LEFT JOIN crmd_product_i AS b ON a~guid = b~guid
LEFT JOIN crmd_pricing_i AS c ON a~guid = c~guid
INTO CORRESPONDING FIELDS OF TABLE lt_item
FOR ALL ENTRIES IN lt_header WHERE header = lt_header-guid.
Example 2: If a JOIN operation with a complex component is required, it is no longer necessary to use
the link handler as intermediate table. The following code is taken from the “end of purpose” check for
business partners:
SELECT
p~partner_no AS partner_no
h~guid AS object_guid
FROM crmd_orderadm_h AS h
INNER JOIN crmd_link AS l ON l~guid_hi = h~guid
INNER JOIN crmd_partner AS p ON p~guid = l~guid_set
INTO CORRESPONDING FIELDS OF TABLE lt_pguid_oguid
WHERE p~partner_no IN it_partner_range.
SELECT
p~partner_no AS partner_no
h~guid AS object_guid
FROM crms4d_btx_h AS h
INNER JOIN crms4d_partner AS p
ON h~objtype_h = p~objtype_h AND
h~object_id = p~object_id
INTO CORRESPONDING FIELDS OF TABLE lt_pguid_oguid
WHERE p~partner_no IN it_partner_range
AND p~number_int = '000000'.
Example 3: It is shown how the logic of the PFT_nn fields from CRMD_ORDER_INDEX can be carried
over to the new database tables. The code is taken from the selection of service order or confirmation
items which need to be released for billing. Note that the semantics of the billing status has changed in
S4CRM:
SELECT item
INTO CORRESPONDING FIELDS OF TABLE lt_guid_idx_i
FROM crmd_order_index
FOR ALL ENTRIES IN lt_guid_adm_h
WHERE header = lt_guid_adm_h-guid
AND object_type IN lr_obj_type
AND partner_no IN impt_partno
AND service_org IN impt_srv_oe
AND stat_bill = 'X'
AND pft_1 = 'X'.
Example 4: This code is take from the archiving preprocessing program. Here, a dynamic SELECT
statement must be used since the code covers all possible business object type. At the same time, JOIN
operations with the status table CRM_JEST can be avoided thanks to the incorporation of statuses in
the header tables.
3 Technical Details
3.1 Extensions and Sets
For convenience, we are providing the list of sets and extensions within the One Order model which
are relevant in S4CRM 2.0. The brief explanation in column “Role in S4CRM” means:
• “Absorbed”: The component has been integrated into the new header/item table(s). There is
no separate database table any more for this component.
• “Unchanged”: The persistence of these components is unchanged with respect to CRM 7.0.
In case there is a new database table for the component, the name of the database table is given.
Some components require special explanations:
D Lost I1028
E Completed I1005
STAT_RELEASED Release status <space> Not released I1004
X Released
STAT_QUOTATION Quotation status <space> Order I1055
X Quotation
STAT_ERROR Error status <space> No errors I1030
X Contains errors
STAT_DELIVERY Delivery status <space> Not relevant
A Not delivered
B Partially delivered I1421
C Completely delivered I1137
STAT_GOODS_ISSUE Goods issue status <space> Not relevant
A Not goods issued
B Partially goods issued I1422
C Completely goods I1423
issued
STAT_BILLING Billing status <space> Not relevant
A Not billed
B Partially billed I1431
C Completely billed I1073
STAT_FOR_BILLING Billing release <space> Not released for billing I1094
status X Released for billing
STAT_ARCHIVABLE Archivable <space> Not archivable I1100
X Archivable
STAT_ARCHIVED Archived <space> Not archived I1101
X Archived
STAT_CANCELLED Cancellation status <space> Not cancelled I1032
X Cancelled
STAT_CHKLST_EXEC Execution Status of A Not to be executed I1391
Checklist Item B Execution in progress I1393
C Executed I1394
STAT_DUPLICATE Duplicate Status Y Duplicate I1098
N No Duplicate
STAT_ACCEPTED Acceptance Status Y Accepted I1079
N Not accepted
STAT_NOTIF_REQUIRED Lead Deduplication Y Notification required I1930
Notification N Notification not required
Required
STAT_OPEN Not completed <space> Completed I1005
X Open (reverse)
For convenience, the table below explains the logic how the two date fields DATE_1 and DATE_2 are
filled. Typically, they are populated from a dedicated appointment type, sometimes from a special
database field or through some piece of extra logic. In the first case, the appointment type is given in
the second column.