SAP C_ABAPD_2309 Practice Test - Questions Answers, Page 3

List of questions
Question 21

Refer to the exhibit.
Which of the following types are permitted to be used for <source> on line #4? Note: There are 2 correct answers to this question.
A database table from the ABAP Dictionary
A CDS DDIC-based view
An external view from the ABAP Dictionary
A database view from the ABAP Dictionary
The <source> clause in the CDS View Entity Data Definition can be used to specify the data source for the view entity.The <source> clause can accept different types of data sources, depending on the type of the view entity1.
A database table from the ABAP Dictionary: This is a valid type of data source for a CDS View Entity Data Definition. A database table from the ABAP Dictionary is a table that is defined in the ABAP Dictionary using the keyword TABLE or TABLE OF.The name of the database table must be unique within its namespace and must not contain any special characters2.
A CDS DDIC-based view: This is also a valid type of data source for a CDS View Entity Data Definition. A CDS DDIC-based view is a view that is defined in the Core Data Services using the keyword DEFINE VIEW ENTITY.The name of the CDS DDIC-based view must be unique within its namespace and must not contain any special characters3.
You cannot do any of the following:
An external view from the ABAP Dictionary: This is not a valid type of data source for a CDS View Entity Data Definition. An external view from the ABAP Dictionary is a view that is defined in an external application using any language supported by SAP, such as SQL, PL/SQL, or Java.The name of the external view must be unique within its namespace and must not contain any special characters4.
A database view from the ABAP Dictionary: This is not a valid type of data source for a CDS View Entity Data Definition. A database view from the ABAP Dictionary is a view that is defined in an external application using any language supported by SAP, such as SQL, PL/SQL, or Java.The name of the database view must be unique within its namespace and must not contain any special characters4.
Question 22

When processing a loop with the statement DO... ENDDO, what system variable contains the implicit loop counter?
sy-linno
sy-labix
sy-subrc
sy-index
When processing a loop with the statement DO... ENDDO, the system variable that contains the implicit loop counter is sy-index. The loop counter is a numeric value that indicates how many times the loop has been executed. The loop counter is initialized to 1 before the first execution of the loop and is incremented by 1 after each execution. The loop counter can be used to control the number of loop iterations or to access the loop elements by index.The loop counter can also be accessed or modified within the loop body, but this is not recommended as it may cause unexpected results or errors1.
For example, the following code snippet uses the loop counter sy-index to display the numbers from 1 to 10:
DO 10 TIMES. WRITE: / sy-index. ENDDO.
The output of this code is:
1 2 3 4 5 6 7 8 9 10
Question 23

Which patterns raise an exception? Note: There are 3 correct answers to this question.
DATA: gv_target TYPE p DECIMALS 2. CONSTANTS: go intl TYPE i VALUE 3. gv_target -U EXACT (2 gcojntl).
DATA: gv_target TYPE string. CONSTANTS: gco_string TYPE LENGTH 16 VALUE 0123456789ABCDEF*. gv_target = EXACT # gco_string+5 (5) ).
DATA: gv_target TYPE c LENGTH 5. V CONSTANTS: ECO string TYPE string VALUE 0123456789ABCDEF'. gv_target - EXACT (gco_string + 5 (6) ).
DATA: Ev target TYPE p DECIMALS 3. CONSTANTS: gcojntl TYPE i VALUE 2. Ev_target -U EXACT #2 / gcojntl ).
DATA: gv_target TYPE d. s/ CONSTANTS: gco_date TYPE d VALUE '20331233*. gv_target EXACT ( geo_date).
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.
Question 24

Which of the following are parts of the definition of a new database table?Note: There are 2 correct answers to this question.
Partitioning attribues
Extension
Semantic table attributes
Field list
Question 25

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?
'ZF1' can be called whether it has been released or not for cloud development.
'ZF1' can be called via a wrapper that itself has been released for cloud development.
'ZF1' can be called via a wrapper that itself has not been released for cloud development.
'ZF1' must be released for cloud development to be called.
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
Question 26

Which of the following are features of Core Data Services? Note: There are 3 correct answers to this question.
Inheritance
Associations
Annotations
Delegation
Structured Query Language (SQL)
Core Data Services (CDS) is a framework for defining and consuming semantically rich data models in SAP HANA.CDS supports various features that enhance the capabilities of SQL and enable developers to create data models that are optimized for performance, readability, and extensibility12. Some of the features of CDS are:
Associations: Associations are a way of defining relationships between CDS entities, such as tables or views. Associations enable navigation and path expressions in CDS queries, which allow accessing data from related entities without explicit joins.Associations also support cardinality, referential constraints, and cascading options34.
Annotations: Annotations are a way of adding metadata to CDS entities or their elements, such as fields or parameters. Annotations provide additional information or instructions for the CDS compiler, the database, or the consumers of the CDS views.Annotations can be used for various purposes, such as defining access control, UI rendering, OData exposure, or search capabilities5.
Structured Query Language (SQL): SQL is the standard language for querying and manipulating data in relational databases. CDS is based on SQL and extends it with additional features and syntax. CDS supports SQL features such as joins, aggregations, filters, expressions, functions, and subqueries. CDS also supports SQL Script, which is a scripting language for stored procedures and functions in SAP HANA .
You cannot do any of the following:
Inheritance: Inheritance is not a feature of CDS. Inheritance is a concept in object-oriented programming that allows a class to inherit the properties and methods of another class. CDS does not support object-oriented programming or classes.
Delegation: Delegation is not a feature of CDS. Delegation is a concept in object-oriented programming that allows an object to delegate some of its responsibilities to another object. CDS does not support object-oriented programming or objects.
Question 27

