Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,40 @@
{
"id": "G1109",
"pool": "train",
"object_type": "FUNC",
"category": "C",
"attempts": [
{
"stage": "bundle",
"errors": [
"seed/call.tabl.ddl: a table needs the annotation @AbapCatalog.tableCategory (for example #TRANSPARENT, #A)",
"seed/call.tabl.ddl: a table needs the annotation @AbapCatalog.deliveryClass (for example #TRANSPARENT, #A)",
"seed/chg.tabl.ddl: a table needs the annotation @AbapCatalog.tableCategory (for example #TRANSPARENT, #A)",
"seed/chg.tabl.ddl: a table needs the annotation @AbapCatalog.deliveryClass (for example #TRANSPARENT, #A)"
],
"by_check": {
"static": 4
}
},
{
"stage": "validate",
"oracle": null,
"null": null
},
{
"stage": "bundle",
"errors": [
"invalid JSON: Unterminated string starting at: line 1 column 5451 (char 5450)"
],
"by_check": {
"json": 1
}
},
{
"stage": "validate",
"oracle": 0,
"null": 0
}
],
"accepted": false
}

View File

@@ -0,0 +1,129 @@
CLASS {{p}}tel_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS rate
IMPORTING iv_ctype TYPE string
iv_zone TYPE string
iv_secs TYPE i
EXPORTING ev_minutes TYPE i
ev_charge TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS zero_duration FOR TESTING.
METHODS one_minute FOR TESTING.
METHODS rounds_up FOR TESTING.
METHODS rounds_half_up FOR TESTING.
METHODS zone_b FOR TESTING.
METHODS mobile_zone_c FOR TESTING.
METHODS special_zone_a FOR TESTING.
METHODS unknown_ctype FOR TESTING.
METHODS unknown_zone FOR TESTING.
METHODS negative_secs FOR TESTING.
METHODS long_call FOR TESTING.
ENDCLASS.
CLASS {{p}}tel_hidden IMPLEMENTATION.
METHOD rate.
CALL FUNCTION '{{P}}TEL_RATE'
EXPORTING
iv_ctype = iv_ctype
iv_zone = iv_zone
iv_secs = iv_secs
IMPORTING
ev_minutes = ev_minutes
ev_charge = ev_charge
EXCEPTIONS
invalid_duration = 1
OTHERS = 2.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD zero_duration.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = 0
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD one_minute.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = 30
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.12' ) act = lv_charge ).
ENDMETHOD.
METHOD rounds_up.
rate( EXPORTING iv_ctype = 'IT' iv_zone = 'B' iv_secs = 61
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.81' ) act = lv_charge ).
ENDMETHOD.
METHOD rounds_half_up.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = 120
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.21' ) act = lv_charge ).
ENDMETHOD.
METHOD zone_b.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'B' iv_secs = 60
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.22' ) act = lv_charge ).
ENDMETHOD.
METHOD mobile_zone_c.
rate( EXPORTING iv_ctype = 'MO' iv_zone = 'C' iv_secs = 1
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.72' ) act = lv_charge ).
ENDMETHOD.
METHOD special_zone_a.
rate( EXPORTING iv_ctype = 'SP' iv_zone = 'A' iv_secs = 180
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.20' ) act = lv_charge ).
ENDMETHOD.
METHOD unknown_ctype.
rate( EXPORTING iv_ctype = 'XX' iv_zone = 'A' iv_secs = 60
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD unknown_zone.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'Z' iv_secs = 60
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD negative_secs.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = -5
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD long_call.
rate( EXPORTING iv_ctype = 'IT' iv_zone = 'C' iv_secs = 3600
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 60 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '35.43' ) act = lv_charge ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,51 @@
FUNCTION {{p}}tel_rate
IMPORTING
iv_ctype TYPE string
iv_zone TYPE string
iv_secs TYPE i
EXPORTING
ev_minutes TYPE i
ev_charge TYPE decfloat34
EXCEPTIONS
invalid_duration.
TYPES: BEGIN OF ty_price,
ctype TYPE string,
zone TYPE string,
price TYPE decfloat34,
END OF ty_price,
tt_price TYPE SORTED TABLE OF ty_price WITH UNIQUE KEY ctype zone.
DATA lt_prices TYPE tt_price.
DATA ls_price TYPE ty_price.
IF iv_secs < 0.
RAISE invalid_duration.
ENDIF.
IF iv_secs > 0.
ev_minutes = ( iv_secs + 59 ) DIV 60.
lt_prices = VALUE #(
( ctype = 'NT' zone = 'A' price = '0.09' )
( ctype = 'NT' zone = 'B' price = '0.19' )
( ctype = 'NT' zone = 'C' price = '0.29' )
( ctype = 'IT' zone = 'A' price = '0.19' )
( ctype = 'IT' zone = 'B' price = '0.39' )
( ctype = 'IT' zone = 'C' price = '0.59' )
( ctype = 'MO' zone = 'A' price = '0.29' )
( ctype = 'MO' zone = 'B' price = '0.49' )
( ctype = 'MO' zone = 'C' price = '0.69' )
( ctype = 'SP' zone = 'A' price = '0.39' )
( ctype = 'SP' zone = 'B' price = '0.59' )
( ctype = 'SP' zone = 'C' price = '0.79' ) ).
READ TABLE lt_prices INTO ls_price
WITH TABLE KEY ctype = iv_ctype zone = iv_zone.
IF sy-subrc = 0 AND ls_price-price > 0.
ev_charge = round( val = ev_minutes * ls_price-price + 0.025
dec = 2 mode = cl_abap_math=>round_half_up ).
ENDIF.
ENDIF.
ENDFUNCTION.

View File

@@ -0,0 +1,73 @@
CLASS {{p}}tel_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS rate
IMPORTING iv_ctype TYPE string
iv_zone TYPE string
iv_secs TYPE i
EXPORTING ev_minutes TYPE i
ev_charge TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS zero_duration FOR TESTING.
METHODS national_call FOR TESTING.
METHODS rounds_up FOR TESTING.
METHODS unknown_type FOR TESTING.
METHODS negative_secs FOR TESTING.
ENDCLASS.
CLASS {{p}}tel_test IMPLEMENTATION.
METHOD rate.
CALL FUNCTION '{{P}}TEL_RATE'
EXPORTING
iv_ctype = iv_ctype
iv_zone = iv_zone
iv_secs = iv_secs
IMPORTING
ev_minutes = ev_minutes
ev_charge = ev_charge
EXCEPTIONS
invalid_duration = 1
OTHERS = 2.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD zero_duration.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = 0
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD national_call.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = 30
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.12' ) act = lv_charge ).
ENDMETHOD.
METHOD rounds_up.
rate( EXPORTING iv_ctype = 'IT' iv_zone = 'B' iv_secs = 61
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.81' ) act = lv_charge ).
ENDMETHOD.
METHOD unknown_type.
rate( EXPORTING iv_ctype = 'XX' iv_zone = 'A' iv_secs = 60
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD negative_secs.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = -1
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,16 @@
FUNCTION {{p}}tel_sample
IMPORTING
iv_ctype TYPE string
iv_zone TYPE string
iv_secs TYPE i
EXPORTING
ev_minutes TYPE i
ev_charge TYPE decfloat34
EXCEPTIONS
invalid_duration.
" Sample module: it shows the interface of all rating modules.
ev_minutes = 0.
ev_charge = 0.
ENDFUNCTION.

View File

@@ -0,0 +1,63 @@
# 1. Goal
A telephone company rates the calls of its customers. The rating program
collects the data of one call and calls one function module for this call. The
function module must have the same interface as the sample function module,
because the rating program calls all rating modules in the same way.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_TEL exists in package $TMP.
- Function module {{P}}TEL_SAMPLE exists in this group. It is the sample rating
module. Its interface is the interface that all rating modules must use.
- A call has a call type, a destination zone and a duration in seconds.
# 4. Contract
- Create the function module {{P}}TEL_RATE in function group {{P}}FG_TEL.
- Use exactly the interface of {{P}}TEL_SAMPLE:
- importing parameter iv_ctype, type string,
- importing parameter iv_zone, type string,
- importing parameter iv_secs, type i,
- exporting parameter ev_minutes, type i,
- exporting parameter ev_charge, type decfloat34,
- exception invalid_duration.
- iv_ctype is the call type of the call. iv_zone is the destination zone of the
call. iv_secs is the duration of the call in seconds.
- ev_minutes is the billed duration of the call in minutes.
- ev_charge is the charge of the call.
# 5. Business rules
1. If iv_secs is less than 0, raise the exception INVALID_DURATION. ev_minutes
and ev_charge stay 0.
2. ev_minutes is iv_secs rounded up to the next full minute. 1 to 60 seconds is
1 minute. 61 to 120 seconds is 2 minutes. 121 to 180 seconds is 3 minutes,
and so on. If iv_secs is 0, ev_minutes is 0.
3. The price of one billed minute depends on the call type and on the zone:
- call type NT: zone A 0.09, zone B 0.19, zone C 0.29
- call type IT: zone A 0.19, zone B 0.39, zone C 0.59
- call type MO: zone A 0.29, zone B 0.49, zone C 0.69
- call type SP: zone A 0.39, zone B 0.59, zone C 0.79
4. If the call type is not NT, IT, MO or SP, or the zone is not A, B or C, the
price of one minute is 0.
5. If ev_minutes is 0 or the price of one minute is 0, ev_charge is 0.
6. Otherwise ev_charge is ev_minutes multiplied by the price of one minute plus
a connection fee of 0.025. Round ev_charge half up to 2 decimals.
# 6. Constraints
- Release target: 8.16.
- Package: $TMP. Do not use a transport.
- Out of scope: do not change {{P}}TEL_SAMPLE.
- Coding standards: Clean ABAP. A method has fewer than 40 statements.
# 7. Acceptance
- The function module is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests for the function module in a global test class.

View File

@@ -0,0 +1,86 @@
{
"id": "G1109",
"category": "C",
"object_type": "FUNC",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "FUGR",
"name": "{{P}}FG_TEL",
"description": "Call rating modules"
},
{
"type": "FUNC",
"name": "{{P}}TEL_SAMPLE",
"functionGroup": "{{P}}FG_TEL",
"file": "seed/tel_sample.func.abap",
"description": "Sample rating module"
}
],
"contract": [
{
"type": "FUNC",
"name": "{{P}}TEL_RATE",
"functionGroup": "{{P}}FG_TEL",
"params": [
{
"name": "iv_ctype",
"type": "string"
},
{
"name": "iv_zone",
"type": "string"
},
{
"name": "iv_secs",
"type": "i"
},
{
"name": "ev_minutes",
"type": "i"
},
{
"name": "ev_charge",
"type": "decfloat34"
}
]
}
],
"out_of_scope": [
"{{P}}TEL_SAMPLE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}TEL_HIDDEN",
"file": "hidden/tel_hidden.clas.abap",
"description": "Hidden tests for the call rating"
}
],
"reference": [
{
"type": "FUNC",
"name": "{{P}}TEL_RATE",
"functionGroup": "{{P}}FG_TEL",
"file": "reference/tel_rate.func.abap",
"description": "Call rating module"
},
{
"type": "CLAS",
"name": "{{P}}TEL_TEST",
"file": "reference/tel_test.clas.abap",
"description": "Own tests for the call rating"
}
],
"craft_checks": [
"method_length",
"sorted_table_with_key",
"read_table_with_key"
]
}