Correct Answer: C
The correct expression to change a given string value `mr joe doe' into `JOE' in an ABAP SQL field list is C. SELECT FROM TABLE dbtabl FIELDS Of1, substring(upper(`mr joe doe'), 4, 3) AS f2_sub_up, f3,... This expression uses the
following SQL functions for strings12:
upper: This function converts all lowercase characters in a string to uppercase. For example, upper(`mr joe doe') returns `MR JOE DOE'. substring: This function returns a substring of a given string starting from a specified position and with a
specified length. For example, substring(`MR JOE DOE', 4, 3) returns `JOE'.
AS: This keyword assigns an alias or a temporary name to a field or an expression in the field list. For example, AS f2_sub_up assigns the name f2_sub_up to the expression substring(upper(`mr joe doe'), 4, 3).
You cannot do any of the following:
A. SELECT FROM TABLE dbtabl FIELDS Of1, upper(left( `mr joe doe', 6)) AS f2_up_left, f3,...: This expression uses the wrong SQL function for strings to get the desired result. The left function returns the leftmost characters of a string with a specified length, ignoring the trailing blanks. For example, left( `mr joe doe', 6) returns `mr joe'. Applying the upper function to this result returns `MR JOE', which is not the same as `JOE'.
B. SELECT FROM TABLE dbtabl FIELDS Of1, left(lower(substring( `mr joe doe', 4, 3)), 3) AS f2_left_lo_sub, f3,...: This expression uses unnecessary and incorrect SQL functions for strings to get the desired result. The lower function converts all uppercase characters in a string to lowercase. For example, lower(substring ( `mr joe doe', 4, 3)) returns `joe'. Applying the left function to this result with the same length returns `joe' again, which is not the same as `JOE'. D. SELECT FROM TABLE dbtabl FIELDS Of1, substring(lower(upper( `mr joe doe' ) ), 4, 3) AS f2_sub_lo_up, f3,...: This expression uses unnecessary and incorrect SQL functions for strings to get the desired result. The lower function converts all uppercase characters in a string to lowercase, and the upper function converts all lowercase characters in a string to uppercase. Applying both functions to the same string cancels out the effect of each other and returns the original string. For example, lower(upper( `mr joe doe' ) ) returns `mr joe doe'. Applying the substring function to this result returns `joe', which is not the same as `JOE'. References: 1: SQL Functions for Strings - ABAP Keyword Documentation - SAP Online Help 2: sql_func - String Functions - ABAP Keyword Documentation - SAP Online Help