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,17 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Purchase order value'
define view entity {{P}}I_PO_VALUE
as select from {{p}}po_head as head
left outer join {{p}}po_item as item on item.po_no = head.po_no
and item.fiscal_year = head.fiscal_year
{
key head.po_no as po_no,
key head.fiscal_year as fiscal_year,
head.supplier as supplier,
count( * ) as item_count,
sum( cast( item.quantity as abap.dec( 13, 0 ) ) * item.price ) as total_value
}
group by
head.po_no,
head.fiscal_year,
head.supplier

View File

@@ -0,0 +1,17 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Purchase order value'
define view entity {{P}}I_PO_VALUE
as select from {{p}}po_head as head
inner join {{p}}po_item as item on item.po_no <> head.po_no
and item.fiscal_year = head.fiscal_year
{
key head.po_no as po_no,
key head.fiscal_year as fiscal_year,
head.supplier as supplier,
count( * ) as item_count,
sum( cast( item.quantity as abap.dec( 13, 0 ) ) * item.price ) as total_value
}
group by
head.po_no,
head.fiscal_year,
head.supplier

View File

@@ -0,0 +1,17 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Purchase order value'
define view entity {{P}}I_PO_VALUE
as select from {{p}}po_head as head
inner join {{p}}po_item as item on item.po_no = head.po_no
or item.fiscal_year = head.fiscal_year
{
key head.po_no as po_no,
key head.fiscal_year as fiscal_year,
head.supplier as supplier,
count( * ) as item_count,
sum( cast( item.quantity as abap.dec( 13, 0 ) ) * item.price ) as total_value
}
group by
head.po_no,
head.fiscal_year,
head.supplier

View File

@@ -0,0 +1,17 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Purchase order value'
define view entity {{P}}I_PO_VALUE
as select from {{p}}po_head as head
inner join {{p}}po_item as item on item.po_no = head.po_no
and item.fiscal_year <> head.fiscal_year
{
key head.po_no as po_no,
key head.fiscal_year as fiscal_year,
head.supplier as supplier,
count( * ) as item_count,
sum( cast( item.quantity as abap.dec( 13, 0 ) ) * item.price ) as total_value
}
group by
head.po_no,
head.fiscal_year,
head.supplier

View File

@@ -0,0 +1,17 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Purchase order value'
define view entity {{P}}I_PO_VALUE
as select from {{p}}po_head as head
inner join {{p}}po_item as item on item.po_no = head.po_no
and item.fiscal_year = head.fiscal_year
{
key head.po_no as po_no,
key head.fiscal_year as fiscal_year,
head.supplier as supplier,
count( * ) as item_count,
max( cast( item.quantity as abap.dec( 13, 0 ) ) * item.price ) as total_value
}
group by
head.po_no,
head.fiscal_year,
head.supplier

View File

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

View File

@@ -0,0 +1,95 @@
CLASS {{p}}tpo_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 total_of_2023 FOR TESTING.
METHODS total_of_2024 FOR TESTING.
METHODS counts_not_mixed FOR TESTING.
METHODS order_without_items FOR TESTING.
METHODS supplier_shown FOR TESTING.
METHODS two_rows_same_no FOR TESTING.
METHODS decimals FOR TESTING.
METHODS year_in_result FOR TESTING.
ENDCLASS.
CLASS {{p}}tpo_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_PO_VALUE' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_head TYPE STANDARD TABLE OF {{p}}po_head WITH EMPTY KEY.
DATA lt_item TYPE STANDARD TABLE OF {{p}}po_item WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_head = VALUE #( ( po_no = '1000' fiscal_year = '2023' supplier = 'ALPHA' )
( po_no = '1000' fiscal_year = '2024' supplier = 'BETA' )
( po_no = '2000' fiscal_year = '2023' supplier = 'GAMMA' )
( po_no = '3000' fiscal_year = '2024' supplier = 'DELTA' ) ).
lt_item = VALUE #( ( po_no = '1000' fiscal_year = '2023' item_no = 1 quantity = 3 price = '10.00' )
( po_no = '1000' fiscal_year = '2023' item_no = 2 quantity = 2 price = '5.00' )
( po_no = '1000' fiscal_year = '2024' item_no = 1 quantity = 1 price = '7.50' )
( po_no = '3000' fiscal_year = '2024' item_no = 1 quantity = 4 price = '2.25' ) ).
go_env->insert_test_data( lt_head ).
go_env->insert_test_data( lt_item ).
ENDMETHOD.
METHOD total_of_2023.
SELECT SINGLE total_value FROM {{p}}i_po_value
WHERE po_no = '1000' AND fiscal_year = '2023' INTO @DATA(lv_total).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '40.00' )
act = CONV decfloat34( lv_total ) ).
ENDMETHOD.
METHOD total_of_2024.
SELECT SINGLE total_value FROM {{p}}i_po_value
WHERE po_no = '1000' AND fiscal_year = '2024' INTO @DATA(lv_total).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '7.50' )
act = CONV decfloat34( lv_total ) ).
ENDMETHOD.
METHOD counts_not_mixed.
SELECT SINGLE item_count FROM {{p}}i_po_value
WHERE po_no = '1000' AND fiscal_year = '2023' INTO @DATA(lv_count).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_count ).
SELECT SINGLE item_count FROM {{p}}i_po_value
WHERE po_no = '1000' AND fiscal_year = '2024' INTO @DATA(lv_count_2024).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_count_2024 ).
ENDMETHOD.
METHOD order_without_items.
SELECT COUNT(*) FROM {{p}}i_po_value INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_rows ).
ENDMETHOD.
METHOD supplier_shown.
SELECT SINGLE supplier FROM {{p}}i_po_value
WHERE po_no = '1000' AND fiscal_year = '2024' INTO @DATA(lv_supplier).
cl_abap_unit_assert=>assert_equals( exp = 'BETA' act = lv_supplier ).
ENDMETHOD.
METHOD two_rows_same_no.
SELECT COUNT(*) FROM {{p}}i_po_value WHERE po_no = '1000' INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rows ).
ENDMETHOD.
METHOD decimals.
SELECT SINGLE total_value FROM {{p}}i_po_value
WHERE po_no = '3000' AND fiscal_year = '2024' INTO @DATA(lv_total).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '9.00' )
act = CONV decfloat34( lv_total ) ).
ENDMETHOD.
METHOD year_in_result.
SELECT SINGLE fiscal_year FROM {{p}}i_po_value
WHERE po_no = '1000' AND supplier = 'BETA' INTO @DATA(lv_year).
cl_abap_unit_assert=>assert_equals( exp = '2024' act = lv_year ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,66 @@
{
"task": "G1091",
"mutants": [
{
"object": "{{P}}I_PO_VALUE",
"mutant": "line 5: inner join -> left outer join (join)",
"status": "killed",
"hidden": "7/8",
"failed_tests": [
"ORDER_WITHOUT_ITEMS"
]
},
{
"object": "{{P}}I_PO_VALUE",
"mutant": "line 5: = -> <> (eq)",
"status": "killed",
"hidden": "3/8",
"failed_tests": [
"COUNTS_NOT_MIXED",
"DECIMALS",
"TOTAL_OF_2023",
"TOTAL_OF_2024",
"TWO_ROWS_SAME_NO"
]
},
{
"object": "{{P}}I_PO_VALUE",
"mutant": "line 6: and -> or (logic)",
"status": "killed",
"hidden": "3/8",
"failed_tests": [
"COUNTS_NOT_MIXED",
"DECIMALS",
"ORDER_WITHOUT_ITEMS",
"TOTAL_OF_2023",
"TOTAL_OF_2024"
]
},
{
"object": "{{P}}I_PO_VALUE",
"mutant": "line 6: = -> <> (eq)",
"status": "killed",
"hidden": "3/8",
"failed_tests": [
"COUNTS_NOT_MIXED",
"DECIMALS",
"ORDER_WITHOUT_ITEMS",
"TOTAL_OF_2023",
"TOTAL_OF_2024"
]
},
{
"object": "{{P}}I_PO_VALUE",
"mutant": "line 12: sum( -> max( (agg)",
"status": "killed",
"hidden": "7/8",
"failed_tests": [
"TOTAL_OF_2023"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,17 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Purchase order value'
define view entity {{P}}I_PO_VALUE
as select from {{p}}po_head as head
inner join {{p}}po_item as item on item.po_no = head.po_no
and item.fiscal_year = head.fiscal_year
{
key head.po_no as po_no,
key head.fiscal_year as fiscal_year,
head.supplier as supplier,
count( * ) as item_count,
sum( cast( item.quantity as abap.dec( 13, 0 ) ) * item.price ) as total_value
}
group by
head.po_no,
head.fiscal_year,
head.supplier

View File

@@ -0,0 +1,53 @@
CLASS {{p}}tpo_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 same_number_two_years FOR TESTING.
METHODS single_item_orders FOR TESTING.
ENDCLASS.
CLASS {{p}}tpo_test IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_PO_VALUE' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_head TYPE STANDARD TABLE OF {{p}}po_head WITH EMPTY KEY.
DATA lt_item TYPE STANDARD TABLE OF {{p}}po_item WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_head = VALUE #( ( po_no = '5000' fiscal_year = '2022' supplier = 'SUP1' )
( po_no = '5000' fiscal_year = '2023' supplier = 'SUP2' ) ).
lt_item = VALUE #( ( po_no = '5000' fiscal_year = '2022' item_no = 1 quantity = 1 price = '1.00' )
( po_no = '5000' fiscal_year = '2023' item_no = 1 quantity = 2 price = '2.00' ) ).
go_env->insert_test_data( lt_head ).
go_env->insert_test_data( lt_item ).
ENDMETHOD.
METHOD same_number_two_years.
SELECT SINGLE total_value FROM {{p}}i_po_value
WHERE po_no = '5000' AND fiscal_year = '2022' INTO @DATA(lv_total).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.00' )
act = CONV decfloat34( lv_total ) ).
SELECT SINGLE total_value FROM {{p}}i_po_value
WHERE po_no = '5000' AND fiscal_year = '2023' INTO @DATA(lv_total_2023).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '4.00' )
act = CONV decfloat34( lv_total_2023 ) ).
ENDMETHOD.
METHOD single_item_orders.
SELECT SINGLE item_count FROM {{p}}i_po_value
WHERE po_no = '5000' AND fiscal_year = '2022' INTO @DATA(lv_count).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_count ).
SELECT SINGLE item_count FROM {{p}}i_po_value
WHERE po_no = '5000' AND fiscal_year = '2023' INTO @DATA(lv_count_2023).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_count_2023 ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,16 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Purchase order value'
define view entity {{P}}I_PO_VALUE
as select from {{p}}po_head as head
inner join {{p}}po_item as item on item.po_no = head.po_no
{
key head.po_no as po_no,
key head.fiscal_year as fiscal_year,
head.supplier as supplier,
count( * ) as item_count,
sum( cast( item.quantity as abap.dec( 13, 0 ) ) * item.price ) as total_value
}
group by
head.po_no,
head.fiscal_year,
head.supplier

