Custom Code Adaptations due to re-introduction of field VBFA-STUFE Document Version Status Date 1.0 final April 06, 2018 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW Table of Content 1 Change Log 2 2 Data Model Changes 3 3 Introduction 3 Release dependency of VBFA-STUFE and indirect relationships 4 Adaptation of Customer Code 6 Coding Adaptation - Examples 6 3.1.1 Direct SELECT on VBFA, context are only direct relationships 6 3.1.2 Filter STUFE EQ ‘0’ in reading an internal table with line type VBFA 6 3.1.3 SELECT on VBFA for direct relationships, method call for indirect relationships 6 3.1.4 Structures containing VBFA as Include 7 3.1.5 Usages of structure VBFAD 8 © 2018 – SAP SE 1 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW 1 Change Log Version Date Change 1.0 2018-04-06 Initial version © 2018 – SAP SE 2 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW 2 Data Model Changes Introduction Note 2267306 (Business Impact Note) describes the general data model changes in SD. Among these general data model changes there are changes to the document flow table VBFA. As indicated in the long text description of note 2470721 the indirect relationships in the SD document flow table VBFA are handled differently in the early releases of S/4HANA (1511 and 1610). In the initial releases of S/4HANA table VBFA only contains direct relationships and field STUFE is missing in VBFA. Later VBFA-STUFE is re-introduced and indirect relationships are stored again (see chapter 2.2 for details). Note 2198647 contains cookbooks describing necessary code adaptations of custom code in S/4HANA due to the SD data model changes. The cookbook for VBFA in note 2198647 describes which changes related to VBFA are necessary, depending on the release and SP level of the S/4HANA system. The current document/cookbook (attachment to note 2470721) describes which changes to custom code are necessary if the custom code related to VBFA was created in 1511/1610 when indirect relationships were not stored in table VBFA. The current cookbook applies for all systems where - the customer has started a new installation on SAP S/4HANA 1511 or 1610 without VBFA-STUFE, and has implemented own coding in S/4HANA Or - the customer had performed a system conversion earlier with target release 1511 or 1610 without VBFASTUFE, and has adapted custom code to the stack without VBFA-STUFE. In general, a rule of thumb for system conversion without VBFA-STUFE is: All Coding which was adapted based on the simplifications for table VBFA and where the reason of the adaptation was the removal of VBFA-STUFE has to be checked and in many cases reverted back to the original logic as in SAP ERP. This does not affect all VBFA-related code changes but only those where the reason was VBFA-STUFE. Code changes due to the primary key change (RUUID instead of semantical key fields) as described in the cookbook of note 2198647 are not affected by VBFA-STUFE. These code changes need to be kept. If the customer system is undergoing a system conversion from SAP ERP to S/4HANA then the VBFA cookbook of note 2198647 shall be applied. The updated version of the VBFA cookbook in note 2198647 describes the necessary changes and explains the dependencies to VBFA-STUFE and to indirect relationships in VBFA. © 2018 – SAP SE 3 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW Release dependency of VBFA-STUFE and indirect relationships As indicated in the long text description of note 2470721 the indirect relationships in the SD document flow table VBFA are handled differently in the early releases of S/4HANA: In the Simplifications for S/4HANA, the field STUFE had been removed from the database table VBFA. In the initial releases of S/4HANA: • • • only direct relationships are stored in VBFA indirect relationships are not stored in VBFA indirect relationships are deleted in the S/4HANA conversion The field STUFE is introduced again and indirect relationships are stored again in table VBFA as of the following releases and SP levels: • • • • • 1709 (SP00) 1610 SP02 = FPS2 (feature pack stack 2) 1511 SP04 Via correction instructions of note 2418242 in 1610 SP00/SP01 Via correction instructions of note 2418242 in 1511 SP00/SP01/SP02/SP03 A reconstruction of missing indirect docflow entries (“VBFA reconstruction”) is necessary in the following cases: • • • • New installation on 1610 SP00/SP01/SP02 or New installation on 1511 SP00/SP01/SP02/SP03/SP04 System conversion from SAP ERP to 1610 SP00/SP01 or System conversion from SAP ERP to 1511 SP00/SP01/SP02/SP03 A reconstruction of VBFA is not necessary in the following cases: • • • • • • New installation on 1709 or higher release New installation on 1610 SP03 or higher SP level New installation on 1511 SP05 or higher SP level System conversion from SAP ERP to 1709 or higher release System conversion from SAP ERP to 1610 SP02 or higher SP level System conversion from SAP ERP to 1511 SP04 or higher SP level The upgrade to 1709 from 1511 or 1610 can only happen if the reconstruction of missing indirect docflow entries has been executed before the upgrade. This is enforced by a so-called SI check (Simplification Item check) that is executed in the upgrade preparation to 1709. Report /SDF/RC_START_CHECK shows a red traffic light for Simplification item “SI21: SD_VBFA_STUFE” if the VBFA reconstruction is missing. Note 2418242 describes the steps that are recommended for VBFA reconstruction. © 2018 – SAP SE 4 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW Hence as of 1709 the field VBFA-STUFE and the indirect relationships have the same functionality and the same persistence like in SAP ERP. In 1610 and in 1511 it depends on the SP level and the system history whether indirect relationships are persisted like in SAP ERP. For the custom code changes the needed adaptations depend on the release/SP level of the S/4HANA system. For better readability of the examples in this cookbook we will use the following notation: • • • • “After VBFA reconstruction” stands for “VBFA-STUFE is available and indirect relationships are completely persisted in VBFA”. “Before VBFA reconstruction” stands for “Indirect relationships may not be completely persisted in VBFA”. “After re-introduction of field VBFA-STUFE” means that the field exists in the database table, but indirect relationships may or may not be completely persisted in table VBFA. “Without field VBFA-STUFE” means that the field does not exist in the database table, and therefore also no indirect relationships are persisted. © 2018 – SAP SE 5 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW 3 Adaptation of Customer Code Coding Adaptation - Examples In most cases, adapting source code requires some knowledge about the business process and the different possible use cases which can occur. 3.1.1 Direct SELECT on VBFA, context are only direct relationships A direct SELECT on VBFA is performed. Without reconstructed VBFA this SELECT has only returned direct relationships. The field STUFE is not part of the WHERE clause because the field did not exist when the coding was created. In order to get the same result set (only direct relationships) it is necessary to add a where clause for VBFASTUFE = ‘00’. The new coding works correctly as soon as VBFA-STUFE is back, independent of the VBFA reconstruction. Old: SELECT * FROM vbfa INTO CORRESPONDING FIELDS OF TABLE LT_VBFA WHERE vbelv = i_vbeln AND posnn NE '000000'. New: SELECT * FROM vbfa INTO CORRESPONDING FIELDS OF TABLE LT_VBFA WHERE vbelv = i_vbeln AND posnn NE '000000' AND stufe = '00' General and release-independent: It is recommended to call method GET_SUCCESSORS of class CL_SD_DOCUMENT_FLOW_RT, with IV_PATH_LENGTH = ‘1’. This method call works independently from the release level in all S/4HANA systems. 3.1.2 Filter STUFE EQ ‘0’ in reading an internal table with line type VBFA Similar to example 1, VBFA entries may be processed in an internal table. If the internal table is the result of a SELECT on VBFA without a filter on STUFE EQ ‘0’ then the table will contain more entries after the VBFA reconstruction (in addition also indirect relationships). It might be necessary to add a check on the value of the field STUFE when the entries of the internal table are processed. If only direct relationships shall be processed, only rows with STUFE EQ ‘0’ have to be taken into account. Alternatively, the filter can be implemented directly as part of the where clause of the SELECT statement (see example 1). You can always use the methods of class CL_SD_DOCUMENT_FLOW_RT, they work in all S/4HANA releases and take care internally for the right way to perform the selections. 3.1.3 SELECT on VBFA for direct relationships, method call for indirect relationships Old coding in 1511/1610 without VBFA-STUFE: © 2018 – SAP SE 6 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW A SELECT on VBFA is performed which reads direct relationships (without where clause for STUFE). In order to get additionally all indirect relationships the methods GET_SUCCESSORS / GET_PREDECESSORS of class CL_SD_DOCUMENT_FLOW_RT are called. The result set of the method is filtered by the consuming program to avoid duplicate direct relationships. New coding: After VBFA reconstruction the SELECT on VBFA without where clause for STUFE also returns indirect relationships. In order to avoid duplicate indirect relationships in the overall result set only the result set of the methods GET_SUCCESSORS / GET_PREDECESSORS of class CL_SD_DOCUMENT_FLOW_RT shall be considered. The method calls are in general sufficient to retrieve all relationships (in all S/4HANA releases). Before VBFA reconstruction there is some performance overhead for the on-the-fly calculation of the indirect relationships. As soon as VBFA reconstruction is done this performance overhead is eliminated. The methods also get all relationships directly from the persisted records in VBFA. 3.1.4 Structures containing VBFA as Include There are several structures in the SAP standard which contain VBFA as an Include, e.g. VBFAVB, VBFAS, SALES_XVBFA_DOCUMENTFLOW or MCVBFA. When STUFE was removed from VBFA the field STUFE was added as a separate field to these structures. When STUFE was reintroduced in VBFA the SAP standard structures were adapted: The separate field STUFE in the SAP standard structures VBFAVB, VBFAS, SALES_XVBFA_DOCUMENTFLOW or MCVBFA has been removed again. For the overall structures, the following fields can be used in any S/4HANA release: 1. 2. 3. 4. VBFAVB-STUFE VBFAS-STUFE SALES_XVBFA_DOCUMENTFLOW-STUFE MCVBFA-STUFE There is no adaptation of custom coding needed where custom coding uses these field names. The following field name does only exist before the re-introduction of VBFA-STUFE: VBFAVB-_D-STUFE The include VBFAD has the group name “_D” in the data dictionary. Custom coding which addresses the field STUFE via the group name of include VBFAD must be adapted. The same pattern can occur for custom structures in 1511 or 1610: The structure includes VBFA and contains an additional separate field STUFE. In that case the field STUFE occurs twice after it has been added to VBFA again. Custom structures containing VBFA as Include which in addition contain a separate field STUFE must be adapted: The field STUFE must be removed. Coding referring to the structure field STUFE is usually not affected, only if the field STUFE was part of an Include with a group name, and the coding addressed the field via the group name. © 2018 – SAP SE 7 DATA MODEL CHANGES REGARDING SD DOCUMENT FLOW 3.1.5 Usages of structure VBFAD Structure VBFAVB is the Reference Structure for internal tables XVBFA/YVBFA which are used in the standard SAP programs internally for processing DocFlow-related information. Structure VBFAVB consists of two includes: .INCLUDE VBFA Sales Document Flow .INCLUDE VBFAD Document Flow: Dynamic Part In SAP ERP the field STUFE was contained in the include VBFA In the beginning of S/4HANA (1511/1610, lower SP levels) the field STUFE is contained in the include VBFAD. With the re-introduction of field STUFE in table VBFA the field is removed from structure VBFAD. Custom coding referencing field VBFAD-STUFE needs to be adapted. Typically, direct consumption of structure VBFAD may not be needed, and the reference structure VBFAVB could be used instead. © 2018 – SAP SE 8