STRU and exception tasks accepted; G6 cascade fix, exception class mutants, RTTI unit notes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 19:25:09 +02:00
parent b119f1afac
commit 55f4068330
36 changed files with 5380 additions and 34 deletions

View File

@@ -0,0 +1,6 @@
@EndUserText.label : 'Audit information'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}audit_info {
created_by : abap.char(11);
created_on : abap.dats;
}

View File

@@ -0,0 +1,6 @@
@EndUserText.label : 'Audit information'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}audit_info {
created_by : abap.numc(12);
created_on : abap.dats;
}

View File

@@ -0,0 +1,10 @@
@EndUserText.label : 'Stock position line'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}stock_line {
material : abap.char(18);
plant : abap.char(4);
net_amount : abap.dec(9,3);
currency : abap.char(5);
created_by : abap.char(12);
created_on : abap.dats;
}

View File

@@ -0,0 +1,6 @@
@EndUserText.label : 'Audit information'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}audit_info {
created_by : abap.char(12);
created_on : abap.tims;
}

View File

@@ -0,0 +1,29 @@
{
"id": "G1903",
"pool": "train",
"object_type": "STRU",
"category": "B",
"attempts": [
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 4,
"killed": 4,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,177 @@
CLASS {{p}}t16_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_osql_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS six_components FOR TESTING.
METHODS component_order FOR TESTING.
METHODS char_lengths FOR TESTING.
METHODS amount_type FOR TESTING.
METHODS date_type FOR TESTING.
METHODS flat_structure FOR TESTING.
METHODS audit_structure FOR TESTING.
METHODS audit_matches FOR TESTING.
METHODS read_stock_row FOR TESTING.
ENDCLASS.
CLASS {{p}}t16_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}STOCK' ) ) ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
go_env->clear_doubles( ).
DATA lt_stock TYPE STANDARD TABLE OF {{p}}stock WITH EMPTY KEY.
lt_stock = VALUE #(
( material = 'MAT-1' plant = 'P001' net_amount = '123.45'
currency = 'EUR' created_by = 'USER1' created_on = '20240115' )
( material = 'MAT-2' plant = 'P001' net_amount = '10.00'
currency = 'EUR' created_by = 'USER2' created_on = '20240116' )
( material = 'MAT-3' plant = 'P002' net_amount = '5.50'
currency = 'USD' created_by = 'USER1' created_on = '20240117' ) ).
go_env->insert_test_data( lt_stock ).
ENDMETHOD.
METHOD six_components.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lt_fields) = lo_struct->get_ddic_field_list( ).
cl_abap_unit_assert=>assert_equals( exp = 6 act = lines( lt_fields ) ).
ENDMETHOD.
METHOD component_order.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lt_comp) = lo_struct->get_components( ).
cl_abap_unit_assert=>assert_equals( exp = 6 act = lines( lt_comp ) ).
DATA(lv_index) = 0.
LOOP AT lt_comp INTO DATA(ls_comp).
lv_index = lv_index + 1.
CASE lv_index.
WHEN 1.
cl_abap_unit_assert=>assert_equals( exp = 'MATERIAL' act = ls_comp-name ).
WHEN 2.
cl_abap_unit_assert=>assert_equals( exp = 'PLANT' act = ls_comp-name ).
WHEN 3.
cl_abap_unit_assert=>assert_equals( exp = 'NET_AMOUNT' act = ls_comp-name ).
WHEN 4.
cl_abap_unit_assert=>assert_equals( exp = 'CURRENCY' act = ls_comp-name ).
WHEN 5.
cl_abap_unit_assert=>assert_equals( exp = 'CREATED_BY' act = ls_comp-name ).
WHEN 6.
cl_abap_unit_assert=>assert_equals( exp = 'CREATED_ON' act = ls_comp-name ).
ENDCASE.
ENDLOOP.
ENDMETHOD.
METHOD char_lengths.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lt_fields) = lo_struct->get_ddic_field_list( ).
READ TABLE lt_fields INTO DATA(ls_field) WITH KEY fieldname = 'MATERIAL'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component MATERIAL is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 18 act = CONV i( ls_field-leng ) ).
READ TABLE lt_fields INTO ls_field WITH KEY fieldname = 'PLANT'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component PLANT is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 4 act = CONV i( ls_field-leng ) ).
READ TABLE lt_fields INTO ls_field WITH KEY fieldname = 'CURRENCY'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component CURRENCY is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 5 act = CONV i( ls_field-leng ) ).
READ TABLE lt_fields INTO ls_field WITH KEY fieldname = 'CREATED_BY'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component CREATED_BY is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 12 act = CONV i( ls_field-leng ) ).
ENDMETHOD.
METHOD amount_type.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lt_fields) = lo_struct->get_ddic_field_list( ).
READ TABLE lt_fields INTO DATA(ls_field) WITH KEY fieldname = 'NET_AMOUNT'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component NET_AMOUNT is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 'DEC' act = ls_field-datatype ).
cl_abap_unit_assert=>assert_equals( exp = 9 act = CONV i( ls_field-leng ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = CONV i( ls_field-decimals ) ).
ENDMETHOD.
METHOD date_type.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lt_fields) = lo_struct->get_ddic_field_list( ).
READ TABLE lt_fields INTO DATA(ls_field) WITH KEY fieldname = 'CREATED_ON'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component CREATED_ON is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 'DATS' act = ls_field-datatype ).
cl_abap_unit_assert=>assert_equals( exp = 8 act = CONV i( ls_field-leng ) ).
ENDMETHOD.
METHOD flat_structure.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lt_comp) = lo_struct->get_components( ).
LOOP AT lt_comp INTO DATA(ls_comp).
cl_abap_unit_assert=>assert_equals(
exp = cl_abap_typedescr=>kind_elem
act = ls_comp-type->kind
msg = |Component { ls_comp-name } is not elementary| ).
ENDLOOP.
ENDMETHOD.
METHOD audit_structure.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}AUDIT_INFO' ) ).
DATA(lt_fields) = lo_struct->get_ddic_field_list( ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_fields ) ).
READ TABLE lt_fields INTO DATA(ls_field) WITH KEY fieldname = 'CREATED_BY'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component CREATED_BY is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 'CHAR' act = ls_field-datatype ).
cl_abap_unit_assert=>assert_equals( exp = 12 act = CONV i( ls_field-leng ) ).
READ TABLE lt_fields INTO ls_field WITH KEY fieldname = 'CREATED_ON'.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Component CREATED_ON is missing' ).
cl_abap_unit_assert=>assert_equals( exp = 'DATS' act = ls_field-datatype ).
cl_abap_unit_assert=>assert_equals( exp = 8 act = CONV i( ls_field-leng ) ).
ENDMETHOD.
METHOD audit_matches.
DATA(lo_line) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lo_audit) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}AUDIT_INFO' ) ).
DATA(lt_line) = lo_line->get_ddic_field_list( ).
DATA(lt_audit) = lo_audit->get_ddic_field_list( ).
LOOP AT lt_audit INTO DATA(ls_audit).
READ TABLE lt_line INTO DATA(ls_line) WITH KEY fieldname = ls_audit-fieldname.
cl_abap_unit_assert=>assert_subrc(
exp = 0 msg = |Component { ls_audit-fieldname } is missing| ).
cl_abap_unit_assert=>assert_equals( exp = ls_audit-leng act = ls_line-leng ).
cl_abap_unit_assert=>assert_equals( exp = ls_audit-datatype act = ls_line-datatype ).
ENDLOOP.
ENDMETHOD.
METHOD read_stock_row.
DATA ls_line TYPE {{p}}stock_line.
SELECT SINGLE material, plant, net_amount, currency, created_by, created_on
FROM {{p}}stock
INTO @ls_line
WHERE material = 'MAT-1' AND plant = 'P001'.
cl_abap_unit_assert=>assert_equals( exp = 'MAT-1' act = ls_line-material ).
cl_abap_unit_assert=>assert_equals( exp = 'P001' act = ls_line-plant ).
cl_abap_unit_assert=>assert_equals( exp = 'EUR' act = ls_line-currency ).
cl_abap_unit_assert=>assert_equals( exp = 'USER1' act = ls_line-created_by ).
cl_abap_unit_assert=>assert_equals(
exp = CONV d( '20240115' ) act = ls_line-created_on ).
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '123.45' )
act = CONV decfloat34( ls_line-net_amount ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,55 @@
{
"task": "G1903",
"mutants": [
{
"object": "{{P}}AUDIT_INFO",
"mutant": "line 4: abap.char(12) -> abap.char(11) (length)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"AUDIT_MATCHES",
"AUDIT_STRUCTURE"
]
},
{
"object": "{{P}}STOCK_LINE",
"mutant": "line 4: abap.char(18) -> abap.numc(18) (type)",
"status": "invalid",
"hidden": "0/0",
"failed_tests": []
},
{
"object": "{{P}}AUDIT_INFO",
"mutant": "line 4: abap.char(12) -> abap.numc(12) (type)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"AUDIT_MATCHES",
"AUDIT_STRUCTURE"
]
},
{
"object": "{{P}}STOCK_LINE",
"mutant": "line 6: abap.dec(9,2) -> abap.dec(9,3) (decimals)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"AMOUNT_TYPE"
]
},
{
"object": "{{P}}AUDIT_INFO",
"mutant": "line 5: abap.dats -> abap.tims (type)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"AUDIT_MATCHES",
"AUDIT_STRUCTURE"
]
}
],
"valid": 4,
"killed": 4,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,6 @@
@EndUserText.label : 'Audit information'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}audit_info {
created_by : abap.char(12);
created_on : abap.dats;
}

