Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
christianjsosa
Participant
A common question from customers before migrating to S/4HANA is: How do I move my custom extension fields to the new landscape?

SAP encourages the use of Key User Extensions whenever possible[1]. In fact, many use cases are covered by this approach. There are, however, certain data structures that as of now (Feb. 2022) are not yet supported by Key User Extensions. The following is an analysis of one of such cases.

Requirement


The customer is planning their migration to S/4HANA, specifically their CRM module. One of their use cases involves adding custom fields to the identifications table (BUT0ID) of business partners. This is typically done by means of traditional Tools for WebClient UI and GUI (BDT[2], EEWB[3], AET[4]). These changes do not automatically impact on the Manage Business Partner Master Data Fiori App.

It is thus required to allow read and write functionality for these fields on the Fiori App.

Solution


Key User Extensions are disregarded as a possible solution since they are only available for certain Business Contexts[5] is available. Unfortunately, there is still no applicable Business Context provided by SAP for the identifications table (as of February 2022).

An SAP Note[6] on this exact topic “Extending BUT0ID table with Custom fields” states that the extension must be done manually but no further specifics are given.

Starting point



  • Stack: S/4HANA 2.0 On-premise

  • Fiori Application: Manage Business Partner Master Data[7] (App ID F3163)



Fiori App Manage Business Partner Master Data before extension




  • Database Tables already extended: BUT0ID + Extended Field



Extended table BUT0ID with the custom field



Extend the CDS-Views with the required Fields


According to documentation, the OData Service is MD_BUSINESSPARTNER_SRV, which can be used to locate the underlying CDS Views through Gateway Builder (transaction SEGW). These are:

  • I_BuPaIdentification (Interface View)


@AbapCatalog.sqlViewAppendName: 'ZCJ_BPID2'
@EndUserText.label: 'Extension of Z_I_BuPaIdentification'
extend view I_BuPaIdentification with ZCJ_I_BuPaIdentification {
but0id.zz_cx_idnumber2
}


  • I_BuPaIdentificationTP (Transactional View)


@AbapCatalog.sqlViewAppendName: 'Z_I_BUPAID2'
@EndUserText.label: 'Extension of I_BuPaIdentificationTP V2'
extend view I_BuPaIdentificationTP with Z_I_BuPaIdentificationTP_2
{
BPIdentification.zz_cx_idnumber2
}


  • C_BuPaIdentification (Consumption View)


@AbapCatalog.sqlViewAppendName: 'ZCBUPAIDENT_EXT'
@EndUserText.label: 'Extension of C BupaIdent'
extend view C_BuPaIdentification with ZC_BuPaIdentificationExt
{
@EndUserText.label: 'New Field'
BPIdentification.zz_cx_idnumber2
}

The reason why three views need to be extended is that the transactional view model. It requires that CDS views meant for OData exposition be organized in three levels (consumption, transactional and interface).

Activate CDS Views


Needed artifacts will then be generated and/or updated. Once this step is completed, you should already be able to display the new field in the Fiori App without any extra coding.


The custom field is already accessible from the App. Write access has not yet been implemented.


Since the field should be made editable as per requirement, it is necessary to implement the draft handling.

Extend the draft persistency table BUPA_ID_D


An extra field matching the newly created field on BUT0ID must be appended here as well.

After activating these changes, the Fiori app should already be able to save the draft in edit mode. For saving the draft to the active entry, more logic is needed.


Draft persistency table after custom field extension



Enhance the draft handling class CL_I_DR_BUSINESSPARTNERTP


Business Partners are modelled through a Business Object in SAP. This Business Object gets automatically generated by the standard CDS Views. This draft handling class is responsible for managing the draft lifecycle. In particular, saving draft changes to database is handled by its method COPY_DRAFT_TO_ACTIVE_ENTITY( ).

Depending on the SAP Standard logic, the recommendation is to enhance as less invasive as possible. This could be Pre, Post or Override Exit. To preserve the complex logic within COPY_DRAFT_TO_ACTIVE_ENTITY( ) and only afterwards execute the new custom code, a Post-Exit method was chosen.