What is the purpose of a foreign key relationship between two tables in the ABAP Dictionary?
To document the relationship between the two tables
To ensure the integrity of data in the corresponding database tables
To create a corresponding foreign key relationship in the database
The purpose of a foreign key relationship between two tables in the ABAP Dictionary is to ensure the integrity of data in the corresponding database tables. A foreign key relationship defines a logical link between a foreign key table and a check table, where the foreign key fields of the former are assigned to the primary key fields of the latter. This means that the values entered in the foreign key fields must exist in the check table, otherwise the system will reject the entry. This way, the foreign key relationship prevents the insertion of invalid or inconsistent data in the database tables.
A foreign key relationship also serves to document the relationship between the two tables in the ABAP Dictionary, but this is not its primary purpose. A foreign key relationship does not necessarily create a corresponding foreign key relationship in the database, as this depends on the database system and the settings of the ABAP Dictionary. Some database systems do not support foreign keys at all, while others require additional steps to activate them. Therefore, the foreign key relationship in the ABAP Dictionary is mainly a logical concept that is enforced by the ABAP runtime environment.
https://help.sap.com/doc/saphelp_snc70/7.0/en-US/cf/21ea77446011d189700000e8322d00/content.htm
Question 28

When does SAP recommend to use a sorted or a hashed table respectively? Note: There are 2 correct answers to this question.
A hashed table, when you read a single record and specify the complete key.
A hashed table, when you read a subset in a loop and specify a part of the key from the left without gaps.
A sorted table, when you read a subset in a loop and specify a part of the key from the left ^ without gaps.
A sorted table, when you read a single record and specify non key fields.
Question 29

Class super has subclass sub. Which rules are valid for the sub constructor? Note: There are 2 correct answers to this question.
The method signature can be changed.
Import parameters can only be evaluated after calling the constructor of super.
The constructor of super must be called before using any components of your own instance.
Events of your own instance cannot be raised before the registration of a handler in super.
The sub constructor is the instance constructor of the subclass sub that inherits from the superclass super.The sub constructor has some rules that it must follow when it is defined and implemented12. Some of the valid rules are:
The method signature can be changed: This is true. The sub constructor can have a different method signature than the super constructor, which means that it can have different input parameters, output parameters, or exceptions.However, the sub constructor must still call the super constructor with appropriate actual parameters that match its interface12.
The constructor of super must be called before using any components of your own instance: This is true. The sub constructor must ensure that the super constructor is called explicitly using super->constructor before accessing any instance components of its own class, such as attributes or methods.This is because the super constructor initializes the inherited components of the subclass and sets the self-reference me-> to the current instance12.
You cannot do any of the following:
Import parameters can only be evaluated after calling the constructor of super: This is false. The sub constructor can evaluate its own import parameters before calling the constructor of super, as long as it does not access any instance components of its own class.For example, the sub constructor can use its import parameters to calculate some values or check some conditions that are needed for calling the super constructor12.
Events of your own instance cannot be raised before the registration of a handler in super: This is false. The sub constructor can raise events of its own instance before calling the constructor of super, as long as it does not access any instance components of its own class.For example, the sub constructor can raise an event to notify the consumers of the subclass about some status or error that occurred during the initialization of the subclass12.
Question 30

In an Access Control Object, which clauses are used? Note: There are 3 correct answers to this question.
Where (to specify the access conditions)
Crant (to identify the data source)
Return code (to assign the return code of the authority check)
Define role (to specify the role name)
Revoke (to remove access to the data source)
An Access Control Object (ACO) is a CDS annotation that defines the access control rules for a CDS view entity.An ACO consists of one or more clauses that specify the role name, the data source, the access conditions, and the return code of the authority check12. Some of the clauses that are used in an ACO are:
Where (to specify the access conditions): This clause is used to define the logical expression that determines whether a user has access to the data source or not. The expression can use the fields of the data source, the parameters of the CDS view entity, or the predefined variables $user and $session.The expression can also use the functions check_authorization and check_role to perform additional authority checks12.
Define role (to specify the role name): This clause is used to assign a name to the role that is defined by the ACO. The role name must be unique within the namespace of the CDS view entity and must not contain any special characters.The role name can be used to reference the ACO in other annotations, such as @AccessControl.authorizationCheck or @AccessControl.grant12.
Revoke (to remove access to the data source): This clause is used to explicitly deny access to the data source for a user who meets the conditions of the where clause. The revoke clause overrides any grant clause that might grant access to the same user.The revoke clause can be used to implement the principle of least privilege or to enforce data segregation12.
You cannot do any of the following:
Grant (to identify the data source): This is not a valid clause in an ACO. The grant clause is a separate annotation that is used to grant access to a CDS view entity or a data source for a user who has a specific role.The grant clause can reference an ACO by its role name to apply the access conditions defined by the ACO12.
Return code (to assign the return code of the authority check): This is not a valid clause in an ACO. The return code of the authority check is a predefined variable that is set by the system after performing the access control check.The return code can be used in the where clause of the ACO to specify different access conditions based on the outcome of the check12.
Question