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,6 @@
@EndUserText.label : 'Service job base fields'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}svc_base {
created_by : abap.numc(12);
created_on : abap.dats;
}

View File

@@ -0,0 +1,14 @@
@EndUserText.label : 'Service job line type'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}svc_job {
created_by : abap.numc(12);
created_on : abap.dats;
job_id : abap.char(10);
work_hours : abap.dec(5,2);
calc_mode : abap.char(2);
order_ref : abap.char(12);
service_date : abap.dats;
part_count : abap.int4;
group_code : abap.char(4);
net_value : abap.dec(13,2);
}

View File

@@ -0,0 +1,6 @@
@EndUserText.label : 'Service job base fields'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}svc_base {
created_by : abap.char(11);
created_on : abap.dats;
}

View File

@@ -0,0 +1,14 @@
@EndUserText.label : 'Service job line type'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}svc_job {
created_by : abap.char(12);
created_on : abap.tims;
job_id : abap.char(10);
work_hours : abap.dec(5,2);
calc_mode : abap.char(2);
order_ref : abap.char(12);
service_date : abap.dats;
part_count : abap.int4;
group_code : abap.char(4);
net_value : abap.dec(13,2);
}

View File

@@ -0,0 +1,6 @@
@EndUserText.label : 'Service job base fields'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}svc_base {
created_by : abap.char(12);
created_on : abap.tims;
}

View File