Draft handling class enhancement



Implement the logic for saving the draft info to database


See sample code below. It should be noted, that certain non-trivial logic needs to be implemented here: consistency checking, draft validation, update type determination (creation, update or deletion). This demonstration does not include such logic.
  METHOD ipo_z_cj_test~copy_draft_to_active_entity.

READ TABLE it_draft_key INTO DATA(wa_draft) INDEX 1.

SELECT FROM bupa_id_d
FIELDS
mandt AS client,
businesspartner AS partner,
bpidentificationtype AS type,
bpidentificationnumber AS idnumber,
zz_cx_idnumber2,
" Mark the entry as an update
'U' AS kz
WHERE draftadministrativedatauuid = @wa_draft-key
INTO TABLE @DATA(lt_result).

" Assign draft data to the input table for BUP_BUPA_UPDATE
MOVE-CORRESPONDING lt_result TO it_t_but0id.

CALL FUNCTION 'BUP_BUPA_UPDATE'
TABLES
" Initialization of empty required tables was removed for clarity
t_but000 = it_t_but000
t_but000_td = it_t_but000_td
t_but000_td_old = it_t_but000_td_old
t_but001 = it_t_but001
t_but0bk = it_t_but0bk
t_but0bk_old = it_t_but0bk_old
t_but100 = it_t_but100
t_but100_old = it_t_but100_old
t_but0cc = it_t_but0cc
t_but0cc_old = it_t_but0cc_old
t_but0id = it_t_but0id
t_but0id_old = it_t_but0id_old
t_but0is = it_t_but0is
t_but0is_old = it_t_but0is_old.

IF sy-subrc EQ 0.

ENDIF.

COMMIT WORK.

ENDMETHOD.

Test the extension


The new field should now be available on the Fiori App Manage Business Partner Master Data including write functionality.

Takeaways



  • Since the App Manage Business Partner Master Data is based on Fiori Elements, no additional UI code was required. Display configs are handled completely through annotations.

  • For a general extensibility request, finding the right extensibility points can be a daunting task. This has been omitted on this article for clarity.

  • The current implementation was applicable to a specific App within the CRM Module. Although it has not been tested, this approach should be valid for other S4HANA Apps with a similar architecture:

    • Frontend characteristics

      • App built with Fiori Elements

      • Data-Source via BOPF-Object generated by a CDS-View

      • Draft handling enabled

      • Key User Extension not possible, for lack of Business Context



    • Backend characteristics:

      • CDS-View with generated BOPF Object

      • BOPF Object extensibility not available






Resources


The following resources were useful for arriving at this solution:

References


[1] Extensibility Explorer: https://extensibilityexplorer.cfapps.eu10.hana.ondemand.com/ExtensibilityExplorer/

[2] Business Data Toolset: https://help.sap.com/viewer/8e1936ace52649b28ef5dc48cafe30c6/latest/en-US/c4bf8d5377a0ec23e10000000a...

[3] Easy Enhancement Workbench: https://help.sap.com/viewer/2eb99edb9d99472d9afa587acddd7a7c/702%20SP20/en-US

[4] Application Enhancement Tool: https://help.sap.com/viewer/4aa273cf7f3a4ecea4a7cc3195e6164e/latest/en-US/3b18f8405201414ab5aa59fe3b...

[5] Business Context: https://help.sap.com/viewer/a1482918da994432859015bf1a083d9b/5_OVERVIEW/en-US/5c8209be60f34e3e9921f2...

[6] SAP Note "Extending BUT0ID table with Custom fields": https://launchpad.support.sap.com/#/notes/2554384

[7] Fiori App Manage Business Partner Master Data: https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer/#/detail/Apps('F3163')/S21OP

About the author

Christian Sosa is SAP Consultant at Q_PERIOR focusing on technology and innovation, currently working on end-to-end SAPUI5 development, test management and ABAP on HANA development.
Labels in this area