In a tutorial Implement a Wrapper for the "Create Purchase Requisition" (BAPI_PR_CREATE) function module that was published recently it was shown how to deal with the case in which no convenient released API is available to create purchase requisitions.
The question that came to my mind was whether there would be a way to automate the steps described in this tutorial so that creating wrappers for other BAPIs would become more easy.
So I did some investigation and have build a prototype of such a wrapper that it based on the same framework as the transaction ACO_PROXY.
This transaction is already available for quite some time and can be used to generate a wrapper class for one or more function modules.
In order to leverage the generated code it would however be necessary to perform several manual steps to adapt the same. Since these steps can be automated I have build a helper class and a helper report that perform these tasks for your convenience.
The RFC tier2 proxy generator is based on the same API that is used by the transaction ACO_PROXY which is described in the following tutorial. This transaction allows to generate a wrapper class for one or more function modules. The code can however not be used immediately since it contains a few statements that need to be adjusted (e.g. CLASS-METHODS statements and CALL DESTINATION _dest_ statements).
The transaction ACO_PROXY and its underlying API now also check if a data element that is used by a non released function module itself has been released. If this is the case, no shadow type will be generated.
The recommended approach (see the tutorial above) is also to use a C1-released interface and a C1-released wrapper class that intantiates the wrapper class being used in your ABAP Cloud coding.
So I developed a class that calls the same API
cl_aco_static_proxy=>create_static_proxy_by_rfc(
EXPORTING
function_names = i_function_modules
proxy_name = i_proxy_class_name
destination_name = 'NONE'
devclass = i_package_name
trkorr = i_transport_request
classic_exceptions = abap_false
bapi_exceptions = abap_false
generate_inactive = abap_false
destination_by_constructor = abap_false
do_not_create_released_type = abap_true
).
and which in addition
The source code of the RFC tier2 generator has been published in the following repository on Github.com
- You have to have a system based on SAP S/4HANA 2022 or 2023 on premise.
- You have to have enabled Developer extensibility
- You have to apply the following notes
- [SAP Note 3444292 - ACO Proxy creates unnecessary shadow types](https://me.sap.com/notes/3444292)
- [SAP Note 3457580 - SAP ACO - Duplicate Types for Table Parameters](https://me.sap.com/notes/3457580)
When you have downloaded the class and the report simply start the report zr_gen_rfc_tier2_proxy.
Here you can select one or more function modules that will be wrapped by one single class.
(e.g BAPI_PR_CREATE, BAPI_PR_CHANGE, BAPI_PR_GETDETAIL, ...)
Now you have to specify additional parameters such as the target package where the wrapper objects are going to be generated.
Then there there are two radio buttons that allow you to choose between the generation of an interface, a wrapper class and a factoy class (option 1, recommended) or just one wrapper class (option 2).
As described in the above mentioned tutorial the approach of using an interface and a factory class is the recommended one.
Last not least you have to provide the names of the repository objects that will be generated.
When the reports finishes successfully it will list the generated repository objects.
The objects can then be checked in the target package.
Hope this will help to speed up the process of creating wrappers for non-released function modules.
What is left to do is to change the value help of the report such that only function modules can be selected that are marked as stable.
How to find SAP APIs for SAP S/4HANA 3-tier extens... - SAP Community
In future the idea is to provide such a generator as well in the ABAP development tools for Eclipse.
This will be possible with the next S/4HANA release and the ADT generator framework.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
20 | |
10 | |
8 | |
8 | |
7 | |
7 | |
7 | |
6 | |
6 | |
6 |