Practice Free C_ABAPD_2507 Exam Online Questions
What are the effects of this annotation? Note: There are 2 correct answers to this question.
- A . The value of sy-langu will be passed to the CDS view automatically both when you use the -1 CDS view in ABAP and in another CDS view entity (view on view).
- B . You can still override the default value with a value of your own.
- C . The value of sy-langu will be passed to the CDS view automatically when you use the CDS view in ABAP but not when you use it in another view entity
- D . It is no longer possible to pass your own value to the parameter.
A, B
Explanation:
The annotation @Environment.systemField: #LANGUAGE is used to assign the ABAP system field sy-langu to an input parameter of a CDS view or a CDS table function. This enables the implicit parameter passing in Open SQL, which means that the value of sy-langu will be automatically passed to the CDS view without explicitly specifying it in the WHERE clause. This also applies to the CDS views that use the annotated CDS view as a data source, which means that the value of sy-langu will be propagated to the nested CDS views (view on view)12.
For example:
The following code snippet defines a CDS view ZI_FLIGHT_TEXTS with an input parameter p_langu that is annotated with @Environment.systemField: #LANGUAGE:
define view ZI_FLIGHT_TEXTS with parameters p_langu: syst_langu @<Environment.systemField: #LANGUAGE as select from sflight left outer join scarr on sflight.carrid = scarr.carrid left outer join stext on scarr.carrid = stext.carrid { sflight.carrid, sflight.connid, sflight.fldate, scarr.carrname,
stext.text as carrtext } where stext.langu = :p_langu
The following code snippet shows how to use the CDS view ZI_FLIGHT_TEXTS in ABAP without specifying the value of p_langu in the WHERE clause. The value of sy-langu will be automatically passed to the CDS view:
SELECT carrid, connid, fldate, carrname, carrtext FROM zi_flight_texts INTO TABLE @DATA(lt_flights).
The following code snippet shows how to use the CDS view ZI_FLIGHT_TEXTS in another CDS view
ZI_FLIGHT_REPORT. The value of sy-langu will be automatically passed to the nested CDS view
ZI_FLIGHT_TEXTS:
define view ZI_FLIGHT_REPORT with parameters p_langu: syst_langu @<Environment.systemField: #LANGUAGE as select from zi_flight_texts(p_langu) { carrid, connid, fldate, carrname, carrtext, count(*) as flight_count } group by carrid, connid, fldate, carrname, carrtext
The annotation @Environment.systemField: #LANGUAGE does not prevent the possibility of overriding the default value with a value of your own. You can still specify a different value for the input parameter p_langu in the WHERE clause, either in ABAP or in another CDS view. This will override the value of sy-langu and pass the specified value to the CDS view12. For example:
The following code snippet shows how to use the CDS view ZI_FLIGHT_TEXTS in ABAP with a specified value of p_langu in the WHERE clause. The value ‘E’ will be passed to the CDS view instead of the value of sy-langu:
SELECT carrid, connid, fldate, carrname, carrtext FROM zi_flight_texts WHERE p_langu = ‘E’ INTO TABLE @DATA(lt_flights).
The following code snippet shows how to use the CDS view ZI_FLIGHT_TEXTS in another CDS view ZI_FLIGHT_REPORT with a specified value of p_langu in the WHERE clause. The value ‘E’ will be passed to the nested CDS view ZI_FLIGHT_TEXTS instead of the value of sy-langu:
define view ZI_FLIGHT_REPORT with parameters p_langu: syst_langu @<Environment.systemField: #LANGUAGE as select from zi_flight_texts(p_langu) { carrid, connid, fldate, carrname, carrtext, count(*) as flight_count } where p_langu = ‘E’ group by carrid, connid, fldate, carrname, carrtext
Reference: 1: ABAP CDS – parameter_annot – ABAP Keyword Documentation – SAP Online Help 2: ABAP CDS – session_variable – ABAP Keyword Documentation – SAP Online Help
In what order are objects created to generate a RESTful Application Programming application?
A) Database table 1
B) Service binding Projection view 4
C) Service definition 3
D) Data model view 2
- A . DABC
- B . BDCA
- C . ADCB
- D . CBAB
C
Explanation:
The order in which objects are created to generate a RESTful Application Programming application is A, D, C, B.
This means that the following steps are followed:
First, a database table is created to store the data for the application. A database table is a CDS DDIC-based view that defines a join or union of database tables. A database table has an SQL view attached and can be accessed by Open SQL or native SQL.
Second, a data model view is created to define a data model based on the database table or other CDS view entities. A data model view is a CDS view entity that can have associations, aggregations, filters, parameters, and annotations. A data model view can also define the behavior definition and implementation for the business object.
Third, a service definition is created to define the service interface for the application. A service definition is a CDS view entity that defines a projection on a data model view or another service definition. A service definition can also define service metadata, such as service name, version, description, and annotations.
Fourth, a service binding is created to define the service binding for the application. A service binding is a CDS view entity that defines a projection on a service definition. A service binding can also define the service protocol, such as OData V2, OData V4, or REST, and the service URL.
Reference: CDS Data Model Views – ABAP Keyword Documentation, CDS Service Definitions – ABAP Keyword Documentation, CDS Service Bindings – ABAP Keyword Documentation, CDS Projection Views – ABAP Keyword Documentation
Which of the following results in faster access to internal tables? Note: There are 3 correct answers to this question.
- A . In a sorted internal table, specifying the primary key partially from the left without gaps.
- B . In a sorted internal table, specifying the primary key completely.
- C . In a standard internal table, specifying the primary key partially from the left without gaps.
- D . In a hashed internal table, specifying the primary key partially from the left without gaps.
- E . In a hashed internal table, specifying the primary key completely.
B, D, E
Explanation:
The access to internal tables can be optimized by using the appropriate table type and specifying the table key. The table key is a set of fields that uniquely identifies a row in the table and determines the sorting order of the table. The table key can be either the primary key or a secondary key. The primary key is defined by the table type and the table definition, while the secondary key is defined by the user using the KEY statement1.
The following results in faster access to internal tables:
B. In a sorted internal table, specifying the primary key completely. A sorted internal table is a table type that maintains a predefined sorting order, which is defined by the primary key in the table definition. The primary key can be either unique or non-unique. A sorted internal table can be accessed using the primary key or the table index. The access using the primary key is faster than the access using the table index, because the system can use a binary search algorithm to find the row. However, the primary key must be specified completely, meaning that all the fields of the primary key must be given in the correct order and without gaps2.
D. In a hashed internal table, specifying the primary key partially from the left without gaps. A hashed internal table is a table type that does not have a predefined sorting order, but uses a hash algorithm to store and access the rows. The primary key of a hashed internal table must be unique and cannot be changed. A hashed internal table can only be accessed using the primary key, not the table index. The access using the primary key is very fast, because the system can directly calculate the position of the row using the hash algorithm. The primary key can be specified partially from the
left without gaps, meaning that some of the fields of the primary key can be omitted, as long as they are the rightmost fields and there are no gaps between the specified fields.
E. In a hashed internal table, specifying the primary key completely. A hashed internal table is a table type that does not have a predefined sorting order, but uses a hash algorithm to store and access the rows. The primary key of a hashed internal table must be unique and cannot be changed. A hashed internal table can only be accessed using the primary key, not the table index. The access using the primary key is very fast, because the system can directly calculate the position of the row using the hash algorithm. The primary key can be specified completely, meaning that all the fields of the primary key must be given in the correct order.
The following do not result in faster access to internal tables, because:
Which patterns raise an exception? Note: There are 3 correct answers to this question.
- A . DATA: gv_target TYPE p DECIMALS 2. CONSTANTS: go intl TYPE i VALUE 3. gv_target -U EXACT (2 gcojntl).
- B . DATA: gv_target TYPE string. □ CONSTANTS: gco_string TYPE LENGTH 16 VALUE 0123456789ABCDEF*. gv_target = EXACT # gco_string+5 (5) ).
- C . DATA: gv_target TYPE c LENGTH 5. V □ CONSTANTS: ECO string TYPE string VALUE 0123456789ABCDEF". gv_target – EXACT (gco_string + 5 (6) ).
- D . DATA: Ev target TYPE p DECIMALS 3. CONSTANTS: gcojntl TYPE i VALUE 2. Ev_target -U EXACT #2 / gcojntl ).
- E . DATA: gv_target TYPE d. s/ □ CONSTANTS: gco_date TYPE d VALUE ‘20331233*. gv_target EXACT ( geo_date).
A, C, E
Explanation:
The patterns that raise an exception are those that use the constructor operator EXACT to perform a lossless assignment or calculation, but the result cannot be converted to the target data type without data loss.
The following are the explanations for each pattern:
A: This pattern raises the exception CX_SY_CONVERSION_LOST because the result of the calculation 2 * 3 is 6, which cannot be assigned to a packed number with two decimal places without losing the integer part. The operator -U is used to perform a lossless calculation with the calculation type decfloat34.
B: This pattern does not raise an exception because the result of the substring expression
gco_string+5(5) is ‘6789A’, which can be assigned to a string without data loss. The operator EXACT # is used to perform a lossless assignment with the data type of the argument.
C: This pattern raises the exception CX_SY_CONVERSION_LOST because the result of the substring expression gco_string+5(6) is ‘6789AB’, which cannot be assigned to a character field with length 5 without losing the last character. The operator EXACT is used to perform a lossless assignment with the data type of the target field.
D: This pattern does not raise an exception because the result of the calculation 2 / 2 is 1, which can be assigned to a packed number with three decimal places without data loss. The operator -U is used to perform a lossless calculation with the calculation type decfloat34.
E: This pattern raises the exception CX_SY_CONVERSION_ERROR because the constant gco_date contains an invalid value ‘20331233’ for a date data type, which cannot be converted to a valid date. The operator EXACT is used to perform a lossless assignment with the data type of the target field.
Reference: EXACT – Lossless Operator – ABAP Keyword Documentation, Lossless Assignments – ABAP Keyword Documentation
What RESTful Application Programming object contains only the fields required for a particular app?
- A . Database view
- B . Metadata extension
- C . Projection View
- D . Data model view
C
Explanation:
A projection view is a RESTful Application Programming object that contains only the fields required for a particular app. A projection view is a CDS view entity that defines a projection on an existing CDS view entity or CDS DDIC-based view. A projection view exposes a subset of the elements of the projected entity, which are relevant for a specific business service. A projection view can also define aliases, virtual elements, and annotations for the projected elements. A projection view is the top-most layer of a CDS data model and prepares data for a particular use case. A projection view can have different provider contracts depending on the type of service it supports, such as transactional query, analytical query, or transactional interface.
A database view is a CDS DDIC-based view that defines a join or union of database tables. A database view has an SQL view attached and can be accessed by Open SQL or native SQL. A database view can be used as a projected entity for a projection view, but it does not contain only the fields required for a particular app.
A metadata extension is a RESTful Application Programming object that defines additional annotations for a CDS view entity or a projection view. A metadata extension can be used to enhance the metadata of a CDS data model without changing the original definition. A metadata extension does not contain any fields, but only annotations.
A data model view is a CDS view entity that defines a data model based on database tables or other CDS view entities. A data model view can have associations, aggregations, filters, parameters, and annotations. A data model view can be used as a projected entity for a projection view, but it does not contain only the fields required for a particular app.
Reference: CDS Projection Views – ABAP Keyword Documentation, CDS Projection Views in ABAP
CDS: What’s Your Flavor, Business Object Projection – ABAP Keyword Documentation
Given the following code in an SAP S/4HANA Cloud private edition tenant:
The class zcl_demo_class is in a software component with the language version set to "ABAP Cloud". The function module ZF1′ is in a different software component with the language version set to "Standard ABAP". Both the class and function module are customer created.
Regarding line #6, which of the following are valid statements? Note: There are 2 correct answers to this question.
- A . ZF1′ can be called only if it is released for cloud development.
- B . ‘ZF1’ can be called if a wrapper is created for it and the wrapper itself is released for cloud development.
- C . "ZF1" can be called whether it is released or not for cloud development
- D . ZF1" can be called if a wrapper is created for it but the wrapper itself is not released for cloud development.
AB
Explanation:
The ABAP Cloud Development Model requires that only public SAP APIs and extension points are used 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 an ABAP Cloud class is not allowed and will result in a syntax error.
However, there are two possible ways to call a function module indirectly from an ABAP Cloud class:
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 “Standard ABAP” and must be marked as released for cloud development using the annotation @EndUserText.label. The wrapper can then be called from an ABAP Cloud class using the public methods or attributes2.
Use the ABAP Cloud Connector to call the function module as a remote function call (RFC) from an ABAP Cloud class. The ABAP Cloud Connector is a service that enables the secure and reliable communication between SAP BTP, ABAP environment and on-premise systems. The function module must be exposed as an RFC-enabled function module in the on-premise system and must be registered in the ABAP Cloud Connector. The ABAP Cloud class can then use the class cl_rfc_destination_service to get the destination name and the class cl_abap_system to create a proxy object for the function module. The proxy object can then be used to call the function module3.
Reference: 1: SAP API Business Hub 2: Creating an ABAP Cloud Project | SAP Help Portal 3: Calling Remote Function Modules | SAP Help Portal
What are valid statements? Note: There are 3 correct answers to this question.
- A . Instead of go_cl1 = NEW #( … ) you could use go_if1 = NEW cl1( … ).
- B . go_if1 may call method m1 with go_if1->m1( … ).
- C . go_cl1 may call method m1 with go_cl1->if1~m1( … ).
- D . go_cl1 may call method m1 directly without interface notation
- E . go_if1 may call method m2 with go_if1->m2( … )
Refer to the exhibit.
with which predicate condition can you ensure that the CAST will work?
- A . IS SUPPLIED
- B . IS NOT INITIAL
- C . IS INSTANCE OF
- D . IS BOUND
C
Explanation:
The predicate condition that can be used to ensure that the CAST will work is IS INSTANCE OF. The IS INSTANCE OF predicate condition checks whether the operand is an instance of the specified class or interface. This is useful when you want to perform a downcast, which is a conversion from a more general type to a more specific type. A downcast can fail if the operand is not an instance of the target type, and this can cause a runtime error. Therefore, you can use the IS INSTANCE OF predicate condition to check whether the downcast is possible before using the CAST operator12. For example: The following code snippet uses the IS INSTANCE OF predicate condition to check whether the variable g_super is an instance of the class lcl_super. If it is, the CAST will work and the variable g_sub1 will be assigned the value of g_super.
DATA: g_super TYPE REF TO lcl_super, g_sub1 TYPE REF TO lcl_sub1. IF g_super IS INSTANCE OF lcl_super. g_sub1 = CAST #( g_super ). g_sub1->method( … ). ENDIF.
You cannot do any of the following:
IS SUPPLIED: The IS SUPPLIED predicate condition checks whether an optional parameter of a method or a function module has been supplied by the caller. This is useful when you want to handle different cases depending on whether the parameter has a value or not. However, this predicate condition has nothing to do with the CAST operator or the type of the operand12.
IS NOT INITIAL: The IS NOT INITIAL predicate condition checks whether the operand has a non-initial value. This is useful when you want to check whether the operand has been assigned a value or not. However, this predicate condition does not guarantee that the CAST will work, because the operand may have a value but not be an instance of the target type12.
IS BOUND: The IS BOUND predicate condition checks whether the operand is a bound reference variable. This is useful when you want to check whether the operand points to an existing object or not. However, this predicate condition does not guarantee that the CAST will work, because the operand may point to an object but not be an instance of the target type12.
Reference: 1: Predicate Expressions – ABAP Keyword Documentation – SAP Online Help 2: ABAP – Predicates | SAP Community
Which restrictions exist for ABAP SQL arithmetic expressions? Note: There are 2 correct answers to this question.
- A . Floating point types and integer types can NOT be used in the same expression.
- B . The operator/is allowed only in floating point expressions.
- C . Decimal types and integer types can NOT be used in the same expression.
- D . The operator is allowed only in floating point expressions.
BD
Explanation:
ABAP SQL arithmetic expressions have different restrictions depending on the data type of the operands.
The following are some of the restrictions:
Floating point types and integer types can be used in the same expression, as long as the integer types are cast to floating point types using the cast function. For example, CAST ( num1 AS FLTP ) / CAST ( num2 AS FLTP ) is a valid expression, where num1 and num2 are integer types.
The operator / is allowed only in floating point expressions, where both operands have the type FLTP or f. For example, num1 / num2 is a valid expression, where num1 and num2 are floating point types. If the operator / is used in an integer expression or a decimal expression, a syntax error occurs.
Decimal types and integer types can be used in the same expression, as long as the expression is a decimal expression. A decimal expression has at least one operand with the type DEC, CURR, or QUAN or p with decimal places. For example, num1 + num2 is a valid expression, where num1 is a decimal type and num2 is an integer type.
The operator ** is allowed only in floating point expressions, where both operands have the type FLTP or f. For example, num1 ** num2 is a valid expression, where num1 and num2 are floating point types. If the operator ** is used in an integer expression or a decimal expression, a syntax error occurs.
Reference: sql_exp – sql_arith – ABAP Keyword Documentation, SQL Expressions, Arithmetic Calculations – ABAP Keyword Documentation