View File

@@ -0,0 +1,10 @@
@EndUserText.label : 'Stock position line'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}stock_line {
material : abap.char(18);
plant : abap.char(4);
net_amount : abap.dec(9,2);
currency : abap.char(5);
created_by : abap.char(12);
created_on : abap.dats;
}

View File

@@ -0,0 +1,68 @@
CLASS {{p}}t16_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_osql_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS six_components FOR TESTING.
METHODS reads_stock_line FOR TESTING.
METHODS audit_matches FOR TESTING.
ENDCLASS.
CLASS {{p}}t16_test IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}STOCK' ) ) ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
go_env->clear_doubles( ).
DATA lt_stock TYPE STANDARD TABLE OF {{p}}stock WITH EMPTY KEY.
lt_stock = VALUE #(
( material = 'MAT-1' plant = 'P001' net_amount = '123.45'
currency = 'EUR' created_by = 'USER1' created_on = '20240115' ) ).
go_env->insert_test_data( lt_stock ).
ENDMETHOD.
METHOD six_components.
DATA(lo_struct) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lt_fields) = lo_struct->get_ddic_field_list( ).
cl_abap_unit_assert=>assert_equals( exp = 6 act = lines( lt_fields ) ).
ENDMETHOD.
METHOD reads_stock_line.
DATA ls_line TYPE {{p}}stock_line.
SELECT SINGLE material, plant, net_amount, currency, created_by, created_on
FROM {{p}}stock
INTO @ls_line
WHERE material = 'MAT-1'.
cl_abap_unit_assert=>assert_equals( exp = 'MAT-1' act = ls_line-material ).
cl_abap_unit_assert=>assert_equals( exp = 'EUR' act = ls_line-currency ).
ENDMETHOD.
METHOD audit_matches.
DATA(lo_line) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}STOCK_LINE' ) ).
DATA(lo_audit) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( '{{P}}AUDIT_INFO' ) ).
DATA(lt_line) = lo_line->get_ddic_field_list( ).
DATA(lt_audit) = lo_audit->get_ddic_field_list( ).
LOOP AT lt_audit INTO DATA(ls_audit).
READ TABLE lt_line INTO DATA(ls_line) WITH KEY fieldname = ls_audit-fieldname.
cl_abap_unit_assert=>assert_subrc(
exp = 0 msg = |Component { ls_audit-fieldname } is missing| ).
cl_abap_unit_assert=>assert_equals( exp = ls_audit-leng act = ls_line-leng ).
ENDLOOP.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,14 @@
@EndUserText.label : 'Stock position'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}stock {
key client : abap.clnt not null;
key material : abap.char(18) not null;
key plant : abap.char(4) not null;
net_amount : abap.dec(9,2);
currency : abap.char(5);
created_by : abap.char(12);
created_on : abap.dats;
}

