BTP - Transport ZLOCAL Objects
Would you like to bring your PoC in the ABAP environment to the next system? This article contains some more information.
Table of contents
In this article, we'll take a closer look at how we can get our Proof of Concept (PoC) from ZLOCAL into the next system track and what we should pay attention to. The question originally comes from Sebastian Freilinger-Huber.
Introduction
If you're using the ABAP Environment in the BTP for the first time, you'll probably create your Hello World in ZLOCAL. This is the temporary package ($TMP) in ABAP Cloud and on the ABAP Environment. Almost every ABAP developer gains their first experience in this package. Basically, you can create all kinds of objects there, and you will be asked to submit a transport request, which depends on the package settings.
Preparation
Before we start, we need a few objects to practice with. To do this, we will create two classes that are almost identical.
CLASS zcl_bs_demo_mypoc_one DEFINITION
PUBLIC FINAL
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS zcl_bs_demo_mypoc_one IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
out->write( `Shift me to a SWC (1)` ).
ENDMETHOD.
ENDCLASS.
We store the two classes in a package that was created under ZLOCAL, giving us the following structure in the system.
If we look at the package, we can see that it is not assigned to a transport layer and is assigned to the software component ZLOCAL.
Challenge
We have completed our PoC on the ABAP environment and now want to transport the objects. However, this is not possible because the objects have not been assigned to a software component (SWC). A software component creates a Git repository in the BTP in the background and all released transports are added as a commit. Each SWC has its own transport track, which is visible in the package and the transport. Objects created in ZLOCAL are also recorded in a transport, but releasing the transport does not generate a commit.
Solution
In this section we describe two solutions to the problem; you can also find further details in the SAP Help below. The aim is to create a package under the software component "ZBS_SWC_DEMO", which we have already used in an older article.
Change Package Assignment
In the first step, we carry out the standard function "Change Package Assignment" using the ABAP Development Tools. To do this, simply click on the corresponding object in the system and select the option from the context menu. select.
In the next step we specify the target package which is in the SWC and confirm the further dialogs.
It can happen, however, that you receive the following error. This is not very descriptive at first and you have to know exactly what to do.
If you receive the error, then the object is probably still stored in a transport with the wrong software component. This is the case when you have completed your PoC and are now considering how you can transport the objects. In this case, you have two options:
- Delete the object from the transport request to remove the lock
- Release the transport so that all locks are removed
If we have now removed the lock, the transport should be empty when the action is carried out. We can now create a new transport.
The action should now have been carried out successfully and the object should be in the new SWC. The transport now has the correct transport destination. You can then move the remaining objects into the component. In the SAP Help you will also find the information that packages cannot be moved and service bindings must be "unpublished" beforehand. With this variant you have to move each object manually; there is currently no mass activity.
abapGit
In the second variant we can use abapGit to save complete packages and make them available on another system. In principle the method also works in the same system, but you must first delete all objects that you have saved, otherwise the objects cannot be created again.
To do this, in the first step we create a Git repository and synchronize the objects with it. For this you need the abapGit Plugin for Eclipse. In the next step we link our repository.
In the next step we take the package to be backed up and define the branch we are working with. In most cases we will stay with the MAIN branch.
Now we can commit all the objects we want to backup and restore in the next step.
The objects are now synced with Git and we can move to the next system or clean up the current system. In this case we delete the object from the system and remove any further locks. Finally, we need to remove the project from the system using "Unlink".
After completing this step, we create a new link with our new package. We then perform a pull to synchronize the objects from Git with our system.
In the next dialogs, we ignore the objects that are already in the package and select the objects that are only available remotely. We also select the transport for the SWC or create a new one. After the objects have been successfully pulled, both classes should now have arrived in the new software component.
Recommendation
We also recommend using a software component for a PoC, as this offers the most flexibility. At the end of the PoC, you can then decide whether to put the SWC directly into the test or to delete it completely from the system. However, all objects must be consistent and all transports must be released so that the current status of the SWC is in the Git repository.
A software component is available in the global account so that it can easily be brought to different ABAP environments in the various sub-accounts. Management takes place via the Fiori app "Manage Software Components" (F3562).
Conclusion
If you have created your first project in ZLOCAL, that is no problem, you can simply transfer the objects to a software component. In the future, you can also simply create your PoCs directly in software components, as these can also be easily removed from the system or you can then put them into production straight away.
More information:
SAP Help - Changing the Package Assignment