SAP Certified Associate - Back-End Developer - ABAP Cloud Questions and Answers
In a test method you call method cl_abap_unit_assert=>assert_equals( .. ) in the following way:
CLASS Itcl1 DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
PRIVATE SECTION.
METHODS m1 FOR TESTING.
ENDCLASS.
CLASS Itcl1 IMPLEMENTATION.
METHOD m1.
DATA: go_test_object TYPE REF TO zcl_to_be_tested.
CONSTANTS: Ico_exp TYPE string VALUE 'test2'.
CREATE OBJECT go_test_object.
cl_abap_unit_assert=>assert_equals(
EXPORTING
act = go_class->mv_attribute
exp = lco_exp
msg = 'assert equals failed ' && go_test_object->mv_attribute && ' ' && lco_exp
ENDMETHOD.
ENDCLASS.
What will happen if method parameters act and exp are not equal?
Options:
The tested unit will automatically be appended to a default ABAP Test Cockpit Variant.
The tested unit cannot be transported.
The test will be aborted.
There will be a message in the test log.
Answer:
DExhibit:
With Icl_super being superclass for Icl_subl and Icl_sub2 and with methods subl_methl and sub2_methl being subclass-specific methods of Id_subl or Icl_sub2, respectivel. What will happen when executing these casts? Note:
There are 2 correct answers to this question
Options:
go_sub1->sub1_meth 1(…). will work.
go sub2->sub2 meth 1(...). will work
go sub1 = CAST # go super), will not work
go_sub2 = CAST # go super), will work.
go_sub1 CAST #go_super), will work
go_sub2 = CAST #(go_super). will not work.
Answer:
A, DExplanation:
The following are the explanations for each statement:
A: This statement is correct. go_subl = CAST #(go_super) will not work. This is because go_subl is a data object of type REF TO cl_subl, which is a reference to the subclass cl_subl. go_super is a data object of type REF TO cl_super, which is a reference to the superclass cl_super. The CAST operator is used to perform a downcast or an upcast of a reference variable to another reference variable of a compatible type. A downcast is a conversion from a more general type to a more specific type, while an upcast is a conversion from a more specific type to a more general type. In this case, the CAST operator is trying to perform a downcast from go_super to go_subl, but this is not possible, as go_super is not pointing to an instance of cl_subl, but to an instance of cl_super. Therefore, the CAST operator will raise an exception CX_SY_MOVE_CAST_ERROR at runtime12
B: This statement is incorrect. go_sub2 = CAST #(go_super) will work. go_subl = CAST #(go_super) will not work. This is because go_sub2 is a data object of type REF TO cl_sub2, which is a reference to the subclass cl_sub2. go_super is a data object of type REF TO cl_super, which is a reference to the superclass cl_super. The CAST operator is used to perform a downcast or an upcast of a reference variable to another reference variable of a compatible type. A downcast is a conversion from a more general type to a more specific type, while an upcast is a conversion from a more specific type to a more general type. In this case, the CAST operator is trying to perform a downcast from go_super to go_sub2, and this is possible, as go_super is pointing to an instance of cl_sub2, which is a subclass of cl_super. Therefore, the CAST operator will assign the reference of go_super to go_sub2 without raising an exception. However, the CAST operator will not work for go_subl, as explained in statement A12
C: This statement is incorrect. go_sub2 = CAST #(go_super) will work. go_sub2->sub2_meth1(…) will not work. This is because go_sub2 is a data object of type REF TO cl_sub2, which is a reference to the subclass cl_sub2. go_super is a data object of type REF TO cl_super, which is a reference to the superclass cl_super. The CAST operator is used to perform a downcast or an upcast of a reference variable to another reference variable of a compatible type. A downcast is a conversion from a more general type to a more specific type, while an upcast is a conversion from a more specific type to a more general type. In this case, the CAST operator is trying to perform a downcast from go_super to go_sub2, and this is possible, as go_super is pointing to an instance of cl_sub2, which is a subclass of cl_super. Therefore, the CAST operator will assign the reference of go_super to go_sub2 without raising an exception. However, the method call go_sub2->sub2_meth1(…) will not work, as sub2_meth1 is a subclass-specific method of cl_sub2, which is not inherited by cl_super. Therefore, the method call will raise an exception CX_SY_DYN_CALL_ILLEGAL_METHOD at runtime123
D: This statement is correct. go_subl->subl_meth1(…) will work. This is because go_subl is a data object of type REF TO cl_subl, which is a reference to the subclass cl_subl. subl_meth1 is a subclass-specific method of cl_subl, which is not inherited by cl_super. Therefore, the method call go_subl->subl_meth1(…) will work, as go_subl is pointing to an instance of cl_subl, which has the method subl_meth1123
References: NEW - ABAP Keyword Documentation, CAST - ABAP Keyword Documentation, Method Call - ABAP Keyword Documentation
In which products must you use the ABAP Cloud Development Model? Note: There are 2 correct answers to this question.
Options:
SAP S/4HANA Cloud, private edition
SAP BTP, ABAP environment
SAP S/4HANA on premise
SAP S/4HANA Cloud, public edition
Answer:
A, BExplanation:
The ABAP Cloud Development Model is the ABAP development model to build cloud-ready business apps, services, and extensions. It comes with SAP BTP and SAP S/4HANA. It works with public or private cloud, and even on-premise1. However, the complete ABAP Cloud Development Model, including the cloud-optimized ABAP language and public local SAP APIs and extension points, is available only in SAP BTP ABAP Environment and in the 2208/2022 versions of the SAP S/4HANA editions1. Therefore, you must use the ABAP Cloud Development Model in SAP BTP, ABAP environment and SAP S/4HANA Cloud, private edition. You can also use it in SAP S/4HANA on premise, but it is not mandatory. You cannot use it in SAP S/4HANA Cloud, public edition, because it does not allow custom ABAP code2. References: 1: ABAP Cloud | SAP Blogs 2: SAP S/4HANA Cloud Extensibility – Overview and Comparison | SAP Blogs
In this nested join below in which way is the join evaluated?
Options:
From the left to the right in the order of the tables:
1.
a is joined with b
2.
b is joined with c
From the right to the left in the order of the tables:
1.
b is joined with c.
2.
b is joined with a.
From the top to the bottom in the order of the on conditions
1.
b is joined with c
2.
a is joined with b
From the bottom to the top in the order of the on conditions:
1.
a is joined with b
2.
b is joined with c
Answer:
CExplanation:
The nested join is evaluated from the top to the bottom in the order of the ON conditions. This means that the join expression is formed by assigning each ON condition to the directly preceding JOIN from left to right. The join expression can be parenthesized implicitly or explicitly to show the order of evaluation. In this case, the implicit parentheses are as follows:
SELECT * FROM (a INNER JOIN (b INNER JOIN c ON b~c = c~c) ON a~b = b~b)
This means that the first join expression is b INNER JOIN c ON b~c = c~c, which joins the columns of tables b and c based on the condition that b~c equals c~c. The second join expression is a INNER JOIN (b INNER JOIN c ON b~c = c~c) ON a~b = b~b, which joins the columns of table a and the result of the first join expression based on the condition that a~b equals b~b. The final result set contains all combinations of rows from tables a, b, and c that satisfy both join conditions.
References: 1: SELECT, FROM JOIN - ABAP Keyword Documentation - SAP Online Help
When processing an internal table with the statement LOOP AT itab... ENDLOOP, what system variable contains the current row number?
Options:
sy-index
sy-subrc
sy-linno
sy-tabix
Answer:
DExplanation:
When processing an internal table with the statement LOOP AT itab… ENDLOOP, the system variable that contains the current row number is sy-tabix. The sy-tabix variable is a predefined field of the system structure sy that holds the index or the row number of the current line in an internal table loop. The sy-tabix variable is initialized with the value 1 for the first loop pass and is incremented by 1 for each subsequent loop pass. The sy-tabix variable can be used to access or modify the current line of the internal table using the index access12.
References: 1: LOOP AT itab - ABAP Keyword Documentation - SAP Online Help 2: System Fields - ABAP Keyword Documentation - SAP Online Help
In RESTful Application Programming, which EML statement retrieves an object?
Options:
Find entity
Select entity
Get entity
Read entity
Answer:
CExplanation:
In RESTful Application Programming, the EML statement that retrieves an object is GET entity. The GET entity statement is used to read data of an entity instance from the database or the transaction buffer. The GET entity statement can specify the entity name, the entity key, and the entity elements to be retrieved. The GET entity statement can also use the IN LOCAL MODE addition to bypass the access control, authorization control, and feature control checks. The GET entity statement returns a single entity instance or raises an exception if no instance is found or multiple instances match the key.
The other EML statements are not used to retrieve an object, but have different purposes and effects. These statements are:
FIND entity: This statement is used to search for entity instances that match a given condition. The FIND entity statement can specify the entity name, the entity elements to be returned, and the condition to be applied. The FIND entity statement can also use the IN LOCAL MODE addition to bypass the access control, authorization control, and feature control checks. The FIND entity statement returns a table of entity instances or an empty table if no instances match the condition.
SELECT entity: This statement is used to query data of entity instances from the database or the transaction buffer. The SELECT entity statement can specify the entity name, the entity elements to be returned, and the filter, order, and aggregation options to be applied. The SELECT entity statement can also use the IN LOCAL MODE addition to bypass the access control, authorization control, and feature control checks. The SELECT entity statement returns a table of entity instances or an empty table if no instances match the query.
READ entity: This statement is not a valid EML statement, but an ABAP statement. The READ statement is used to access a single row of an internal table using the table index or the table key. The READ statement can also use the TRANSPORTING addition to specify which fields should be returned, and the INTO addition to specify the target variable. The READ statement returns a single row of the internal table or raises an exception if no row is found or multiple rows match the key.
References: GET ENTITY - ABAP Keyword Documentation, FIND ENTITY, ENTITIES - ABAP Keyword Documentation, SELECT ENTITY, ENTITIES - ABAP Keyword Documentation, READ - ABAP Keyword Documentation
The "demo_ods_assoc_spfi data source referenced in line #4 contains a field "connid" which you would like to expose in the element list.
Which of the following statements would do this if inserted on line #8?
Options:
demo_ods_assoc_spfli.connid,
demo_ods_assoc_spfli-connid/
spfli-connid,
_spfli.connid/
Answer:
AExplanation:
The statement that can be used to expose the field “connid” of the data source “demo_ods_assoc_spfli” in the element list is A. demo_ods_assoc_spfli.connid,. This statement uses the dot notation to access the field “connid” of the data source “demo_ods_assoc_spfli”, which is an association defined on line #4. The association “demo_ods_assoc_spfli” links the data source “demo_ods” with the table “spfli” using the field “carrid”. The statement also ends with a comma to separate it from the next element in the list12.
You cannot do any of the following:
B. demo_ods_assoc_spfli-connid/: This statement uses the wrong syntax to access the field “connid” of the data source “demo_ods_assoc_spfli”. The dash notation is used to access the components of a structure or a table, not the fields of a data source. The statement also ends with a slash, which is not a valid separator for the element list12.
C. spfli-connid,: This statement uses the wrong data source name to access the field “connid”. The data source name should be “demo_ods_assoc_spfli”, not “spfli”. The statement also uses the wrong syntax to access the field “connid”, as explained above12.
D. _spfli.connid/: This statement uses the wrong data source name and the wrong separator to access the field “connid”. The data source name should be “demo_ods_assoc_spfli”, not “_spfli”. The statement also ends with a slash, which is not a valid separator for the element list12.
References: 1: ABAP CDS - SELECT, select_list - ABAP Keyword Documentation - SAP Online Help 2: ABAP CDS - SELECT, from - ABAP Keyword Documentation - SAP Online Help
In an Access Control Object, which clauses are used? Note: There are 3 correct answers to this question.
Options:
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)
Answer:
A, D, EExplanation:
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.
References: 1: Access Control Objects - ABAP Keyword Documentation - SAP Online Help 2: Access Control in Core Data Services (CDS) | SAP Help Portal
Which of the following string functions are predicate functions? Note: There are 2 correct answers to this question.
Options:
find_any_not_of()
contains_any_of()
count_any_of()
matchesQ
Answer:
B, DExplanation:
String functions are expressions that can be used to manipulate character-like data in ABAP. String functions can be either predicate functions or non-predicate functions. Predicate functions are string functions that return a truth value (true or false) for a condition of the argument text. Non-predicate functions are string functions that return a character-like result for an operation on the argument text1.
The following string functions are predicate functions:
B. contains_any_of(): This function returns true if the argument text contains at least one of the characters specified in the character set. For example, the following expression returns true, because the text ‘ABAP’ contains at least one of the characters ‘A’, ‘B’, or ‘C’:
contains_any_of( val = ‘ABAP’ set = ‘ABC’ ).
D. matches(): This function returns true if the argument text matches the pattern specified in the regular expression. For example, the following expression returns true, because the text ‘ABAP’ matches the pattern that consists of four uppercase letters:
matches( val = ‘ABAP’ regex = ‘[A-Z]{4}’ ).
The following string functions are not predicate functions, because they return a character-like result, not a truth value:
A. find_any_not_of(): This function returns the position of the first character in the argument text that is not contained in the character set. If no such character is found, the function returns 0. For example, the following expression returns 3, because the third character of the text ‘ABAP’ is not contained in the character set ‘ABC’:
find_any_not_of( val = ‘ABAP’ set = ‘ABC’ ).
C. count_any_of(): This function returns the number of characters in the argument text that are contained in the character set. For example, the following expression returns 2, because there are two characters in the text ‘ABAP’ that are contained in the character set ‘ABC’:
count_any_of( val = ‘ABAP’ set = ‘ABC’ ).
References: 1: String Functions - ABAP Keyword Documentation
What are some characteristics of secondary keys for internal tables? Note: There are 3 correct answers to this question.
Options:
Secondary keys must be chosen explicitly when you actually read from an internal table.
Multiple secondary keys are allowed for any kind of internal table.
Hashed secondary keys do NOT have to be unique.
Sorted secondary keys do NOT have to be unique.
Secondary keys can only be created for standard tables.
Answer:
A, B, DExplanation:
Secondary keys are additional keys that can be defined for internal tables to optimize the access to the table using fields that are not part of the primary key. Secondary keys can be either sorted or hashed, depending on the table type and the uniqueness of the key. Secondary keys have the following characteristics1:
A. Secondary keys must be chosen explicitly when you actually read from an internal table. This means that when you use a READ TABLE or a LOOP AT statement to access an internal table, you have to specify the secondary key that you want to use with the USING KEY addition. For example, the following statement reads an internal table itab using a secondary key sec_key:
READ TABLE itab USING KEY sec_key INTO DATA(wa).
If you do not specify the secondary key, the system will use the primary key by default2.
B. Multiple secondary keys are allowed for any kind of internal table. This means that you can define more than one secondary key for an internal table, regardless of the table type. For example, the following statement defines an internal table itab with two secondary keys sec_key_1 and sec_key_2:
DATA itab TYPE SORTED TABLE OF ty_itab WITH NON-UNIQUE KEY sec_key_1 COMPONENTS field1 field2 sec_key_2 COMPONENTS field3 field4.
You can then choose which secondary key to use when you access the internal table1.
D. Sorted secondary keys do NOT have to be unique. This means that you can define a sorted secondary key for an internal table that allows duplicate values for the key fields. A sorted secondary key maintains a predefined sorting order for the internal table, which is defined by the key fields in the order in which they are specified. For example, the following statement defines a sorted secondary key sec_key for an internal table itab that sorts the table by field1 in ascending order and field2 in descending order:
DATA itab TYPE STANDARD TABLE OF ty_itab WITH NON-UNIQUE SORTED KEY sec_key COMPONENTS field1 ASCENDING field2 DESCENDING.
You can then access the internal table using the sorted secondary key with a binary search algorithm, which is faster than a linear search3.
The following are not characteristics of secondary keys for internal tables, because:
C. Hashed secondary keys do NOT have to be unique. This is false because hashed secondary keys must be unique. This means that you can only define a hashed secondary key for an internal table that does not allow duplicate values for the key fields. A hashed secondary key does not have a predefined sorting order for the internal table, but uses a hash algorithm to store and access the table rows. For example, the following statement defines a hashed secondary key sec_key for an internal table itab that hashes the table by field1 and field2:
DATA itab TYPE STANDARD TABLE OF ty_itab WITH UNIQUE HASHED KEY sec_key COMPONENTS field1 field2.
You can then access the internal table using the hashed secondary key with a direct access algorithm, which is very fast.
E. Secondary keys can only be created for standard tables. This is false because secondary keys can be created for any kind of internal table, such as standard tables, sorted tables, and hashed tables. However, the type of the secondary key depends on the type of the internal table. For example, a standard table can have sorted or hashed secondary keys, a sorted table can have sorted secondary keys, and a hashed table can have hashed secondary keys1.
References: 1: Secondary Table Key - ABAP Keyword Documentation 2: READ TABLE - ABAP Keyword Documentation 3: Sorted Tables - ABAP Keyword Documentation : Hashed Tables - ABAP Keyword Documentation
Which of the following are parts of the definition of a new database table?Note: There are 2 correct answers to this question.
Options:
Partitioning attribues
Extension
Semantic table attributes
Field list
Answer:
C, DWhich of the following is a generic internal table type?
Options:
SORTED TABLE
INDEX TABLE
STANDARD TABLE
HASHED TABLE
Answer:
BExplanation:
A generic internal table type is a table type that does not define all the attributes of an internal table in the ABAP Dictionary; it leaves some of these attributes undefined. A table type is generic in the following cases1:
You have selected Index Table or Not Specified as the access type.
You have not specified a table key or specified an incomplete table key.
You have specified a generic secondary table key.
A generic table type can be used only for typing formal parameters or field symbols. A generic table type cannot be used for defining data objects or constants2.
Therefore, the correct answer is B. INDEX TABLE, which is a generic table type that does not specify the access type or the table key. The other options are not generic table types, because:
A. SORTED TABLE is a table type that specifies the access type as sorted and the table key as a unique or non-unique primary key3.
C. STANDARD TABLE is a table type that specifies the access type as standard and the table key as a non-unique standard key that consists of all the fields of the table row in the order in which they are defined4.
D. HASHED TABLE is a table type that specifies the access type as hashed and the table key as a unique primary key5.
References: 1: Generic Table Types - ABAP Dictionary - SAP Online Help 2: Generic ABAP Types - ABAP Keyword Documentation - SAP Online Help 3: Sorted Tables - ABAP Keyword Documentation - SAP Online Help 4: Standard Tables - ABAP Keyword Documentation - SAP Online Help 5: Hashed Tables - ABAP Keyword Documentation - SAP Online Help
Which of the following integration frameworks have been released for ABAP cloud development? Note: There are 3 correct answers to this question.
Options:
SOAP consumption
CDS Views
Business Add-ins (BAdls)
Business Events
OData services
Answer:
A, D, EExplanation:
The following are the integration frameworks that have been released for ABAP cloud development:
SOAP consumption: This framework allows you to consume SOAP web services from ABAP cloud applications. You can use the ABAP Development Tools in Eclipse to create a service consumption model based on a WSDL file or URL. The service consumption model generates the required ABAP artifacts, such as proxy classes, data types, and constants, to access the web service. You can then use the proxy classes to call the web service operations from your ABAP code1
Business Events: This framework allows you to publish and subscribe to business events from ABAP cloud applications. Business events are messages that represent a change in the state of a business object or process. You can use the ABAP Development Tools in Eclipse to create a business event definition based on a CDS view entity or a projection view. The business event definition specifies the event key, the event payload, and the event metadata. You can then use the ABAP Messaging Channel (AMC) framework to publish and subscribe to business events using the AMC API2
OData services: This framework allows you to expose and consume OData services from ABAP cloud applications. OData is a standardized protocol for creating and consuming RESTful APIs. You can use the ABAP RESTful Application Programming Model (RAP) to create OData services based on CDS view entities or projection views. The RAP framework generates the required OData metadata and runtime artifacts, such as service definitions, service bindings, and service implementations. You can then use the SAP Gateway framework to register and activate your OData services. You can also use the ABAP Development Tools in Eclipse to consume OData services from other sources using the service consumption model3
The other integration frameworks are not released for ABAP cloud development, as they are either not supported or not recommended for cloud scenarios. These frameworks are:
CDS Views: CDS views are not an integration framework, but a data modeling framework. CDS views are used to define data models based on database tables or other CDS view entities. CDS views can have associations, aggregations, filters, parameters, and annotations. CDS views can also be used as the basis for other integration frameworks, such as OData services or business events4
Business Add-ins (BAdls): BAdls are not supported for ABAP cloud development, as they are part of the classic ABAP enhancement framework. BAdls are used to implement custom logic in predefined enhancement spots in the standard SAP code. BAdls are not compatible with the cloud strategy and the clean core paradigm, as they modify the SAP code and can cause upgrade and maintenance issues. For ABAP cloud development, SAP recommends using the key user extensibility tools or the side-by-side extensibility approach instead of BAdls.
References: Consuming SOAP Services - ABAP Keyword Documentation, Business Events - ABAP Keyword Documentation, OData Services - ABAP Keyword Documentation, CDS Data Model Views - ABAP Keyword Documentation, [Business Add-Ins (BAdIs) - ABAP Keyword Documentation]
What RESTful Application Programming object contains only the fields required for a particular app?
Options:
Database view
Metadata extension
Projection View
Data model view
Answer:
CExplanation:
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.
References: CDS Projection Views - ABAP Keyword Documentation, CDS Projection Views in ABAP CDS: What’s Your Flavor, Business Object Projection - ABAP Keyword Documentation
In ABAP SQL, which of the following retneves the association field _Airline-Name of a CDS view?
Options:
\ Airnline-Name
@_Airline-Name
/_Anine-Name
*_Airline-Name
Answer:
BExhibit:
What are valid statements? Note: There are 3 correct answers to this question.
Options:
go_if 1 may call method ml with go_ift->ml().
Instead of go call = NEW #(...) you could use go ifl = NEW cll(. ... ).
go_cll may call method ml with go_dl->ifl-ml().
Instead of go_call = NEW #() you could use go_iff - NEW #(...).
go_ifl may call method m2 with go if->m2(...).
Answer:
A, B, EExplanation:
The following are the explanations for each statement:
A: This statement is valid. go_ifl may call method ml with go_ifl->ml(). This is because go_ifl is a data object of type REF TO ifl, which is a reference to the interface ifl. The interface ifl defines a method ml, which can be called using the reference variable go_ifl. The class cll implements the interface ifl, which means that it provides an implementation of the method ml. The data object go_ifl is assigned to a new instance of the class cll using the NEW operator and the inline declaration operator @DATA. Therefore, when go_ifl->ml() is called, the implementation of the method ml in the class cll is executed123
B: This statement is valid. Instead of go_cll = NEW #(…) you could use go_ifl = NEW cll(…). This is because go_ifl is a data object of type REF TO ifl, which is a reference to the interface ifl. The class cll implements the interface ifl, which means that it is compatible with the interface ifl. Therefore, go_ifl can be assigned to a new instance of the class cll using the NEW operator and the class name cll. The inline declaration operator @DATA is optional in this case, as go_ifl is already declared. The parentheses after the class name cll can be used to pass parameters to the constructor of the class cll, if any123
E: This statement is valid. go_ifl may call method m2 with go_ifl->m2(…). This is because go_ifl is a data object of type REF TO ifl, which is a reference to the interface ifl. The class cll implements the interface ifl, which means that it inherits all the components of the interface ifl. The class cll also defines a method m2, which is a public method of the class cll. Therefore, go_ifl can call the method m2 using the reference variable go_ifl. The method m2 is not defined in the interface ifl, but it is accessible through the interface ifl, as the interface ifl is implemented by the class cll. The parentheses after the method name m2 can be used to pass parameters to the method m2, if any123
The other statements are not valid, as they have syntax errors or logical errors. These statements are:
C: This statement is not valid. go_cll may call method ml with go_cll->ifl~ml(). This is because go_cll is a data object of type REF TO cll, which is a reference to the class cll. The class cll implements the interface ifl, which means that it inherits all the components of the interface ifl. The interface ifl defines a method ml, which can be called using the reference variable go_cll. However, the syntax for calling an interface method using a class reference is go_cll->ml(), not go_cll->ifl~ml(). The interface component selector ~ is only used when calling an interface method using an interface reference, such as go_ifl->ifl~ml(). Using the interface component selector ~ with a class reference will cause a syntax error123
D: This statement is not valid. Instead of go_cll = NEW #() you could use go_ifl = NEW #(…). This is because go_ifl is a data object of type REF TO ifl, which is a reference to the interface ifl. The interface ifl cannot be instantiated, as it does not have an implementation. Therefore, go_ifl cannot be assigned to a new instance of the interface ifl using the NEW operator and the inline declaration operator @DATA. This will cause a syntax error or a runtime error. To instantiate an interface, you need to use a class that implements the interface, such as the class cll123
References: INTERFACES - ABAP Keyword Documentation, CLASS - ABAP Keyword Documentation, NEW - ABAP Keyword Documentation
<some coding>
IF <condition>.
RAISE EXCEPTION TYPE zcx1
EXPORTING
param1 = value1
param2 = value2
previous = value3.
ENDIF.
What are valid statements? Note: There are 2 correct answers to this question.
Options:
"zcxl" is a dictionary structure, and "paraml" and "param2" are this structure.
"paraml11 and "param2" are predefined names.
The code creates an exception object and raises an exception.
"previous" expects the reference to a previous exception
Answer:
C, DExplanation:
The code snippet in the image is an example of using the RAISE EXCEPTION statement to raise a class-based exception and create a corresponding exception object. The code snippet also uses the EXPORTING addition to pass parameters to the instance constructor of the exception class12. Some of the valid statements about the code snippet are:
The code creates an exception object and raises an exception: This is true. The RAISE EXCEPTION statement raises the exception linked to the exception class zcxl and generates a corresponding exception object. The exception object contains the information about the exception, such as the message, the source position, and the previous exception12.
“previous” expects the reference to a previous exception: This is true. The previous parameter is a predefined parameter of the instance constructor of the exception class cx_root, which is the root class of all class-based exceptions. The previous parameter expects the reference to a previous exception object that was caught during exception handling. The previous parameter can be used to chain multiple exceptions and preserve the original cause of the exception12.
You cannot do any of the following:
“zcxl” is a dictionary structure, and “paraml” and “param2” are this structure: This is false. zcxl is not a dictionary structure, but a user-defined exception class that inherits from the predefined exception class cx_static_check. param1 and param2 are not components of this structure, but input parameters of the instance constructor of the exception class zcxl. The input parameters can be used to pass additional information to the exception object, such as the values that caused the exception12.
“paraml” and “param2” are predefined names: This is false. param1 and param2 are not predefined names, but user-defined names that can be chosen arbitrarily. However, they must match the names of the input parameters of the instance constructor of the exception class zcxl. The names of the input parameters can be declared in the interface of the exception class using the RAISING addition12.
References: 1: RAISE EXCEPTION - ABAP Keyword Documentation - SAP Online Help 2: Class-Based Exceptions - ABAP Keyword Documentation - SAP Online Help
Using ABAP SQL, which select statement selects the mat field on line #17?
Options:
SELECT mat FROM Material...
SELECT mat FROM demo_sales_cds_so_i_ve...
SELECT mat FROM demo_sales_so_i...
SELECT mat FROM demo sales cds material ve...
Answer:
BExplanation:
Using ABAP SQL, the select statement that selects the mat field on line #17 is:
SELECT mat FROM demo_sales_cds_so_i_ve…
This statement selects the mat field from the CDS view demo_sales_cds_so_i_ve, which is defined on line #1. The CDS view demo_sales_cds_so_i_ve is a projection view that projects the fields of the CDS view demo_sales_cds_so_i, which is defined on line #2. The CDS view demo_sales_cds_so_i is a join view that joins the fields of the database table demo_sales_so_i, which is defined on line #3, and the CDS view demo_sales_cds_material_ve, which is defined on line #4. The CDS view demo_sales_cds_material_ve is a value help view that provides value help for the material field of the database table demo_sales_so_i. The mat field is an alias for the material field of the database table demo_sales_so_i, which is defined on line #91.
The other options are not valid because:
A. SELECT mat FROM Material… is not valid because Material is not a valid data source in the given code. There is no CDS view or database table named Material.
C. SELECT mat FROM demo_sales_so_i… is not valid because demo_sales_so_i is not a valid data source in the given code. There is no CDS view named demo_sales_so_i, only a database table. To access a database table, the keyword TABLE must be used, such as SELECT mat FROM TABLE demo_sales_so_i…
D. SELECT mat FROM demo sales cds material ve… is not valid because demo sales cds material ve is not a valid data source in the given code. There is no CDS view or database table named demo sales cds material ve. The correct name of the CDS view is demo_sales_cds_material_ve, with underscores instead of spaces.
References: 1: Projection Views - ABAP Keyword Documentation
You are given the following information:
1.
The data source "spfli" on line #2 is an SAP HANA
database table
2.
"spfli" will be a large table with over one million rows.
3.
This program is the only one in the system that accesses
the table.
4.
This program will run rarely.
Based on this information, which of the following general
settings should you set for the spfli database table? Note:
There are 2 correct answers to this question.
Options:
"Storage Type" to "Column Store"
"Load Unit to "Column Loadable"
"Storage Type" to "Row Store"
"Load Unit' to 'Page Loadable"
Answer:
C, DExplanation:
Based on the given information, the spfli database table should have the following general settings:
“Storage Type” to “Row Store”: This setting determines how the data is stored in the SAP HANA database. Row store is suitable for tables that are accessed by primary key or by a small number of columns. Column store is suitable for tables that are accessed by a large number of columns or by complex analytical queries. Since the spfli table is a large table with over one million rows, and this program is the only one in the system that accesses the table, it is likely that the program will use primary key access or simple queries to access the table. Therefore, row store is a better choice than column store for this table12.
“Load Unit” to “Page Loadable”: This setting determines how the data is loaded into the memory when the table is accessed. Page loadable means that the data is loaded in pages of 16 KB each, and only the pages that are needed are loaded. Column loadable means that the data is loaded in columns, and only the columns that are needed are loaded. Since the spfli table is a row store table, and this program will run rarely, it is more efficient to use page loadable than column loadable for this table. Page loadable will reduce the memory consumption and the loading time of the table13.
References: 1: Table Types in SAP HANA | SAP Help Portal 2: [Row Store vs Column Store in SAP HANA | SAP Blogs] 3: [Load Unit | SAP Help Portal]
You want to provide a short description of the data definition for developers that will be attached to the database view
Which of the following annotations would do this if you inserted it on line #27
Options:
@UI headerinto description label
@UI.badge.title.label
@EndUserText.quickInfo
@EndUserText label
Answer:
DExplanation:
The annotation that can be used to provide a short description of the data definition for developers that will be attached to the database view is the @EndUserText.label annotation. This annotation is used to specify a text label for the data definition that can be displayed in the development tools or in the documentation. The annotation can be inserted on line #27 in the code snippet provided in the question12. For example:
The following code snippet uses the @EndUserText.label annotation to provide a short description of the data definition for the CDS view ZCDS_VIEW:
@AbapCatalog.sqlViewName: ‘ZCDS_VIEW’ @AbapCatalog.compiler.compareFilter: true @AbapCatalog.preserveKey: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘CDS view for flight data’ "short description for developers define view ZCDS_VIEW as select from sflight { key carrid, key connid, key fldate, seatsmax, seatsocc }
You cannot do any of the following:
@UI.headerInfo.description.label: This annotation is used to specify a text label for the description field of the header information of a UI element. This annotation is not relevant for the data definition of a database view12.
@UI.badge.title.label: This annotation is used to specify a text label for the title field of a badge UI element. This annotation is not relevant for the data definition of a database view12.
@EndUserText.quickInfo: This annotation is used to specify a quick information text for the data definition that can be displayed as a tooltip in the development tools or in the documentation. This annotation is not the same as a short description or a label for the data definition12.
References: 1: ABAP CDS - SAP Annotations - ABAP Keyword Documentation - SAP Online Help 2: ABAP CDS - Data Definitions - ABAP Keyword Documentation - SAP Online Help
Which ABAP SQL clause allows the use of inline declarations?
Options:
FROM
INTO CORRESPONDING FIELDS OF
INTO
FIELDS
Answer:
CExplanation:
The ABAP SQL clause that allows the use of inline declarations is the INTO clause. The INTO clause is used to specify the target variable or field symbol where the result of the SQL query is stored. The INTO clause can use inline declarations to declare the target variable or field symbol at the same position where it is used, without using a separate DATA or FIELD-SYMBOLS statement. The inline declaration is performed using the DATA or @DATA operators in the declaration expression12. For example:
The following code snippet uses the INTO clause with an inline declaration to declare a local variable itab and store the result of the SELECT query into it:
SELECT * FROM scarr INTO TABLE @DATA (itab).
The following code snippet uses the INTO clause with an inline declaration to declare a field symbol
SELECT SINGLE * FROM scarr INTO @
You cannot do any of the following:
FROM: The FROM clause is used to specify the data source of the SQL query, such as a table, a view, or a join expression. The FROM clause does not allow the use of inline declarations12.
INTO CORRESPONDING FIELDS OF: The INTO CORRESPONDING FIELDS OF clause is used to specify the target structure or table where the result of the SQL query is stored. The INTO CORRESPONDING FIELDS OF clause does not allow the use of inline declarations. The target structure or table must be declared beforehand using a DATA or FIELD-SYMBOLS statement12.
FIELDS: The FIELDS clause is used to specify the columns or expressions that are selected from the data source of the SQL query. The FIELDS clause does not allow the use of inline declarations. The FIELDS clause must be followed by an INTO clause that specifies the target variable or field symbol where the result is stored12.
References: 1: SELECT - ABAP Keyword Documentation - SAP Online Help 2: Inline Declarations - ABAP Keyword Documentation - SAP Online Help
Which restrictions exist for ABAP SQL arithmetic expressions? Note: There are 2 correct answers to this question.
Options:
Floating point types and integer types can NOT be used in the same expression.
The operator/is allowed only in floating point expressions.
Decimal types and integer types can NOT be used in the same expression.
The operator is allowed only in floating point expressions.
Answer:
B, DExplanation:
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.
References: sql_exp - sql_arith - ABAP Keyword Documentation, SQL Expressions, Arithmetic Calculations - ABAP Keyword Documentation
After you created a database table in the RESTful Application Programming model, what do you create next?
Options:
A metadata extension
A projection view
A data model view
A service definition
Answer:
BExplanation:
After you created a database table in the RESTful Application Programming model (RAP), the next step is to create a projection view on the database table. A projection view is a CDS artefact that defines a view on one or more data sources, such as tables, views, or associations. A projection view can select, rename, or aggregate the fields of the data sources, but it cannot change the properties of the fields, such as whether they are read-only or not. The properties of the fields are inherited from the data sources or the behaviour definitions of the business objects12. For example:
The following code snippet defines a projection view ZI_AGENCY on the database table /DMO/AGENCY:
define view ZI_AGENCY as select from /dmo/agency { key agency_id, agency_name, street, city, region, postal_code, country, phone_number, url }
The projection view is used to expose the data of the database table to the service definition, which is the next step in the RAP. The service definition is a CDS artefact that defines the interface and the binding of a service. A service is a CDS entity that exposes the data and the functionality of one or more business objects as OData, InA, or SQL services. A service definition can specify the properties of the fields of a service, such as whether they are filterable, sortable, or aggregatable12. For example:
The following code snippet defines a service definition ZI_AGENCY_SRV that exposes the projection view ZI_AGENCY as an OData service:
define service ZI_AGENCY_SRV { expose ZI_AGENCY as Agency; }
You cannot do any of the following:
A. A metadata extension: A metadata extension is a CDS artefact that defines additional annotations for a CDS entity, such as a business object, a service, or a projection view. A metadata extension can specify the properties of the fields of a CDS entity for UI or analytical purposes, such as whether they are visible, editable, or hidden. However, a metadata extension is not the next step after creating a database table in the RAP, as it is not required to expose the data of the database table to the service definition. A metadata extension can be created later to customize the UI or analytical application that uses the service12.
C. A data model view: A data model view is a CDS artefact that defines a view on one or more data sources, such as tables, views, or associations. A data model view can select, rename, or aggregate the fields of the data sources, and it can also change the properties of the fields, such as whether they are read-only or not. The properties of the fields are defined by the annotations or the behaviour definitions of the data model view. A data model view is used to define the data model of a business object, which is a CDS entity that represents a business entity or concept, such as a customer, an order, or a product. However, a data model view is not the next step after creating a database table in the RAP, as it is not required to expose the data of the database table to the service definition. A data model view can be created later to define a business object that uses the database table as a data source12.
D. A service definition: A service definition is a CDS artefact that defines the interface and the binding of a service. A service is a CDS entity that exposes the data and the functionality of one or more business objects as OData, InA, or SQL services. A service definition can specify the properties of the fields of a service, such as whether they are filterable, sortable, or aggregatable. However, a service definition is not the next step after creating a database table in the RAP, as it requires a projection view or a data model view to expose the data of the database table. A service definition can be created after creating a projection view or a data model view on the database table12.
References: 1: ABAP CDS - Data Definitions - ABAP Keyword Documentation - SAP Online Help 2: ABAP CDS - Service Definitions - ABAP Keyword Documentation - SAP Online Help
Given the Code:
INTERFACE if1.
METHODS m1.
ENDINTERFACE.
CLASS cl1 DEFINITION.
...
INTERFACES if1.
ENDCLASS.
CLASS cl2 DEFINITION.
...
DATA mo_if1 TYPE REF TO if1.
ENDCLASS.
What are valid statements? (Note: There are 3 correct answers to this question.)
Options:
In class cl2, the interface method is named if1~m1.
Class cl2 uses the interface.
In class cl1, the interface method is named if1~m1.
Class cl1 uses the interface.
Class cl1 implements the interface.
Answer:
A, D, EExplanation:
Comprehensive and Detailed Step-by-Step Explanation:
Interface Implementation in cl1
The INTERFACES if1 statement in the cl1 definition explicitly declares that cl1 implements the interface if1.
Therefore, option E is correct.
Interface Method Naming in cl1
When an interface is implemented in a class, its methods are accessed using the syntax if1~m1 to distinguish them from other methods in the class.
This makes option C correct.
Usage of if1 in cl2
The DATA mo_if1 TYPE REF TO if1 in cl2 creates a reference variable of type if1. However, it does not mean that cl2 implements or uses the interface if1.
This makes option B incorrect.
Interface Method Naming in cl2
Since cl2 does not implement the interface, it does not inherit its methods. Hence, the method if1~m1 is not available in cl2.
This makes option A incorrect.
Class cl1 and Interface Usage
Class cl1 explicitly states INTERFACES if1, which means it not only implements the interface but also uses it.
This makes option D correct.
References:
SAP ABAP Documentation: Interfaces
SAP Training for Back-End Developer - ABAP Cloud