How to backup custom code with gCTS
In an average customer SAP ERP system, a large part of custom code is never executed in the production. Therefore, while converting your system to SAP S/4HANA it is crucial to identify and remove unused custom code in order to save your costs for its adaptation and future maintenance.
Custom Code Migration app can identify obsolete custom code based on uploaded usage data, store it in the deletion transport on your SAP ERP system, and during system conversion to SAP S/4HANA this deletion transport can be removed from the system (see the blogs Custom code analysis for SAP S/4HANA with SAP Fiori App Custom Code Migration for more details about the Custom Code Migration app and ABAP Call Monitor (SCMON) – Analyze usage of your code on how to collect usage data).
If you have concerns about deleting unused code, because you think, that you may need it at a later point of time, a downsized production or development system for backup of your unused code might be a solution. However, it is associated with costs and effort since you would need to set up and maintain an additional system in your landscape only for backup purposes.
That’s why we decided to offer the much better option to backup and possibly restore your unused code – backup with gCTS.
The idea behind that is as following. During SAP S/4HANA system conversion you don’t remove your unused custom code. Instead of this, after the system conversion, you create an external Git repository, enable Git-enabled Change and Transport System (gCTS) and configure a Git repository on your converted SAP S/4HANA system to create a connection between your SAP S/4HANA system and this external Git repository. Finally you transfer the objects from your deletion transport to the external Git repository. Your backup of unused custom code is ready, and you can remove the unused objects of the deletion transport from your SAP S/4HANA system.
How to import individual objects from Git repository to your SAP S/4HANA system
Just imagine, that using gCTS you have created the backup for your unused objects as a Git repository:
and deleted these objects from your SAP S/4HANA system.
Now you want to import some objects from the backup back into your SAP S/4HANA system, for example domain ZFILEPATH and data element ZFILEPATH:
On your SAP S/4HANA system these objects don’t exist anymore, since you removed them after creating the backup:
If you want to import these individual objects you can use the corresponding API, which takes as parameters your repository ID (as configured in gCTS UI) and the list of objects, you want to import. Here is the code snippet containing the API usage example:
data(request) = value cl_cts_abap_vcs_repo_facade=>ty_deploy_repository_request( repository = 'myRepositoryId' " Enter your repository ID (as configured in gCTS UI) here scope = 'CUSTOM' objects = value #( " List all objects you want to deploy from the repository into your ABAP system here: ( pgmid = 'R3TR' type = 'DOMA' object = 'ZFILEPATH' ) ( pgmid = 'R3TR' type = 'DTEL' object = 'ZFILEPATH' ) ) ). data(response) = cl_cts_abap_vcs_repo_facade=>deploy_repository( request = request ).
To use this API you need to implement the SAP Note 3084108 on your SAP S/4HANA >=2020 system.
After executing it domain ZFILEPATH and data element ZFILEPATH get imported into the SAP S/4HANA system and are available again: