Snapshot: new training tasks (balanced generation), docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 22:08:59 +02:00
parent eb13453097
commit 6984fc7917
572 changed files with 30024 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Service job cost'
define view entity {{P}}I_JOB_COST
as select from {{p}}job as h
left outer join {{p}}jobl as l on l.job_id = h.job_id
{
key h.job_id as job_id,
h.customer as customer,
h.calc_mode as calc_mode,
h.group_code as group_code,
h.job_date as job_date,
sum( l.work_hours ) as work_hours,
count( * ) as line_count,
sum( case when h.calc_mode = 'F'
then cast( l.rate as abap.dec( 21, 4 ) )
else cast( l.work_hours * l.rate as abap.dec( 21, 4 ) )
end ) as job_value
}
group by
h.job_id,
h.customer,
h.calc_mode,
h.group_code,
h.job_date

View File

@@ -0,0 +1,24 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Service job cost'
define view entity {{P}}I_JOB_COST
as select from {{p}}job as h
inner join {{p}}jobl as l on l.job_id <> h.job_id
{
key h.job_id as job_id,
h.customer as customer,
h.calc_mode as calc_mode,
h.group_code as group_code,
h.job_date as job_date,
sum( l.work_hours ) as work_hours,
count( * ) as line_count,
sum( case when h.calc_mode = 'F'
then cast( l.rate as abap.dec( 21, 4 ) )
else cast( l.work_hours * l.rate as abap.dec( 21, 4 ) )
end ) as job_value
}
group by
h.job_id,
h.customer,
h.calc_mode,
h.group_code,
h.job_date

View File

@@ -0,0 +1,24 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Service job cost'
define view entity {{P}}I_JOB_COST
as select from {{p}}job as h
inner join {{p}}jobl as l on l.job_id = h.job_id
{
key h.job_id as job_id,
h.customer as customer,
h.calc_mode as calc_mode,
h.group_code as group_code,
h.job_date as job_date,
max( l.work_hours ) as work_hours,
count( * ) as line_count,
sum( case when h.calc_mode = 'F'
then cast( l.rate as abap.dec( 21, 4 ) )
else cast( l.work_hours * l.rate as abap.dec( 21, 4 ) )
end ) as job_value
}
group by
h.job_id,
h.customer,
h.calc_mode,
h.group_code,
h.job_date

View File

@@ -0,0 +1,24 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Service job cost'
define view entity {{P}}I_JOB_COST
as select from {{p}}job as h
inner join {{p}}jobl as l on l.job_id = h.job_id
{
key h.job_id as job_id,
h.customer as customer,
h.calc_mode as calc_mode,
h.group_code as group_code,
h.job_date as job_date,
sum( l.work_hours ) as work_hours,
count( * ) as line_count,
sum( case when h.calc_mode <> 'F'
then cast( l.rate as abap.dec( 21, 4 ) )
else cast( l.work_hours * l.rate as abap.dec( 21, 4 ) )
end ) as job_value
}
group by
h.job_id,
h.customer,
h.calc_mode,
h.group_code,
h.job_date

View File

@@ -0,0 +1,24 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Service job cost'
define view entity {{P}}I_JOB_COST
as select from {{p}}job as h
inner join {{p}}jobl as l on l.job_id = h.job_id
{
key h.job_id as job_id,
h.customer as customer,
h.calc_mode as calc_mode,
h.group_code as group_code,
h.job_date as job_date,
sum( l.work_hours ) as work_hours,
count( * ) as line_count,
sum( case when h.calc_mode = 'Z'
then cast( l.rate as abap.dec( 21, 4 ) )
else cast( l.work_hours * l.rate as abap.dec( 21, 4 ) )
end ) as job_value
}
group by
h.job_id,
h.customer,
h.calc_mode,
h.group_code,
h.job_date

View File

