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,16 @@
@EndUserText.label : 'Grape harvest record'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}grh {
key client : abap.clnt not null;
harvest_id : abap.char(10) not null;
vineyard_id : abap.char(8) not null;
grape : abap.char(12);
harvest_date : abap.dats;
crates : abap.int4;
weight_kg : abap.dec(13,3);
grade : abap.char(2);
organic : abap.char(1);
}

View File

@@ -0,0 +1,16 @@
@EndUserText.label : 'Grape harvest record'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}grh {
key client : abap.clnt not null;
key harvest_id : abap.char(9) not null;
vineyard_id : abap.char(8) not null;
grape : abap.char(12);
harvest_date : abap.dats;
crates : abap.int4;
weight_kg : abap.dec(13,3);
grade : abap.char(2);
organic : abap.char(1);
}

View File

@@ -0,0 +1,16 @@
@EndUserText.label : 'Grape harvest record'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}grh {
key client : abap.clnt not null;
key harvest_id : abap.char(10) not null;
vineyard_id : abap.char(8) not null;
grape : abap.numc(12);
harvest_date : abap.dats;
crates : abap.int4;
weight_kg : abap.dec(13,3);
grade : abap.char(2);
organic : abap.char(1);
}

View File

@@ -0,0 +1,16 @@
@EndUserText.label : 'Grape harvest record'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}grh {
key client : abap.clnt not null;
key harvest_id : abap.char(10) not null;
vineyard_id : abap.char(8) not null;
grape : abap.char(12);
harvest_date : abap.tims;
crates : abap.int4;
weight_kg : abap.dec(13,3);
grade : abap.char(2);
organic : abap.char(1);
}

View File

@@ -0,0 +1,16 @@
@EndUserText.label : 'Grape harvest record'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}grh {
key client : abap.clnt not null;
key harvest_id : abap.char(10) not null;
vineyard_id : abap.char(8) not null;
grape : abap.char(12);
harvest_date : abap.dats;
crates : abap.int4;
weight_kg : abap.dec(13,4);
grade : abap.char(2);
organic : abap.char(1);
}

View File

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

View File