View File

@@ -0,0 +1,59 @@
# 1. Goal
A stock report and an OData service must use the same line type for warehouse
stock positions. Create the DDIC structure {{P}}STOCK_LINE and the DDIC
structure {{P}}AUDIT_INFO in package $TMP.
# 2. Open questions
None.
# 3. Context
- The table {{P}}STOCK exists in package $TMP. Its columns are, in this order:
MATERIAL (CHAR 18), PLANT (CHAR 4), NET_AMOUNT (DEC 9,2), CURRENCY (CHAR 5),
CREATED_BY (CHAR 12), CREATED_ON (DATS). The key is CLIENT, MATERIAL and
PLANT.
- The table {{P}}STOCK is empty. Test data comes from test doubles.
- {{P}}AUDIT_INFO is the audit part that other objects use, for example a
change log view and a service. {{P}}STOCK_LINE must carry the same audit
part.
- Both structures are used as line types in ABAP SQL and in an OData service.
# 4. Contract
- Create the DDIC structure {{P}}STOCK_LINE in package $TMP.
Components, in this order: material (CHAR 18), plant (CHAR 4),
net_amount (DEC 9,2), currency (CHAR 5), created_by (CHAR 12),
created_on (DATS).
- Create the DDIC structure {{P}}AUDIT_INFO in package $TMP.
Components, in this order: created_by (CHAR 12), created_on (DATS).
- {{P}}STOCK_LINE contains all six components itself. It does not use a DDIC
include.
# 5. Business rules
1. {{P}}STOCK_LINE has exactly six components.
2. The components of {{P}}STOCK_LINE are, in this order: material, plant,
net_amount, currency, created_by, created_on.
3. material is a character field of 18 characters.
4. plant is a character field of 4 characters.
5. net_amount is a packed number with 9 digits and 2 decimal places.
6. currency is a character field of 5 characters.
7. created_by is a character field of 12 characters.
8. created_on is a date field of type DATS.
9. {{P}}AUDIT_INFO has exactly two components, in this order: created_by
(CHAR 12) and created_on (DATS).
10. Every component of {{P}}STOCK_LINE is elementary. {{P}}STOCK_LINE is a
flat structure.
11. The components created_by and created_on of {{P}}STOCK_LINE have the same
data type and the same length as the components of {{P}}AUDIT_INFO.
12. A row of {{P}}STOCK can be read into a work area of type {{P}}STOCK_LINE
with ABAP SQL.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Package $TMP. Do not use transports.
- Coding standards: Clean ABAP. No ATC priority 1 or 2 findings.
- Out of scope: do not change the table {{P}}STOCK.
# 7. Acceptance
- Both structures are active and have no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests with CL_OSQL_TEST_ENVIRONMENT in a global test class
(for example {{P}}T16_TEST). The tests must prove rules 1 to 12.

View File

@@ -0,0 +1,74 @@
{
"id": "G1903",
"category": "B",
"object_type": "STRU",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}STOCK",
"file": "seed/stock.tabl.asabap",
"description": "Stock positions"
}
],
"contract": [
{
"type": "STRU",
"name": "{{P}}STOCK_LINE",
"fields": [
"material",
"plant",
"net_amount",
"currency",
"created_by",
"created_on"
]
},
{
"type": "STRU",
"name": "{{P}}AUDIT_INFO",
"fields": [
"created_by",
"created_on"
]
}
],
"out_of_scope": [
"{{P}}STOCK"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T16_HIDDEN",
"file": "hidden/t16_hidden.clas.abap",
"description": "T16 hidden tests"
}
],
"reference": [
{
"type": "STRU",
"name": "{{P}}AUDIT_INFO",
"file": "reference/audit_info.ddls.asddls",
"description": "Audit information structure"
},
{
"type": "STRU",
"name": "{{P}}STOCK_LINE",
"file": "reference/stock_line.ddls.asddls",
"description": "Stock line structure"
},
{
"type": "CLAS",
"name": "{{P}}T16_TEST",
"file": "reference/t16_test.clas.abap",
"description": "T16 own tests"
}
],
"craft_checks": []
}