@@ -0,0 +1,34 @@
{
"id": "G1947",
"pool": "train",
"object_type": "STRU",
"category": "B",
"attempts": [
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 5,
"killed": 2,
"ok": false
}
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 5,
"killed": 5,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,193 @@
CLASS {{p}}svc_job_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_job TYPE REF TO cl_abap_structdescr.
CLASS-DATA go_base TYPE REF TO cl_abap_structdescr.
CLASS-DATA gt_job TYPE ddfields.
CLASS-DATA gt_base TYPE ddfields.
CLASS-METHODS class_setup.
METHODS assert_job_field
IMPORTING iv_index TYPE i
iv_name TYPE string
iv_type TYPE string
iv_leng TYPE i
iv_dec TYPE i.
METHODS assert_base_field
IMPORTING iv_index TYPE i
iv_name TYPE string
iv_type TYPE string
iv_leng TYPE i
iv_dec TYPE i.
METHODS structure_exists FOR TESTING.
METHODS base_structure_exists FOR TESTING.
METHODS component_order FOR TESTING.
METHODS base_component_order FOR TESTING.
METHODS base_created_by_type FOR TESTING.
METHODS base_created_on_type FOR TESTING.
METHODS char_fields FOR TESTING.
METHODS numeric_fields FOR TESTING.
METHODS date_fields FOR TESTING.
ENDCLASS.
CLASS {{p}}svc_job_hidden IMPLEMENTATION.
METHOD class_setup.
TRY.
go_job ?= cl_abap_typedescr=>describe_by_name( '{{P}}SVC_JOB' ).
gt_job = go_job->get_ddic_field_list( ).
CATCH cx_root.
CLEAR go_job.
CLEAR gt_job.
ENDTRY.
TRY.
go_base ?= cl_abap_typedescr=>describe_by_name( '{{P}}SVC_BASE' ).
gt_base = go_base->get_ddic_field_list( ).
CATCH cx_root.
CLEAR go_base.
CLEAR gt_base.
ENDTRY.
DELETE gt_job WHERE fieldname CP '.*'.
DELETE gt_base WHERE fieldname CP '.*'.
ENDMETHOD.
METHOD assert_job_field.
DATA ls_field TYPE dfies.
cl_abap_unit_assert=>assert_bound( act = go_job
msg = 'Structure {{P}}SVC_JOB is not available' ).
READ TABLE gt_job INTO ls_field INDEX iv_index.
cl_abap_unit_assert=>assert_equals(
exp = iv_name
act = CONV string( ls_field-fieldname )
msg = |Wrong field name at position { iv_index } of SVC_JOB| ).
cl_abap_unit_assert=>assert_equals(
exp = iv_type
act = CONV string( ls_field-datatype )
msg = |Wrong data type of field { iv_name }| ).
cl_abap_unit_assert=>assert_equals(
exp = iv_leng
act = ls_field-leng
msg = |Wrong length of field { iv_name }| ).
cl_abap_unit_assert=>assert_equals(
exp = iv_dec
act = ls_field-decimals
msg = |Wrong number of decimals of field { iv_name }| ).
ENDMETHOD.
METHOD assert_base_field.
DATA ls_field TYPE dfies.
cl_abap_unit_assert=>assert_bound( act = go_base
msg = 'Structure {{P}}SVC_BASE is not available' ).
READ TABLE gt_base INTO ls_field INDEX iv_index.
cl_abap_unit_assert=>assert_equals(
exp = iv_name
act = CONV string( ls_field-fieldname )
msg = |Wrong field name at position { iv_index } of SVC_BASE| ).
cl_abap_unit_assert=>assert_equals(
exp = iv_type
act = CONV string( ls_field-datatype )
msg = |Wrong data type of base field { iv_name }| ).
cl_abap_unit_assert=>assert_equals(
exp = iv_leng
act = ls_field-leng
msg = |Wrong length of base field { iv_name }| ).
cl_abap_unit_assert=>assert_equals(
exp = iv_dec
act = ls_field-decimals
msg = |Wrong number of decimals of base field { iv_name }| ).
ENDMETHOD.
METHOD structure_exists.
DATA lo_descr TYPE REF TO cl_abap_typedescr.
TRY.
lo_descr = cl_abap_typedescr=>describe_by_name( '{{P}}SVC_JOB' ).
CATCH cx_root.
CLEAR lo_descr.
ENDTRY.
cl_abap_unit_assert=>assert_bound( act = lo_descr
msg = 'Structure {{P}}SVC_JOB does not exist' ).
ENDMETHOD.
METHOD base_structure_exists.
DATA lo_descr TYPE REF TO cl_abap_typedescr.
TRY.
lo_descr = cl_abap_typedescr=>describe_by_name( '{{P}}SVC_BASE' ).
CATCH cx_root.
CLEAR lo_descr.
ENDTRY.
cl_abap_unit_assert=>assert_bound( act = lo_descr
msg = 'Structure {{P}}SVC_BASE does not exist' ).
ENDMETHOD.
METHOD component_order.
cl_abap_unit_assert=>assert_bound( act = go_job
msg = 'Structure {{P}}SVC_JOB is not available' ).
cl_abap_unit_assert=>assert_equals( exp = 10 act = lines( gt_job )
msg = 'Structure {{P}}SVC_JOB must have exactly 10 fields' ).
assert_job_field( iv_index = 1 iv_name = `CREATED_BY` iv_type = `CHAR`
iv_leng = 12 iv_dec = 0 ).
assert_job_field( iv_index = 2 iv_name = `CREATED_ON` iv_type = `DATS`
iv_leng = 8 iv_dec = 0 ).
assert_job_field( iv_index = 3 iv_name = `JOB_ID` iv_type = `CHAR`
iv_leng = 10 iv_dec = 0 ).
assert_job_field( iv_index = 4 iv_name = `WORK_HOURS` iv_type = `DEC`
iv_leng = 5 iv_dec = 2 ).
assert_job_field( iv_index = 5 iv_name = `CALC_MODE` iv_type = `CHAR`
iv_leng = 2 iv_dec = 0 ).
assert_job_field( iv_index = 6 iv_name = `ORDER_REF` iv_type = `CHAR`
iv_leng = 12 iv_dec = 0 ).
assert_job_field( iv_index = 7 iv_name = `SERVICE_DATE` iv_type = `DATS`
iv_leng = 8 iv_dec = 0 ).
assert_job_field( iv_index = 8 iv_name = `PART_COUNT` iv_type = `INT4`
iv_leng = 10 iv_dec = 0 ).
assert_job_field( iv_index = 9 iv_name = `GROUP_CODE` iv_type = `CHAR`
iv_leng = 4 iv_dec = 0 ).
assert_job_field( iv_index = 10 iv_name = `NET_VALUE` iv_type = `DEC`
iv_leng = 13 iv_dec = 2 ).
ENDMETHOD.
METHOD base_component_order.
cl_abap_unit_assert=>assert_bound( act = go_base
msg = 'Structure {{P}}SVC_BASE is not available' ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( gt_base )
msg = 'Structure {{P}}SVC_BASE must have exactly 2 fields' ).
assert_base_field( iv_index = 1 iv_name = `CREATED_BY` iv_type = `CHAR`
iv_leng = 12 iv_dec = 0 ).
assert_base_field( iv_index = 2 iv_name = `CREATED_ON` iv_type = `DATS`
iv_leng = 8 iv_dec = 0 ).
ENDMETHOD.
METHOD base_created_by_type.
assert_base_field( iv_index = 1 iv_name = `CREATED_BY` iv_type = `CHAR`
iv_leng = 12 iv_dec = 0 ).
ENDMETHOD.
METHOD base_created_on_type.
assert_base_field( iv_index = 2 iv_name = `CREATED_ON` iv_type = `DATS`
iv_leng = 8 iv_dec = 0 ).
ENDMETHOD.
METHOD char_fields.
assert_job_field( iv_index = 3 iv_name = `JOB_ID` iv_type = `CHAR`
iv_leng = 10 iv_dec = 0 ).
assert_job_field( iv_index = 5 iv_name = `CALC_MODE` iv_type = `CHAR`
iv_leng = 2 iv_dec = 0 ).
assert_job_field( iv_index = 6 iv_name = `ORDER_REF` iv_type = `CHAR`
iv_leng = 12 iv_dec = 0 ).
assert_job_field( iv_index = 9 iv_name = `GROUP_CODE` iv_type = `CHAR`
iv_leng = 4 iv_dec = 0 ).
ENDMETHOD.
METHOD numeric_fields.
assert_job_field( iv_index = 4 iv_name = `WORK_HOURS` iv_type = `DEC`
iv_leng = 5 iv_dec = 2 ).
assert_job_field( iv_index = 8 iv_name = `PART_COUNT` iv_type = `INT4`
iv_leng = 10 iv_dec = 0 ).
assert_job_field( iv_index = 10 iv_name = `NET_VALUE` iv_type = `DEC`
iv_leng = 13 iv_dec = 2 ).
ENDMETHOD.
METHOD date_fields.
assert_job_field( iv_index = 7 iv_name = `SERVICE_DATE` iv_type = `DATS`
iv_leng = 8 iv_dec = 0 ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,57 @@
{
"task": "G1947",
"mutants": [
{
"object": "{{P}}SVC_BASE",
"mutant": "line 4: abap.char(12) -> abap.numc(12) (type)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"BASE_COMPONENT_ORDER",
"BASE_CREATED_BY_TYPE"
]
},
{
"object": "{{P}}SVC_JOB",
"mutant": "line 4: abap.char(12) -> abap.numc(12) (type)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"COMPONENT_ORDER"
]
},
{
"object": "{{P}}SVC_BASE",
"mutant": "line 4: abap.char(12) -> abap.char(11) (length)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"BASE_COMPONENT_ORDER",
"BASE_CREATED_BY_TYPE"
]
},
{
"object": "{{P}}SVC_JOB",
"mutant": "line 5: abap.dats -> abap.tims (type)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"COMPONENT_ORDER"
]
},
{
"object": "{{P}}SVC_BASE",
"mutant": "line 5: abap.dats -> abap.tims (type)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"BASE_COMPONENT_ORDER",
"BASE_CREATED_ON_TYPE"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,6 @@
@EndUserText.label : 'Service job base fields'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}svc_base {
created_by : abap.char(12);
created_on : abap.dats;
}