@@ -0,0 +1,146 @@
CLASS {{p}}grh_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES ty_field_name TYPE dfies-fieldname.
CLASS-DATA go_env TYPE REF TO if_osql_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS get_descr RETURNING VALUE(ro_descr) TYPE REF TO cl_abap_structdescr.
METHODS assert_field_exists IMPORTING iv_name TYPE ty_field_name.
METHODS field_of IMPORTING iv_name TYPE ty_field_name
RETURNING VALUE(rs_field) TYPE dfies.
METHODS field_names FOR TESTING.
METHODS key_fields FOR TESTING.
METHODS text_lengths FOR TESTING.
METHODS date_and_number_types FOR TESTING.
METHODS decimal_places FOR TESTING.
METHODS client_field FOR TESTING.
METHODS stores_and_reads_a_record FOR TESTING.
METHODS rejects_duplicate_key FOR TESTING.
ENDCLASS.
CLASS {{p}}grh_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}GRH' ) ) ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
go_env->clear_doubles( ).
ENDMETHOD.
METHOD get_descr.
ro_descr = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( '{{P}}GRH' ) ).
ENDMETHOD.
METHOD assert_field_exists.
DATA(lt_fields) = get_descr( )->get_ddic_field_list( ).
READ TABLE lt_fields TRANSPORTING NO FIELDS WITH KEY fieldname = iv_name.
cl_abap_unit_assert=>assert_subrc( exp = 0 act = sy-subrc
msg = |Field { iv_name } is missing in table {{P}}GRH| ).
ENDMETHOD.
METHOD field_of.
DATA(lt_fields) = get_descr( )->get_ddic_field_list( ).
READ TABLE lt_fields INTO rs_field WITH KEY fieldname = iv_name.
cl_abap_unit_assert=>assert_subrc( exp = 0 act = sy-subrc
msg = |Field { iv_name } is missing in table {{P}}GRH| ).
ENDMETHOD.
METHOD field_names.
DATA(lt_fields) = get_descr( )->get_ddic_field_list( ).
cl_abap_unit_assert=>assert_equals( exp = 9 act = lines( lt_fields ) ).
assert_field_exists( 'CLIENT' ).
assert_field_exists( 'HARVEST_ID' ).
assert_field_exists( 'VINEYARD_ID' ).
assert_field_exists( 'GRAPE' ).
assert_field_exists( 'HARVEST_DATE' ).
assert_field_exists( 'CRATES' ).
assert_field_exists( 'WEIGHT_KG' ).
assert_field_exists( 'GRADE' ).
assert_field_exists( 'ORGANIC' ).
ENDMETHOD.
METHOD key_fields.
cl_abap_unit_assert=>assert_equals( exp = 'X' act = field_of( 'CLIENT' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = 'X' act = field_of( 'HARVEST_ID' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = ' ' act = field_of( 'VINEYARD_ID' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = ' ' act = field_of( 'GRAPE' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = ' ' act = field_of( 'HARVEST_DATE' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = ' ' act = field_of( 'CRATES' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = ' ' act = field_of( 'WEIGHT_KG' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = ' ' act = field_of( 'GRADE' )-keyflag ).
cl_abap_unit_assert=>assert_equals( exp = ' ' act = field_of( 'ORGANIC' )-keyflag ).
ENDMETHOD.
METHOD text_lengths.
cl_abap_unit_assert=>assert_equals( exp = 10 act = CONV i( field_of( 'HARVEST_ID' )-leng ) ).
cl_abap_unit_assert=>assert_equals( exp = 8 act = CONV i( field_of( 'VINEYARD_ID' )-leng ) ).
cl_abap_unit_assert=>assert_equals( exp = 12 act = CONV i( field_of( 'GRAPE' )-leng ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = CONV i( field_of( 'GRADE' )-leng ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = CONV i( field_of( 'ORGANIC' )-leng ) ).
ENDMETHOD.
METHOD date_and_number_types.
cl_abap_unit_assert=>assert_equals( exp = 'D' act = field_of( 'HARVEST_DATE' )-inttype ).
cl_abap_unit_assert=>assert_equals( exp = 8 act = CONV i( field_of( 'HARVEST_DATE' )-leng ) ).
cl_abap_unit_assert=>assert_equals( exp = 'I' act = field_of( 'CRATES' )-inttype ).
cl_abap_unit_assert=>assert_equals( exp = 10 act = CONV i( field_of( 'CRATES' )-leng ) ).
ENDMETHOD.
METHOD decimal_places.
cl_abap_unit_assert=>assert_equals( exp = 'P' act = field_of( 'WEIGHT_KG' )-inttype ).
cl_abap_unit_assert=>assert_equals( exp = 13 act = CONV i( field_of( 'WEIGHT_KG' )-leng ) ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = CONV i( field_of( 'WEIGHT_KG' )-decimals ) ).
ENDMETHOD.
METHOD client_field.
cl_abap_unit_assert=>assert_equals( exp = 'C' act = field_of( 'CLIENT' )-inttype ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = CONV i( field_of( 'CLIENT' )-leng ) ).
ENDMETHOD.
METHOD stores_and_reads_a_record.
DATA lt_grh TYPE STANDARD TABLE OF {{p}}grh WITH EMPTY KEY.
lt_grh = VALUE #( ( client = sy-mandt harvest_id = 'H1' vineyard_id = 'VINE01'
grape = 'RIESLING' harvest_date = '20240901'
crates = 14 weight_kg = '212.500' grade = 'A' organic = 'X' ) ).
INSERT {{p}}grh FROM TABLE @lt_grh.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
SELECT SINGLE vineyard_id, grape, harvest_date, crates, weight_kg, grade, organic
FROM {{p}}grh WHERE harvest_id = 'H1' INTO @DATA(ls_grh).
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = 'VINE01' act = ls_grh-vineyard_id ).
cl_abap_unit_assert=>assert_equals( exp = 'RIESLING' act = ls_grh-grape ).
cl_abap_unit_assert=>assert_equals( exp = '20240901' act = ls_grh-harvest_date ).
cl_abap_unit_assert=>assert_equals( exp = 14 act = ls_grh-crates ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '212.5' )
act = CONV decfloat34( ls_grh-weight_kg ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = ls_grh-grade ).
cl_abap_unit_assert=>assert_equals( exp = 'X' act = ls_grh-organic ).
ENDMETHOD.
METHOD rejects_duplicate_key.
DATA lt_grh TYPE STANDARD TABLE OF {{p}}grh WITH EMPTY KEY.
lt_grh = VALUE #( ( client = sy-mandt harvest_id = 'D1' vineyard_id = 'VINE02' ) ).
INSERT {{p}}grh FROM TABLE @lt_grh.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
TRY.
INSERT {{p}}grh FROM TABLE @lt_grh.
cl_abap_unit_assert=>fail( msg = 'A duplicate key must not be accepted' ).
CATCH cx_sy_open_sql_db.
" expected: client and harvest_id are the unique key
ENDTRY.
SELECT COUNT(*) FROM {{p}}grh WHERE harvest_id = 'D1' INTO @DATA(lv_count).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_count ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,55 @@
{
"task": "G1915",
"mutants": [
{
"object": "{{P}}GRH",
"mutant": "line 8: key harvest_id : -> harvest_id : (key)",
"status": "killed",
"hidden": "7/8",
"failed_tests": [
"KEY_FIELDS"
]
},
{
"object": "{{P}}GRH",
"mutant": "line 8: abap.char(10) -> abap.char(9) (length)",
"status": "killed",
"hidden": "7/8",
"failed_tests": [
"TEXT_LENGTHS"
]
},
{
"object": "{{P}}GRH",
"mutant": "line 10: abap.char(12) -> abap.numc(12) (type)",
"status": "killed",
"hidden": "7/8",
"failed_tests": [
"STORES_AND_READS_A_RECORD"
]
},
{
"object": "{{P}}GRH",
"mutant": "line 11: abap.dats -> abap.tims (type)",
"status": "killed",
"hidden": "6/8",
"failed_tests": [
"DATE_AND_NUMBER_TYPES",
"STORES_AND_READS_A_RECORD"
]
},
{
"object": "{{P}}GRH",
"mutant": "line 13: abap.dec(13,3) -> abap.dec(13,4) (decimals)",
"status": "killed",
"hidden": "7/8",
"failed_tests": [
"DECIMAL_PLACES"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,16 @@
@EndUserText.label : 'Grape harvest record'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}grh {
key client : abap.clnt not null;
key harvest_id : abap.char(10) not null;
vineyard_id : abap.char(8) not null;
grape : abap.char(12);
harvest_date : abap.dats;
crates : abap.int4;
weight_kg : abap.dec(13,3);
grade : abap.char(2);
organic : abap.char(1);
}

View File

@@ -0,0 +1,64 @@
CLASS {{p}}grh_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 stores_all_values FOR TESTING.
METHODS rejects_duplicate_key FOR TESTING.
METHODS has_expected_fields FOR TESTING.
ENDCLASS.
CLASS {{p}}grh_test IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}GRH' ) ) ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
go_env->clear_doubles( ).
ENDMETHOD.
METHOD stores_all_values.
DATA lt_grh TYPE STANDARD TABLE OF {{p}}grh WITH EMPTY KEY.
lt_grh = VALUE #( ( client = sy-mandt harvest_id = 'H1' vineyard_id = 'VINE01'
grape = 'RIESLING' harvest_date = '20240901'
crates = 14 weight_kg = '212.500' grade = 'A' organic = 'X' ) ).
INSERT {{p}}grh FROM TABLE @lt_grh.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
SELECT SINGLE vineyard_id, crates FROM {{p}}grh WHERE harvest_id = 'H1'
INTO @DATA(ls_grh).
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = 'VINE01' act = ls_grh-vineyard_id ).
cl_abap_unit_assert=>assert_equals( exp = 14 act = ls_grh-crates ).
ENDMETHOD.
METHOD rejects_duplicate_key.
DATA lt_grh TYPE STANDARD TABLE OF {{p}}grh WITH EMPTY KEY.
lt_grh = VALUE #( ( client = sy-mandt harvest_id = 'D1' vineyard_id = 'VINE02' ) ).
INSERT {{p}}grh FROM TABLE @lt_grh.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
TRY.
INSERT {{p}}grh FROM TABLE @lt_grh.
cl_abap_unit_assert=>fail( msg = 'A duplicate key must not be accepted' ).
CATCH cx_sy_open_sql_db.
" expected: the key is unique
ENDTRY.
SELECT COUNT(*) FROM {{p}}grh WHERE harvest_id = 'D1' INTO @DATA(lv_count).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_count ).
ENDMETHOD.
METHOD has_expected_fields.
DATA(lo_descr) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( '{{P}}GRH' ) ).
DATA(lt_fields) = lo_descr->get_ddic_field_list( ).
cl_abap_unit_assert=>assert_equals( exp = 9 act = lines( lt_fields ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,63 @@
# 1. Goal
A winery records the grape harvest of each picking. The cellar team needs one
database table for these records. The table stores the vineyard, the grape
variety, the picking date, the number of crates, the weight and the quality
grade of each picking.
# 2. Open questions
None.
# 3. Context
- Package: $TMP.
- The table is a new object. No other object exists.
- One harvest record belongs to exactly one vineyard and one grape variety.
- The winery stores the weight of a picking in kilograms.
# 4. Contract
- Create the transparent database table {{P}}GRH in package $TMP.
- Field names, in this order: client, harvest_id, vineyard_id, grape,
harvest_date, crates, weight_kg, grade, organic.
- Key fields: client and harvest_id.
# 5. Business rules
1. client is the client field (abap.clnt, length 3). It is a key field. It must
not be null.
2. harvest_id identifies one picking (abap.char, length 10). It is a key field.
It must not be null.
3. vineyard_id identifies the vineyard (abap.char, length 8). It is not a key
field. It must not be null.
4. grape holds the name of the grape variety (abap.char, length 12). It is not
a key field.
5. harvest_date holds the date of the picking (abap.dats). It is not a key
field.
6. crates holds the number of crates that the picking filled (abap.int4). It is
not a key field.
7. weight_kg holds the weight of the picking in kilograms (abap.dec, length 13,
3 decimal places). It is not a key field.
8. grade holds the quality grade of the picking (abap.char, length 2). It is
not a key field.
9. organic holds 'X' when the vineyard is organic (abap.char, length 1). It is
not a key field.
10. The table stores one record for each value pair of client and harvest_id. A
second record with the same client and the same harvest_id must not be
stored. The database rejects the second record: the statement that stores
it raises an exception of the class CX_SY_OPEN_SQL_DB, and the first record
stays in the table.
11. A stored record can be read again with all its values.
# 6. Constraints
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
- The table is transparent. Create it as a DDL source in package $TMP with the
annotations @EndUserText.label, @AbapCatalog.enhancement.category :
#NOT_EXTENSIBLE, @AbapCatalog.tableCategory : #TRANSPARENT,
@AbapCatalog.deliveryClass : #A and @AbapCatalog.dataMaintenance :
#RESTRICTED.
- Coding standards: Clean ABAP.
- Out of scope: do not create any other object. Do not create a CDS view, a
report or a class other than the test class.
# 7. Acceptance
- The table is active.
- The hidden tests pass.
- Write ABAP Unit tests in a global test class. The tests use
CL_OSQL_TEST_ENVIRONMENT.

View File

@@ -0,0 +1,54 @@
{
"id": "G1915",
"category": "B",
"object_type": "TABL",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [],
"contract": [
{
"type": "TABL",
"name": "{{P}}GRH",
"fields": [
"client",
"harvest_id",
"vineyard_id",
"grape",
"harvest_date",
"crates",
"weight_kg",
"grade",
"organic"
]
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}GRH_HIDDEN",
"file": "hidden/grh_hidden.clas.abap",
"description": "Hidden tests: DDIC field list of the table and Open SQL test doubles"
}
],
"reference": [
{
"type": "TABL",
"name": "{{P}}GRH",
"file": "reference/grh.tabl.asabap",
"description": "Grape harvest records"
},
{
"type": "CLAS",
"name": "{{P}}GRH_TEST",
"file": "reference/grh_test.clas.abap",
"description": "Own tests for the table"
}
],
"craft_checks": []
}