Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Introduction

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.

RFC tier2 proxy generator

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

  • creates an interface and a factory class
  • moves part of the code generated by the API mentioned above to the interface
  • changes the code of the generated wrapper class to use the interface
  • C1-release the factory class and the interface

How to get the source code of the RFC tier2 generator

The source code of the RFC tier2 generator has been published in the following repository on Github.com

SAP-samples/tier2-rfc-proxy 

 

 

Prerequisites

- 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)

How to use the RFC tier2 generator

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, ...)

010_select_function_modules.png

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.

020_specify_options.png

When the reports finishes successfully it will list the generated repository objects.

030_result_report.png

The objects can then be checked in the target package.

040_generated_objects.png

Hope this will help to speed up the process of creating wrappers for non-released function modules.

ToDo's

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

SAP/abap-atc-cr-cv-s4hc: ABAP test cockpit cloud readiness check variants for SAP S/4HANA Cloud (git...

Future Outlook

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.    

 

 

9 Comments