
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.
This can now be done using transaction ACO_PROXY.
- 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
3444292 - ACO Proxy creates unnecessary shadow types. - SAP for Me
3457580 - SAP ACO - Duplicate Types for Table Parameters - SAP for Me
3518177 - SAP ACO Proxy Improvements - SAP for Me
3519098 - F4: fix function module value help - SAP for Me (only relevant for SAP S/4 HANA 2023)
The transaction ACO_PROXY now allows to generate a wrapper class, an C1-interface and a C1-released factory class which is the recommended approach (see the tutorial above). The C1 released factory class can then be used to intantiates the wrapper class being used in your ABAP Cloud coding.
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.
First you have to start transaction ACO_PROXY.
As described in the above mentioned tutorial the approach of using an interface and a factory class is the recommended one.
When you press the green check mark or press F8 you continue to the dialogues that allow you to de-select optional parameters from being used in the public interface of your wrapper class.
You can continue to the dialogue for the next function module by pressing the green check mark in the upper left corner of the SAPGUI screen.
Finally the generation starts.
The objects can then be checked in the target package.
When you check the code of the public method you see that the private method is called with the de-selected optional parameters being commented out so that they can easily be added afterwards back to the public interface if you wish to do so.
Last not least you can check that the interface and the factory class have been C1-released.
Hope this will help to speed up the process of creating wrappers for non-released function modules.
The wrapper class in the sample shown above can be called as follows (see below) and would produce an out put as follows:
CLASS zcl_bapi_wrap_test_009 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_bapi_wrap_test_009 IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA pr_returns TYPE bapirettab.
DATA prheader TYPE zaf_if_pr_bapi_009=>bapimereqheader .
DATA prheaderx TYPE zaf_if_pr_bapi_009=>bapimereqheaderx .
DATA number TYPE zaf_if_pr_bapi_009=>banfn .
DATA pritem TYPE zaf_if_pr_bapi_009=>_bapimereqitemimp .
DATA pritemx TYPE zaf_if_pr_bapi_009=>_bapimereqitemx .
DATA prheaderexp TYPE zaf_if_pr_bapi_009=>bapimereqheader .
DATA(myclass) = zaf_cl_f_pr_bapi_009=>create_instance( ).
prheader = VALUE #( pr_type = 'NB' ).
prheaderx = VALUE #( pr_type = 'X' ).
pritem = VALUE #( (
preq_item = '00010'
plant = '1010'
acctasscat = 'U'
currency = 'EUR'
deliv_date = cl_abap_context_info=>get_system_date( ) + 14 "format: yyyy-mm-dd (at least 10 days)
material = 'ZPRINTER01'
matl_group = 'A001'
preq_price = '100.00'
quantity = '1'
unit = 'ST'
pur_group = '001'
purch_org = '1010'
short_text = 'ZPRINTER01'
) ).
pritemx = VALUE #( (
preq_item = '00010'
plant = 'X'
acctasscat = 'X'
currency = 'X'
deliv_date = 'X'
material = 'X'
matl_group = 'X'
preq_price = 'X'
quantity = 'X'
unit = 'X'
pur_group = 'X'
purch_org = 'X'
short_text = 'X'
) ).
TRY.
myclass->bapi_pr_create(
EXPORTING
prheader = prheader
prheaderx = prheaderx
_dest_ = 'NONE'
IMPORTING
number = number
prheaderexp = prheaderexp
CHANGING
pritem = pritem
pritemx = pritemx
)
.
CATCH cx_aco_application_exception cx_aco_communication_failure cx_aco_system_failure INTO DATA(call_wrapper_exception).
"handle exception
out->write( |Exception occured: { call_wrapper_exception->get_text( ) }| ).
ENDTRY.
out->write( |purchase requistion number: { number } | ).
LOOP AT pr_returns INTO DATA(bapiret2_line).
out->write( |bapi_return: { bapiret2_line-message } | ).
ENDLOOP.
ENDMETHOD.
ENDCLASS.
How to find SAP APIs for SAP S/4HANA 3-tier extens... - SAP Community
In future the idea is to offer the option to start 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 |
---|---|
29 | |
26 | |
23 | |
19 | |
19 | |
15 | |
14 | |
13 | |
9 | |
8 |