View File

@@ -0,0 +1,14 @@
@EndUserText.label : 'Service job line type'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure {{p}}svc_job {
created_by : abap.char(12);
created_on : abap.dats;
job_id : abap.char(10);
work_hours : abap.dec(5,2);
calc_mode : abap.char(2);
order_ref : abap.char(12);
service_date : abap.dats;
part_count : abap.int4;
group_code : abap.char(4);
net_value : abap.dec(13,2);
}

View File

@@ -0,0 +1,55 @@
CLASS {{p}}svc_job_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS structure_exists FOR TESTING.
METHODS field_count FOR TESTING.
METHODS net_value_type FOR TESTING.
METHODS base_created_by_type FOR TESTING.
ENDCLASS.
CLASS {{p}}svc_job_test IMPLEMENTATION.
METHOD structure_exists.
DATA lo_descr TYPE REF TO cl_abap_typedescr.
TRY.
lo_descr = cl_abap_typedescr=>describe_by_name( '{{P}}SVC_JOB' ).
CATCH cx_root.
CLEAR lo_descr.
ENDTRY.
cl_abap_unit_assert=>assert_bound( act = lo_descr ).
ENDMETHOD.
METHOD field_count.
DATA lo_structdescr TYPE REF TO cl_abap_structdescr.
DATA lt_fields TYPE ddfields.
lo_structdescr ?= cl_abap_typedescr=>describe_by_name( '{{P}}SVC_JOB' ).
lt_fields = lo_structdescr->get_ddic_field_list( ).
DELETE lt_fields WHERE fieldname CP '.*'.
cl_abap_unit_assert=>assert_equals( exp = 10 act = lines( lt_fields ) ).
ENDMETHOD.
METHOD net_value_type.
DATA lo_structdescr TYPE REF TO cl_abap_structdescr.
DATA lt_fields TYPE ddfields.
DATA ls_field TYPE dfies.
lo_structdescr ?= cl_abap_typedescr=>describe_by_name( '{{P}}SVC_JOB' ).
lt_fields = lo_structdescr->get_ddic_field_list( ).
READ TABLE lt_fields INTO ls_field WITH KEY fieldname = 'NET_VALUE'.
cl_abap_unit_assert=>assert_equals( exp = `DEC`
act = CONV string( ls_field-datatype ) ).
cl_abap_unit_assert=>assert_equals( exp = 13 act = ls_field-leng ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_field-decimals ).
ENDMETHOD.
METHOD base_created_by_type.
DATA lo_structdescr TYPE REF TO cl_abap_structdescr.
DATA lt_fields TYPE ddfields.
DATA ls_field TYPE dfies.
lo_structdescr ?= cl_abap_typedescr=>describe_by_name( '{{P}}SVC_BASE' ).
lt_fields = lo_structdescr->get_ddic_field_list( ).
READ TABLE lt_fields INTO ls_field WITH KEY fieldname = 'CREATED_BY'.
cl_abap_unit_assert=>assert_equals( exp = `CHAR`
act = CONV string( ls_field-datatype ) ).
cl_abap_unit_assert=>assert_equals( exp = 12 act = ls_field-leng ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,51 @@
# 1. Goal
A service company records its service jobs. The company needs one reusable line
type for a service job. The line type is a DDIC structure. The company also
needs a small base structure for the audit fields of its business objects.
# 2. Open questions
None.
# 3. Context
- Several programs and one OData service use the service job line type.
- The line type is a DDIC structure. It is not a database table.
- The base structure is a DDIC structure too.
- The company keeps the audit fields in the base structure, so that all of its
business objects use the same audit fields.
# 4. Contract
- Create the DDIC structure {{P}}SVC_BASE in package $TMP.
- Create the DDIC structure {{P}}SVC_JOB in package $TMP.
- Fields of {{P}}SVC_BASE, in this order:
- created_by : abap.char(12)
- created_on : abap.dats
- Fields of {{P}}SVC_JOB, in this order:
- created_by : abap.char(12)
- created_on : abap.dats
- job_id : abap.char(10)
- work_hours : abap.dec(5,2)
- calc_mode : abap.char(2)
- order_ref : abap.char(12)
- service_date : abap.dats
- part_count : abap.int4
- group_code : abap.char(4)
- net_value : abap.dec(13,2)
# 5. Business rules
1. {{P}}SVC_JOB has exactly the ten fields of the contract, in the given order.
2. The field names are the safe names of the contract. Do not use the words
hours, mode, order, date, count, group or value as a field name.
3. The data type and the length of every field are exactly as in the contract.
4. {{P}}SVC_BASE has exactly the two fields of the contract, in the given order.
5. The first two fields of {{P}}SVC_JOB have the same name, data type and length
as the two fields of {{P}}SVC_BASE.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP.
- Out of scope: do not create database tables.
# 7. Acceptance
- The structures are active and have no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests with RTTI in a global test class.

View File

@@ -0,0 +1,69 @@
{
"id": "G1947",
"category": "B",
"object_type": "STRU",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [],
"contract": [
{
"type": "STRU",
"name": "{{P}}SVC_BASE",
"fields": [
"created_by",
"created_on"
]
},
{
"type": "STRU",
"name": "{{P}}SVC_JOB",
"fields": [
"created_by",
"created_on",
"job_id",
"work_hours",
"calc_mode",
"order_ref",
"service_date",
"part_count",
"group_code",
"net_value"
]
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}SVC_JOB_HIDDEN",
"file": "hidden/svc_job_hidden.clas.abap",
"description": "Hidden RTTI tests for the service job structures"
}
],
"reference": [
{
"type": "STRU",
"name": "{{P}}SVC_BASE",
"file": "reference/svc_base.ddls.asddls",
"description": "Base structure with the audit fields"
},
{
"type": "STRU",
"name": "{{P}}SVC_JOB",
"file": "reference/svc_job.ddls.asddls",
"description": "Service job line type"
},
{
"type": "CLAS",
"name": "{{P}}SVC_JOB_TEST",
"file": "reference/svc_job_test.clas.abap",
"description": "Own RTTI tests for the structures"
}
],
"craft_checks": []
}