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,15 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product quality totals'
define view entity {{P}}I_PRODUCT_QUALITY
as select from {{p}}i_batch_quality
{
key product as product,
count( * ) as batch_count,
max( bars_total ) as bars_total,
sum( bars_good ) as bars_good,
sum( bars_scrap ) as bars_scrap,
cast( cast( sum( bars_good ) as abap.dec(15,2) ) * 100
/ cast( sum( bars_total ) as abap.dec(15,2) )
as abap.dec(5,2) ) as yield_pct
}
group by product

View File

@@ -0,0 +1,15 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product quality totals'
define view entity {{P}}I_PRODUCT_QUALITY
as select from {{p}}i_batch_quality
{
key product as product,
count( * ) as batch_count,
sum( bars_total ) as bars_total,
max( bars_good ) as bars_good,
sum( bars_scrap ) as bars_scrap,
cast( cast( sum( bars_good ) as abap.dec(15,2) ) * 100
/ cast( sum( bars_total ) as abap.dec(15,2) )
as abap.dec(5,2) ) as yield_pct
}
group by product

View File

@@ -0,0 +1,15 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product quality totals'
define view entity {{P}}I_PRODUCT_QUALITY
as select from {{p}}i_batch_quality
{
key product as product,
count( * ) as batch_count,
sum( bars_total ) as bars_total,
sum( bars_good ) as bars_good,
max( bars_scrap ) as bars_scrap,
cast( cast( sum( bars_good ) as abap.dec(15,2) ) * 100
/ cast( sum( bars_total ) as abap.dec(15,2) )
as abap.dec(5,2) ) as yield_pct
}
group by product

View File

@@ -0,0 +1,15 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product quality totals'
define view entity {{P}}I_PRODUCT_QUALITY
as select from {{p}}i_batch_quality
{
key product as product,
count( * ) as batch_count,
sum( bars_total ) as bars_total,
sum( bars_good ) as bars_good,
sum( bars_scrap ) as bars_scrap,
cast( cast( max( bars_good ) as abap.dec(15,2) ) * 100
/ cast( sum( bars_total ) as abap.dec(15,2) )
as abap.dec(5,2) ) as yield_pct
}
group by product

View File

@@ -0,0 +1,15 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product quality totals'
define view entity {{P}}I_PRODUCT_QUALITY
as select from {{p}}i_batch_quality
{
key product as product,
count( * ) as batch_count,
sum( bars_total ) as bars_total,
sum( bars_good ) as bars_good,
sum( bars_scrap ) as bars_scrap,
cast( cast( sum( bars_good ) as abap.dec(15,2) ) * 100
/ cast( max( bars_total ) as abap.dec(15,2) )
as abap.dec(5,2) ) as yield_pct
}
group by product

View File

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

View File

@@ -0,0 +1,115 @@
CLASS {{p}}t41_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 one_row_per_product FOR TESTING.
METHODS batch_count_choc FOR TESTING.
METHODS batch_count_dark FOR TESTING.
METHODS total_bars_choc FOR TESTING.
METHODS good_bars_choc FOR TESTING.
METHODS scrap_bars_choc FOR TESTING.
METHODS yield_choc FOR TESTING.
METHODS yield_dark FOR TESTING.
METHODS yield_milk FOR TESTING.
ENDCLASS.
CLASS {{p}}t41_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_PRODUCT_QUALITY' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_quality TYPE STANDARD TABLE OF {{p}}i_batch_quality WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_quality = VALUE #(
( batch_id = 'B1' product = 'CHOC' site = '1000' prod_date = '20250101'
bars_total = 1000 bars_good = 900 bars_scrap = 100 )
( batch_id = 'B2' product = 'CHOC' site = '1000' prod_date = '20250102'
bars_total = 1000 bars_good = 750 bars_scrap = 250 )
( batch_id = 'B3' product = 'DARK' site = '2000' prod_date = '20250103'
bars_total = 2000 bars_good = 1234 bars_scrap = 766 )
( batch_id = 'B4' product = 'MILK' site = '1000' prod_date = '20250105'
bars_total = 4 bars_good = 3 bars_scrap = 1 ) ).
go_env->insert_test_data( lt_quality ).
ENDMETHOD.
METHOD one_row_per_product.
DATA lv_rows TYPE i.
SELECT COUNT(*) FROM {{p}}i_product_quality INTO @lv_rows.
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_rows ).
ENDMETHOD.
METHOD batch_count_choc.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'CHOC' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV i( 2 )
act = CONV i( ls_row-batch_count ) ).
ENDMETHOD.
METHOD batch_count_dark.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'DARK' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV i( 1 )
act = CONV i( ls_row-batch_count ) ).
ENDMETHOD.
METHOD total_bars_choc.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'CHOC' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV i( 2000 )
act = CONV i( ls_row-bars_total ) ).
ENDMETHOD.
METHOD good_bars_choc.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'CHOC' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV i( 1650 )
act = CONV i( ls_row-bars_good ) ).
ENDMETHOD.
METHOD scrap_bars_choc.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'CHOC' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV i( 350 )
act = CONV i( ls_row-bars_scrap ) ).
ENDMETHOD.
METHOD yield_choc.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'CHOC' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '82.50' )
act = CONV decfloat34( ls_row-yield_pct ) ).
ENDMETHOD.
METHOD yield_dark.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'DARK' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '61.70' )
act = CONV decfloat34( ls_row-yield_pct ) ).
ENDMETHOD.
METHOD yield_milk.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'MILK' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '75.00' )
act = CONV decfloat34( ls_row-yield_pct ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,54 @@
{
"task": "G1950",
"mutants": [
{
"object": "{{P}}I_PRODUCT_QUALITY",
"mutant": "line 8: sum( -> max( (agg)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"TOTAL_BARS_CHOC"
]
},
{
"object": "{{P}}I_PRODUCT_QUALITY",
"mutant": "line 9: sum( -> max( (agg)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"GOOD_BARS_CHOC"
]
},
{
"object": "{{P}}I_PRODUCT_QUALITY",
"mutant": "line 10: sum( -> max( (agg)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"SCRAP_BARS_CHOC"
]
},
{
"object": "{{P}}I_PRODUCT_QUALITY",
"mutant": "line 11: sum( -> max( (agg)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"YIELD_CHOC"
]
},
{
"object": "{{P}}I_PRODUCT_QUALITY",
"mutant": "line 12: sum( -> max( (agg)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"YIELD_CHOC"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,15 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product quality totals'
define view entity {{P}}I_PRODUCT_QUALITY
as select from {{p}}i_batch_quality
{
key product as product,
count( * ) as batch_count,
sum( bars_total ) as bars_total,
sum( bars_good ) as bars_good,
sum( bars_scrap ) as bars_scrap,
cast( cast( sum( bars_good ) as abap.dec(15,2) ) * 100
/ cast( sum( bars_total ) as abap.dec(15,2) )
as abap.dec(5,2) ) as yield_pct
}
group by product

View File

@@ -0,0 +1,49 @@
CLASS {{p}}t41_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 totals_of_one_product FOR TESTING.
ENDCLASS.
CLASS {{p}}t41_test IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_PRODUCT_QUALITY' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_quality TYPE STANDARD TABLE OF {{p}}i_batch_quality WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_quality = VALUE #(
( batch_id = 'A1' product = 'BAR' site = '1000' prod_date = '20250101'
bars_total = 400 bars_good = 300 bars_scrap = 100 )
( batch_id = 'A2' product = 'BAR' site = '1000' prod_date = '20250102'
bars_total = 600 bars_good = 300 bars_scrap = 300 ) ).
go_env->insert_test_data( lt_quality ).
ENDMETHOD.
METHOD totals_of_one_product.
DATA ls_row TYPE {{p}}i_product_quality.
SELECT SINGLE * FROM {{p}}i_product_quality
WHERE product = 'BAR' INTO @ls_row.
cl_abap_unit_assert=>assert_equals( exp = CONV i( 2 )
act = CONV i( ls_row-batch_count ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV i( 1000 )
act = CONV i( ls_row-bars_total ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV i( 600 )
act = CONV i( ls_row-bars_good ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV i( 400 )
act = CONV i( ls_row-bars_scrap ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '60.00' )
act = CONV decfloat34( ls_row-yield_pct ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,14 @@
@EndUserText.label : 'Production batch'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}batch {
key client : abap.clnt not null;
key batch_id : abap.char(10) not null;
product : abap.char(10);
site : abap.char(4);
prod_date : abap.dats;
bars_total : abap.int4;
bars_good : abap.int4;
}

View File

@@ -0,0 +1,14 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Batch quality'
define view entity {{P}}I_BATCH_QUALITY
as select from {{p}}batch
{
key batch_id as batch_id,
product as product,
site as site,
prod_date as prod_date,
bars_total as bars_total,
bars_good as bars_good,
bars_total - bars_good as bars_scrap
}
where bars_total > 0

View File

@@ -0,0 +1,46 @@
# 1. Goal
The chocolate factory "Cocoa Lane" produces chocolate bars in batches. The
production team needs the quality totals of each product. A dashboard and an
OData service read these totals. Therefore the calculation must be in the
database, in a CDS view. The new view reuses the existing batch view.
# 2. Open questions
None.
# 3. Context
- The view entity {{P}}I_BATCH_QUALITY in package $TMP shows the production
batches that produced bars. The production team already uses this view in a
dashboard.
- The signature of {{P}}I_BATCH_QUALITY is not in this document. Read the view
entity to see its elements and its source.
- The database table behind {{P}}I_BATCH_QUALITY is a seed object in package
$TMP.
# 4. Contract
- Create the CDS view entity {{P}}I_PRODUCT_QUALITY in package $TMP.
- The new view reads from {{P}}I_BATCH_QUALITY. Do not change
{{P}}I_BATCH_QUALITY.
- The view has these elements, with these names: PRODUCT (key), BATCH_COUNT,
BARS_TOTAL, BARS_GOOD, BARS_SCRAP, YIELD_PCT.
- No authorization check (#NOT_REQUIRED).
# 5. Business rules
1. Show one row for each product that has at least one batch in
{{P}}I_BATCH_QUALITY.
2. PRODUCT is the product code.
3. BATCH_COUNT is the number of batches of the product.
4. BARS_TOTAL is the sum of the total bars of these batches.
5. BARS_GOOD is the sum of the good bars of these batches.
6. BARS_SCRAP is the sum of the scrap bars of these batches.
7. YIELD_PCT is BARS_GOOD as a percentage of BARS_TOTAL, with 2 decimal
places. Example: 600 good bars out of 1000 total bars is 60.00.
# 6. Constraints
- Release target: 8.16 (SAP_BASIS 816).
- Coding standard: Clean ABAP.
- Out of scope: do not change {{P}}I_BATCH_QUALITY and {{P}}BATCH.
# 7. Acceptance
- The view 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,67 @@
{
"id": "G1950",
"category": "F",
"object_type": "DDLS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}BATCH",
"file": "seed/batch.tabl.asabap",
"description": "Production batch of the chocolate factory"
},
{
"type": "DDLS",
"name": "{{P}}I_BATCH_QUALITY",
"file": "seed/i_batch_quality.ddls.asddls",
"description": "Batch quality view, already used by the dashboard"
}
],
"contract": [
{
"type": "DDLS",
"name": "{{P}}I_PRODUCT_QUALITY",
"fields": [
"PRODUCT",
"BATCH_COUNT",
"BARS_TOTAL",
"BARS_GOOD",
"BARS_SCRAP",
"YIELD_PCT"
]
}
],
"out_of_scope": [
"{{P}}BATCH",
"{{P}}I_BATCH_QUALITY"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T41_HIDDEN",
"file": "hidden/t41_hidden.clas.abap",
"description": "Hidden tests for the product quality view"
}
],
"reference": [
{
"type": "DDLS",
"name": "{{P}}I_PRODUCT_QUALITY",
"file": "reference/i_product_quality.ddls.asddls",
"description": "Product quality totals"
},
{
"type": "CLAS",
"name": "{{P}}T41_TEST",
"file": "reference/t41_test.clas.abap",
"description": "Own ABAP Unit tests for the view"
}
],
"craft_checks": []
}