@@ -0,0 +1,24 @@
{
"id": "G1927",
"pool": "train",
"object_type": "DDLS",
"category": "E",
"attempts": [
{
"stage": "validate",
"oracle": null,
"null": null
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 5,
"killed": 5,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,101 @@
CLASS {{p}}e21_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS value_hourly FOR TESTING.
METHODS value_fixed FOR TESTING.
METHODS work_hours_sum FOR TESTING.
METHODS line_count FOR TESTING.
METHODS job_without_lines FOR TESTING.
METHODS calc_mode_shown FOR TESTING.
METHODS group_code_shown FOR TESTING.
METHODS customer_shown FOR TESTING.
METHODS job_date_shown FOR TESTING.
METHODS row_count FOR TESTING.
ENDCLASS.
CLASS {{p}}e21_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_JOB_COST' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_job TYPE STANDARD TABLE OF {{p}}job WITH EMPTY KEY.
DATA lt_jobl TYPE STANDARD TABLE OF {{p}}jobl WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_job = VALUE #(
( job_id = 'J1' customer = 'C1' calc_mode = 'H' group_code = 'A1' job_date = '20240101' )
( job_id = 'J2' customer = 'C2' calc_mode = 'F' group_code = 'A2' job_date = '20240102' )
( job_id = 'J3' customer = 'C3' calc_mode = 'H' group_code = 'A1' job_date = '20240103' ) ).
lt_jobl = VALUE #(
( job_id = 'J1' line_no = 1 work_hours = '3.00' rate = '10.00' )
( job_id = 'J1' line_no = 2 work_hours = '1.00' rate = '2.50' )
( job_id = 'J1' line_no = 3 work_hours = '4.00' rate = '0.25' )
( job_id = 'J2' line_no = 1 work_hours = '2.00' rate = '100.00' )
( job_id = 'J2' line_no = 2 work_hours = '5.00' rate = '50.00' ) ).
go_env->insert_test_data( lt_job ).
go_env->insert_test_data( lt_jobl ).
ENDMETHOD.
METHOD value_hourly.
SELECT SINGLE job_value FROM {{p}}i_job_cost WHERE job_id = 'J1' INTO @DATA(lv_value).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '33.50' )
act = CONV decfloat34( lv_value ) ).
ENDMETHOD.
METHOD value_fixed.
SELECT SINGLE job_value FROM {{p}}i_job_cost WHERE job_id = 'J2' INTO @DATA(lv_value).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '150.00' )
act = CONV decfloat34( lv_value ) ).
ENDMETHOD.
METHOD work_hours_sum.
SELECT SINGLE work_hours FROM {{p}}i_job_cost WHERE job_id = 'J1' INTO @DATA(lv_hours).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 8 )
act = CONV decfloat34( lv_hours ) ).
ENDMETHOD.
METHOD line_count.
SELECT SINGLE line_count FROM {{p}}i_job_cost WHERE job_id = 'J1' INTO @DATA(lv_count).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 3 )
act = CONV decfloat34( lv_count ) ).
ENDMETHOD.
METHOD job_without_lines.
SELECT COUNT(*) FROM {{p}}i_job_cost WHERE job_id = 'J3' INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rows ).
ENDMETHOD.
METHOD calc_mode_shown.
SELECT SINGLE calc_mode FROM {{p}}i_job_cost WHERE job_id = 'J2' INTO @DATA(lv_mode).
cl_abap_unit_assert=>assert_equals( exp = 'F' act = lv_mode ).
ENDMETHOD.
METHOD group_code_shown.
SELECT SINGLE group_code FROM {{p}}i_job_cost WHERE job_id = 'J1' INTO @DATA(lv_group).
cl_abap_unit_assert=>assert_equals( exp = 'A1' act = lv_group ).
ENDMETHOD.
METHOD customer_shown.
SELECT SINGLE customer FROM {{p}}i_job_cost WHERE job_id = 'J1' INTO @DATA(lv_customer).
cl_abap_unit_assert=>assert_equals( exp = 'C1' act = lv_customer ).
ENDMETHOD.
METHOD job_date_shown.
SELECT SINGLE job_date FROM {{p}}i_job_cost WHERE job_id = 'J1' INTO @DATA(lv_date).
cl_abap_unit_assert=>assert_equals( exp = '20240101' act = lv_date ).
ENDMETHOD.
METHOD row_count.
SELECT COUNT(*) FROM {{p}}i_job_cost INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rows ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,61 @@
{
"task": "G1927",
"mutants": [
{
"object": "{{P}}I_JOB_COST",
"mutant": "line 5: inner join -> left outer join (join)",
"status": "killed",
"hidden": "8/10",
"failed_tests": [
"JOB_WITHOUT_LINES",
"ROW_COUNT"
]
},
{
"object": "{{P}}I_JOB_COST",
"mutant": "line 5: = -> <> (eq)",
"status": "killed",
"hidden": "4/10",
"failed_tests": [
"JOB_WITHOUT_LINES",
"LINE_COUNT",
"ROW_COUNT",
"VALUE_FIXED",
"VALUE_HOURLY",
"WORK_HOURS_SUM"
]
},
{
"object": "{{P}}I_JOB_COST",
"mutant": "line 12: sum( -> max( (agg)",
"status": "killed",
"hidden": "9/10",
"failed_tests": [
"WORK_HOURS_SUM"
]
},
{
"object": "{{P}}I_JOB_COST",
"mutant": "line 14: = -> <> (eq)",
"status": "killed",
"hidden": "8/10",
"failed_tests": [
"VALUE_FIXED",
"VALUE_HOURLY"
]
},
{
"object": "{{P}}I_JOB_COST",
"mutant": "line 14: 'F' -> 'Z' (lit)",
"status": "killed",
"hidden": "9/10",
"failed_tests": [
"VALUE_FIXED"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,55 @@
CLASS {{p}}e21_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS hourly_value FOR TESTING.
METHODS fixed_value FOR TESTING.
ENDCLASS.
CLASS {{p}}e21_test IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_JOB_COST' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
go_env->clear_doubles( ).
ENDMETHOD.
METHOD hourly_value.
DATA lt_job TYPE STANDARD TABLE OF {{p}}job WITH EMPTY KEY.
DATA lt_jobl TYPE STANDARD TABLE OF {{p}}jobl WITH EMPTY KEY.
lt_job = VALUE #( ( job_id = 'A' customer = 'C1' calc_mode = 'H'
group_code = 'G1' job_date = '20240101' ) ).
lt_jobl = VALUE #( ( job_id = 'A' line_no = 1 work_hours = '2.00' rate = '10.00' )
( job_id = 'A' line_no = 2 work_hours = '1.50' rate = '4.00' ) ).
go_env->insert_test_data( lt_job ).
go_env->insert_test_data( lt_jobl ).
SELECT SINGLE work_hours, job_value FROM {{p}}i_job_cost WHERE job_id = 'A'
INTO @DATA(ls_row).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '3.50' )
act = CONV decfloat34( ls_row-work_hours ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '26.00' )
act = CONV decfloat34( ls_row-job_value ) ).
ENDMETHOD.
METHOD fixed_value.
DATA lt_job TYPE STANDARD TABLE OF {{p}}job WITH EMPTY KEY.
DATA lt_jobl TYPE STANDARD TABLE OF {{p}}jobl WITH EMPTY KEY.
lt_job = VALUE #( ( job_id = 'B' customer = 'C2' calc_mode = 'F'
group_code = 'G2' job_date = '20240102' ) ).
lt_jobl = VALUE #( ( job_id = 'B' line_no = 1 work_hours = '1.00' rate = '75.00' ) ).
go_env->insert_test_data( lt_job ).
go_env->insert_test_data( lt_jobl ).
SELECT SINGLE job_value FROM {{p}}i_job_cost WHERE job_id = 'B' INTO @DATA(lv_value).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '75.00' )
act = CONV decfloat34( lv_value ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,24 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Service job cost'
define view entity {{P}}I_JOB_COST
as select from {{p}}job as h
inner join {{p}}jobl as l on l.job_id = h.job_id
{
key h.job_id as job_id,
h.customer as customer,
h.calc_mode as calc_mode,
h.group_code as group_code,
h.job_date as job_date,
sum( l.work_hours ) as work_hours,
count( * ) as line_count,
sum( case when h.calc_mode = 'F'
then cast( l.rate as abap.dec( 21, 4 ) )
else cast( l.work_hours * l.rate as abap.dec( 21, 4 ) )
end ) as job_value
}
group by
h.job_id,
h.customer,
h.calc_mode,
h.group_code,
h.job_date

View File

@@ -0,0 +1,24 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Service job cost'
define view entity {{P}}I_JOB_COST
as select from {{p}}job as h
inner join {{p}}jobl as l on l.job_id = h.job_id
{
key h.job_id as job_id,
h.customer as customer_name,
h.calc_mode as calc_mode_cd,
h.group_code as group_code,
h.job_date as job_date,
sum( l.work_hours ) as hours_sum,
count( * ) as line_count,
sum( case when h.calc_mode = 'F'
then cast( l.rate as abap.dec( 21, 4 ) )
else cast( l.work_hours * l.rate as abap.dec( 21, 4 ) )
end ) as value_sum
}
group by
h.job_id,
h.customer,
h.calc_mode,
h.group_code,
h.job_date

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Service job'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}job {
key client : abap.clnt not null;
key job_id : abap.char(10) not null;
customer : abap.char(10);
calc_mode : abap.char(1);
group_code : abap.char(2);
job_date : abap.dats;
}

View File

@@ -0,0 +1,12 @@
@EndUserText.label : 'Service job work line'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}jobl {
key client : abap.clnt not null;
key job_id : abap.char(10) not null;
key line_no : abap.int4 not null;
work_hours : abap.dec(5,2);
rate : abap.dec(15,2);
}

View File

@@ -0,0 +1,51 @@
# 1. Goal
The CDS view entity {{P}}I_JOB_COST in package $TMP shows the cost of the
service jobs of a wind turbine service company. The view is active. Its element
names are old abbreviations that carry stems of SQL keywords. Refactor the view
in place. Keep the view name. Keep the behavior. Rename the elements to the
safe names of the contract.
# 2. Open questions
None.
# 3. Context
- Table {{P}}JOB (service job), package $TMP. Key: JOB_ID (CHAR 10).
Fields: CUSTOMER (CHAR 10), CALC_MODE (CHAR 1), GROUP_CODE (CHAR 2),
JOB_DATE (DATS).
- Table {{P}}JOBL (work line of a service job), package $TMP.
Key: JOB_ID (CHAR 10), LINE_NO (INT4). Fields: WORK_HOURS (DEC 5,2),
RATE (DEC 15,2).
- The view {{P}}I_JOB_COST is in package $TMP and is active. The current
definition of the view is the specification of the calculation.
- A report and an OData service read the view. They use the element names of
the contract.
# 4. Contract
- The CDS view entity {{P}}I_JOB_COST in package $TMP. The view name stays the
same.
- Elements, with these names. They replace the current element names:
- JOB_ID (key)
- CUSTOMER
- CALC_MODE
- GROUP_CODE
- JOB_DATE
- WORK_HOURS
- LINE_COUNT
- JOB_VALUE
- No authorization check (#NOT_REQUIRED).
# 5. Business rules
1. The behavior of {{P}}I_JOB_COST must not change. Read the current definition
of the view in package $TMP. It is the specification of the calculation.
2. The element names are the names in the contract. No element name is a
reserved word.
# 6. Constraints
- Release target: 8.16 (ABAP Platform 2025).
- Coding standards: Clean ABAP. No ATC priority 1 or 2 findings.
- Out of scope: do not change {{P}}JOB and {{P}}JOBL.
# 7. Acceptance
- The view {{P}}I_JOB_COST is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests with CL_CDS_TEST_ENVIRONMENT in a global test class.

View File

@@ -0,0 +1,75 @@
{
"id": "G1927",
"category": "E",
"object_type": "DDLS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}JOB",
"file": "seed/job.tabl.asabap",
"description": "Service job header"
},
{
"type": "TABL",
"name": "{{P}}JOBL",
"file": "seed/jobl.tabl.asabap",
"description": "Service job work line"
},
{
"type": "DDLS",
"name": "{{P}}I_JOB_COST",
"file": "seed/i_job_cost.ddls.asddls",
"description": "Legacy service job cost view"
}
],
"contract": [
{
"type": "DDLS",
"name": "{{P}}I_JOB_COST",
"fields": [
"JOB_ID",
"CUSTOMER",
"CALC_MODE",
"GROUP_CODE",
"JOB_DATE",
"WORK_HOURS",
"LINE_COUNT",
"JOB_VALUE"
]
}
],
"out_of_scope": [
"{{P}}JOB",
"{{P}}JOBL"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}E21_HIDDEN",
"file": "hidden/e21_hidden.clas.abap",
"description": "E21 hidden tests"
}
],
"reference": [
{
"type": "DDLS",
"name": "{{P}}I_JOB_COST",
"file": "reference/i_job_cost.ddls.asddls",
"description": "Service job cost view"
},
{
"type": "CLAS",
"name": "{{P}}E21_TEST",
"file": "reference/e21_test.clas.abap",
"description": "E21 own tests"
}
],
"craft_checks": []
}