View File

@@ -0,0 +1,12 @@
@EndUserText.label : 'Purchase order header'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}po_head {
key client : abap.clnt not null;
key po_no : abap.char(10) not null;
key fiscal_year : abap.char(4) not null;
supplier : abap.char(10);
po_date : abap.dats;
}

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Purchase order item'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}po_item {
key client : abap.clnt not null;
key po_no : abap.char(10) not null;
key fiscal_year : abap.char(4) not null;
key item_no : abap.int4 not null;
quantity : abap.int4;
price : abap.dec(15,2);
}

View File

@@ -0,0 +1,45 @@
# 1. Goal
The CDS view entity {{P}}I_PO_VALUE shows the value of each purchase order of
an electronics company. The view gives a wrong result. When two purchase orders
have the same order number in two different fiscal years, the view shows a
total that is too high and an item count that is too high for both orders.
Fix the view. Each row must use only the items of its own purchase order.
# 2. Open questions
None.
# 3. Context
- The CDS view entity {{P}}I_PO_VALUE is in package $TMP. It is active. It reads
the tables {{P}}PO_HEAD and {{P}}PO_ITEM.
- Table {{P}}PO_HEAD (purchase order header), package $TMP.
Key: PO_NO (CHAR 10), FISCAL_YEAR (CHAR 4).
Fields: SUPPLIER (CHAR 10), PO_DATE (DATS).
- Table {{P}}PO_ITEM (purchase order item), package $TMP.
Key: PO_NO (CHAR 10), FISCAL_YEAR (CHAR 4), ITEM_NO (INT4).
Fields: QUANTITY (INT4), PRICE (DEC 15,2, the price for one unit).
- An order number is unique only inside one fiscal year. Two purchase orders can
have the same PO_NO in two different fiscal years.
- Read the current source of the view before you change it.
# 4. Contract
- Fix the CDS view entity {{P}}I_PO_VALUE in package $TMP. The name of the view
and the names of the elements do not change.
- Elements: PO_NO (key), FISCAL_YEAR (key), SUPPLIER, ITEM_COUNT, TOTAL_VALUE.
- The authorization check stays #NOT_REQUIRED.
# 5. Business rules
1. A purchase order is identified by PO_NO together with FISCAL_YEAR.
2. A row uses only the items of its own purchase order. Items of another
purchase order with the same PO_NO must not change ITEM_COUNT and must not
change TOTAL_VALUE.
3. All other behavior of the view stays the same.
# 6. Constraints
- Release target: 8.16 (SAP_BASIS 816, ABAP Platform 2025).
- Coding standards: Clean ABAP. Keep the view simple.
- Out of scope: do not change the tables {{P}}PO_HEAD and {{P}}PO_ITEM.
# 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,72 @@
{
"id": "G1091",
"category": "I",
"object_type": "DDLS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}PO_HEAD",
"file": "seed/po_head.tabl.asabap",
"description": "Purchase order header"
},
{
"type": "TABL",
"name": "{{P}}PO_ITEM",
"file": "seed/po_item.tabl.asabap",
"description": "Purchase order item"
},
{
"type": "DDLS",
"name": "{{P}}I_PO_VALUE",
"file": "seed/i_po_value.ddls.asddls",
"description": "Faulty purchase order value view"
}
],
"contract": [
{
"type": "DDLS",
"name": "{{P}}I_PO_VALUE",
"fields": [
"PO_NO",
"FISCAL_YEAR",
"SUPPLIER",
"ITEM_COUNT",
"TOTAL_VALUE"
]
}
],
"out_of_scope": [
"{{P}}PO_HEAD",
"{{P}}PO_ITEM"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}TPO_HIDDEN",
"file": "hidden/tpo_hidden.clas.abap",
"description": "Hidden tests for the fixed purchase order value view"
}
],
"reference": [
{
"type": "DDLS",
"name": "{{P}}I_PO_VALUE",
"file": "reference/i_po_value.ddls.asddls",
"description": "Fixed purchase order value view"
},
{
"type": "CLAS",
"name": "{{P}}TPO_TEST",
"file": "reference/tpo_test.clas.abap",
"description": "Own tests for the fixed view"
}
],
"craft_checks": []
}