the following is a valid statement?

Refer to the exhibit.

The class zcl_demo_class is in a software component with the language version set to "Standard ABAP". The function module "ZF11 is in a software component with the language version set to "ABAP Cloud". Both the class and function module are customer created. Regarding line #6, which of

the following is a valid statement?
A . ‘ZF1’ can be called whether it has been released or not for cloud development.
B . ‘ZF1’ can be called via a wrapper that itself has been released for cloud development.
C . ‘ZF1’ can be called via a wrapper that itself has not been released for cloud development.
D . ‘ZF1’ must be released for cloud development to be called.

Answer: B

Explanation:

The function module ZF1 is in a software component with the language version set to “ABAP Cloud”. This means that it follows the ABAP Cloud Development Model, which requires the usage of public SAP APIs and extension points to access SAP functionality and data. These APIs and extension points are released by SAP and documented in the SAP API Business Hub1. Customer-created function modules are not part of the public SAP APIs and are not released for cloud development. Therefore, calling a function module directly from a class with the language version set to “Standard ABAP” is not allowed and will result in a syntax error. However, there is a possible way to call a function module indirectly from a class with the language version set to “Standard ABAP”:

Create a wrapper class or interface for the function module and release it for cloud development. A wrapper is a class or interface that encapsulates the function module and exposes its functionality through public methods or attributes. The wrapper must be created in a software component with the language version set to “ABAP Cloud” and must be marked as released for cloud development using the annotation @EndUserText.label. The wrapper can then be called from a class with the language version set to “Standard ABAP” using the public methods or attributes2.

For example, the following code snippet shows how to create a wrapper class for the function module ZF1 and call it from the class zcl_demo_class:

@EndUserText.label: ‘Wrapper for ZF1’ CLASS zcl_wrapper_zf1 DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. CLASS-METHODS: call_zf1 IMPORTING iv_a TYPE i iv_b TYPE i EXPORTING ev_result TYPE i. ENDCLASS.

CLASS zcl_wrapper_zf1 IMPLEMENTATION. METHOD call_zf1. CALL FUNCTION ‘ZF1’ EXPORTING a = iv_a b = iv_b IMPORTING result = ev_result. ENDMETHOD. ENDCLASS. CLASS zcl_demo_class DEFINITION. METHODS: m1. ENDCLASS.

CLASS zcl_demo_class IMPLEMENTATION. METHOD m1. DATA(lv_result) =

zcl_wrapper_zf1=>call_zf1( iv_a = 2 iv_b = 3 ). WRITE: / lv_result. ENDMETHOD. ENDCLASS.

The output of this code is: 5

Reference: 1: SAP API Business Hub 2: Creating an ABAP Cloud Project | SAP Help Portal

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments