Exam4Training

Which patterns raise an exception? Note: There are 3 correct answers to this question.

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).

Answer: 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

Exit mobile version