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,104 @@
REPORT {{p}}sharp_sum.
DATA gv_customer TYPE {{p}}sharpen-customer.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_cust FOR gv_customer.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES tt_customer TYPE RANGE OF {{p}}sharpen-customer.
TYPES:
BEGIN OF ty_line,
customer TYPE {{p}}sharpen-customer,
knives TYPE i,
fee TYPE {{p}}kntype-price,
END OF ty_line.
TYPES tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
METHODS select_totals
IMPORTING iv_from TYPE d
it_customer TYPE tt_customer
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT s~customer,
SUM( s~knife_count ) AS knives,
SUM( s~knife_count * t~price ) AS fee
FROM {{p}}sharpen AS s
INNER JOIN {{p}}kntype AS t ON t~type_id = s~knife_type
WHERE s~sharp_date < @iv_from
AND s~customer IN @it_customer
GROUP BY s~customer
ORDER BY fee DESCENDING
INTO CORRESPONDING FIELDS OF TABLE @rt_lines.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->select_totals( iv_from = p_from it_customer = s_cust[] ).
go_report->display( CHANGING ct_lines = gt_lines ).
CLASS ltc_report DEFINITION FINAL 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 totals_per_customer FOR TESTING.
METHODS unknown_type_skipped FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}SHARPEN' ) ( '{{P}}KNTYPE' ) ) ).
DATA lt_types TYPE STANDARD TABLE OF {{p}}kntype WITH EMPTY KEY.
lt_types = VALUE #( ( type_id = 'CHEF' price = '2.00' )
( type_id = 'BONE' price = '3.00' ) ).
go_env->insert_test_data( lt_types ).
DATA lt_items TYPE STANDARD TABLE OF {{p}}sharpen WITH EMPTY KEY.
lt_items = VALUE #( ( item_id = 1 customer = 'A' knife_type = 'CHEF' knife_count = 10 sharp_date = '20260101' )
( item_id = 2 customer = 'A' knife_type = 'BONE' knife_count = 2 sharp_date = '20260102' )
( item_id = 3 customer = 'B' knife_type = 'CHEF' knife_count = 5 sharp_date = '20260101' )
( item_id = 4 customer = 'B' knife_type = 'PLAS' knife_count = 7 sharp_date = '20260101' ) ).
go_env->insert_test_data( lt_items ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_customer.
DATA(lt_lines) = NEW lcl_report( )->select_totals(
iv_from = '20260101'
it_customer = VALUE #( ( sign = 'E' option = 'EQ' low = 'X' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lt_lines[ 1 ]-customer ).
cl_abap_unit_assert=>assert_equals( exp = 12 act = lt_lines[ 1 ]-knives ).
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}kntype-price( 26 ) act = lt_lines[ 1 ]-fee ).
ENDMETHOD.
METHOD unknown_type_skipped.
DATA(lt_lines) = NEW lcl_report( )->select_totals(
iv_from = '20260101'
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'B' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 5 act = lt_lines[ 1 ]-knives ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,104 @@
REPORT {{p}}sharp_sum.
DATA gv_customer TYPE {{p}}sharpen-customer.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_cust FOR gv_customer.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES tt_customer TYPE RANGE OF {{p}}sharpen-customer.
TYPES:
BEGIN OF ty_line,
customer TYPE {{p}}sharpen-customer,
knives TYPE i,
fee TYPE {{p}}kntype-price,
END OF ty_line.
TYPES tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
METHODS select_totals
IMPORTING iv_from TYPE d
it_customer TYPE tt_customer
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT s~customer,
SUM( s~knife_count ) AS knives,
SUM( s~knife_count * t~price ) AS fee
FROM {{p}}sharpen AS s
INNER JOIN {{p}}kntype AS t ON t~type_id = s~knife_type
WHERE s~sharp_date >= @iv_from
OR s~customer IN @it_customer
GROUP BY s~customer
ORDER BY fee DESCENDING
INTO CORRESPONDING FIELDS OF TABLE @rt_lines.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->select_totals( iv_from = p_from it_customer = s_cust[] ).
go_report->display( CHANGING ct_lines = gt_lines ).
CLASS ltc_report DEFINITION FINAL 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 totals_per_customer FOR TESTING.
METHODS unknown_type_skipped FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}SHARPEN' ) ( '{{P}}KNTYPE' ) ) ).
DATA lt_types TYPE STANDARD TABLE OF {{p}}kntype WITH EMPTY KEY.
lt_types = VALUE #( ( type_id = 'CHEF' price = '2.00' )
( type_id = 'BONE' price = '3.00' ) ).
go_env->insert_test_data( lt_types ).
DATA lt_items TYPE STANDARD TABLE OF {{p}}sharpen WITH EMPTY KEY.
lt_items = VALUE #( ( item_id = 1 customer = 'A' knife_type = 'CHEF' knife_count = 10 sharp_date = '20260101' )
( item_id = 2 customer = 'A' knife_type = 'BONE' knife_count = 2 sharp_date = '20260102' )
( item_id = 3 customer = 'B' knife_type = 'CHEF' knife_count = 5 sharp_date = '20260101' )
( item_id = 4 customer = 'B' knife_type = 'PLAS' knife_count = 7 sharp_date = '20260101' ) ).
go_env->insert_test_data( lt_items ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_customer.
DATA(lt_lines) = NEW lcl_report( )->select_totals(
iv_from = '20260101'
it_customer = VALUE #( ( sign = 'E' option = 'EQ' low = 'X' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lt_lines[ 1 ]-customer ).
cl_abap_unit_assert=>assert_equals( exp = 12 act = lt_lines[ 1 ]-knives ).
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}kntype-price( 26 ) act = lt_lines[ 1 ]-fee ).
ENDMETHOD.
METHOD unknown_type_skipped.
DATA(lt_lines) = NEW lcl_report( )->select_totals(
iv_from = '20260101'
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'B' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 5 act = lt_lines[ 1 ]-knives ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,34 @@
{
"id": "G1944",
"pool": "train",
"object_type": "PROG",
"category": "C",
"attempts": [
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 2,
"killed": 2,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,102 @@
CLASS {{p}}t15_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES tt_customer TYPE RANGE OF {{p}}sharpen-customer.
METHODS run
IMPORTING iv_from TYPE d
it_customer TYPE tt_customer OPTIONAL
RETURNING VALUE(rr_data) TYPE REF TO data.
METHODS lines_of
IMPORTING ir_data TYPE REF TO data
RETURNING VALUE(rv_lines) TYPE i.
METHODS value_of
IMPORTING ir_data TYPE REF TO data
iv_row TYPE i
iv_col TYPE string
RETURNING VALUE(rv_value) TYPE string.
METHODS all_customers FOR TESTING.
METHODS sorted_by_fee FOR TESTING.
METHODS fee_and_knives FOR TESTING.
METHODS customer_filter FOR TESTING.
METHODS date_filter FOR TESTING.
METHODS unknown_type FOR TESTING.
ENDCLASS.
CLASS {{p}}t15_hidden IMPLEMENTATION.
METHOD run.
DATA(lt_customer) = it_customer.
IF lt_customer IS INITIAL.
lt_customer = VALUE #( ( sign = 'E' option = 'EQ' low = 'X' ) ).
ENDIF.
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
SUBMIT {{p}}sharp_sum WITH p_from = iv_from WITH s_cust IN lt_customer AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = rr_data ).
CATCH cx_salv_bs_sc_runtime_info.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
ENDMETHOD.
METHOD lines_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
IF ir_data IS NOT BOUND.
RETURN.
ENDIF.
ASSIGN ir_data->* TO <lt_data>.
IF sy-subrc = 0.
rv_lines = lines( <lt_data> ).
ENDIF.
ENDMETHOD.
METHOD value_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
FIELD-SYMBOLS <ls_line> TYPE any.
FIELD-SYMBOLS <lv_value> TYPE any.
IF ir_data IS NOT BOUND.
cl_abap_unit_assert=>fail( msg = 'No result table' ).
ENDIF.
ASSIGN ir_data->* TO <lt_data>.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'No result table' ).
READ TABLE <lt_data> INDEX iv_row ASSIGNING <ls_line>.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Row { iv_row } is missing| ).
ASSIGN COMPONENT iv_col OF STRUCTURE <ls_line> TO <lv_value>.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Column { iv_col } is missing| ).
rv_value = condense( CONV string( <lv_value> ) ).
ENDMETHOD.
METHOD all_customers.
cl_abap_unit_assert=>assert_equals( exp = 4 act = lines_of( run( '20260101' ) ) ).
ENDMETHOD.
METHOD sorted_by_fee.
DATA(lr_data) = run( '20260101' ).
cl_abap_unit_assert=>assert_equals( exp = `CANTEEN` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `CUSTOMER` ) ).
cl_abap_unit_assert=>assert_equals( exp = `DELI` act = value_of( ir_data = lr_data iv_row = 4 iv_col = `CUSTOMER` ) ).
ENDMETHOD.
METHOD fee_and_knives.
DATA(lr_data) = run( '20260101' ).
cl_abap_unit_assert=>assert_equals( exp = `TRATTORIA` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `CUSTOMER` ) ).
cl_abap_unit_assert=>assert_equals( exp = `14` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `KNIVES` ) ).
cl_abap_unit_assert=>assert_equals( exp = `26.00` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `FEE` ) ).
ENDMETHOD.
METHOD customer_filter.
DATA(lr_data) = run( iv_from = '20260101'
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'BISTRO' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals( exp = `12.00` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `FEE` ) ).
ENDMETHOD.
METHOD date_filter.
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines_of( run( '20260113' ) ) ).
ENDMETHOD.
METHOD unknown_type.
DATA(lr_data) = run( iv_from = '20260101'
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'DELI' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals( exp = `5` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `KNIVES` ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,40 @@
{
"task": "G1944",
"mutants": [
{
"object": "{{P}}SHARP_SUM",
"mutant": "line 30: * -> / (arith)",
"status": "invalid",
"hidden": "0/0",
"failed_tests": []
},
{
"object": "{{P}}SHARP_SUM",
"mutant": "line 33: >= -> < (rel)",
"status": "killed",
"hidden": "1/6",
"failed_tests": [
"ALL_CUSTOMERS",
"CUSTOMER_FILTER",
"FEE_AND_KNIVES",
"SORTED_BY_FEE",
"UNKNOWN_TYPE"
]
},
{
"object": "{{P}}SHARP_SUM",
"mutant": "line 34: AND -> OR (logic)",
"status": "killed",
"hidden": "3/6",
"failed_tests": [
"CUSTOMER_FILTER",
"DATE_FILTER",
"UNKNOWN_TYPE"
]
}
],
"valid": 2,
"killed": 2,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,104 @@
REPORT {{p}}sharp_sum.
DATA gv_customer TYPE {{p}}sharpen-customer.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_cust FOR gv_customer.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES tt_customer TYPE RANGE OF {{p}}sharpen-customer.
TYPES:
BEGIN OF ty_line,
customer TYPE {{p}}sharpen-customer,
knives TYPE i,
fee TYPE {{p}}kntype-price,
END OF ty_line.
TYPES tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
METHODS select_totals
IMPORTING iv_from TYPE d
it_customer TYPE tt_customer
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT s~customer,
SUM( s~knife_count ) AS knives,
SUM( s~knife_count * t~price ) AS fee
FROM {{p}}sharpen AS s
INNER JOIN {{p}}kntype AS t ON t~type_id = s~knife_type
WHERE s~sharp_date >= @iv_from
AND s~customer IN @it_customer
GROUP BY s~customer
ORDER BY fee DESCENDING
INTO CORRESPONDING FIELDS OF TABLE @rt_lines.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->select_totals( iv_from = p_from it_customer = s_cust[] ).
go_report->display( CHANGING ct_lines = gt_lines ).
CLASS ltc_report DEFINITION FINAL 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 totals_per_customer FOR TESTING.
METHODS unknown_type_skipped FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}SHARPEN' ) ( '{{P}}KNTYPE' ) ) ).
DATA lt_types TYPE STANDARD TABLE OF {{p}}kntype WITH EMPTY KEY.
lt_types = VALUE #( ( type_id = 'CHEF' price = '2.00' )
( type_id = 'BONE' price = '3.00' ) ).
go_env->insert_test_data( lt_types ).
DATA lt_items TYPE STANDARD TABLE OF {{p}}sharpen WITH EMPTY KEY.
lt_items = VALUE #( ( item_id = 1 customer = 'A' knife_type = 'CHEF' knife_count = 10 sharp_date = '20260101' )
( item_id = 2 customer = 'A' knife_type = 'BONE' knife_count = 2 sharp_date = '20260102' )
( item_id = 3 customer = 'B' knife_type = 'CHEF' knife_count = 5 sharp_date = '20260101' )
( item_id = 4 customer = 'B' knife_type = 'PLAS' knife_count = 7 sharp_date = '20260101' ) ).
go_env->insert_test_data( lt_items ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_customer.
DATA(lt_lines) = NEW lcl_report( )->select_totals(
iv_from = '20260101'
it_customer = VALUE #( ( sign = 'E' option = 'EQ' low = 'X' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lt_lines[ 1 ]-customer ).
cl_abap_unit_assert=>assert_equals( exp = 12 act = lt_lines[ 1 ]-knives ).
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}kntype-price( 26 ) act = lt_lines[ 1 ]-fee ).
ENDMETHOD.
METHOD unknown_type_skipped.
DATA(lt_lines) = NEW lcl_report( )->select_totals(
iv_from = '20260101'
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'B' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 5 act = lt_lines[ 1 ]-knives ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,10 @@
@EndUserText.label : 'Knife type price list'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}kntype {
key client : abap.clnt not null;
key type_id : abap.char(5) not null;
price : abap.dec(15,2);
}

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Knife sharpening items'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}sharpen {
key client : abap.clnt not null;
key item_id : abap.int4 not null;
customer : abap.char(10);
knife_type : abap.char(5);
knife_count : abap.int4;
sharp_date : abap.dats;
}

View File

@@ -0,0 +1,28 @@
CLASS {{p}}t15_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS {{p}}t15_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DELETE FROM {{p}}kntype.
INSERT {{p}}kntype FROM TABLE @( VALUE #(
( type_id = 'CHEF' price = '2.00' )
( type_id = 'PARI' price = '1.50' )
( type_id = 'BONE' price = '3.00' )
( type_id = 'BREAD' price = '1.00' ) ) ).
DELETE FROM {{p}}sharpen.
INSERT {{p}}sharpen FROM TABLE @( VALUE #(
( item_id = 1 customer = 'TRATTORIA' knife_type = 'CHEF' knife_count = 10 sharp_date = '20260110' )
( item_id = 2 customer = 'TRATTORIA' knife_type = 'PARI' knife_count = 4 sharp_date = '20260112' )
( item_id = 3 customer = 'BISTRO' knife_type = 'CHEF' knife_count = 6 sharp_date = '20260111' )
( item_id = 4 customer = 'BISTRO' knife_type = 'BONE' knife_count = 2 sharp_date = '20251220' )
( item_id = 5 customer = 'DELI' knife_type = 'BREAD' knife_count = 5 sharp_date = '20260115' )
( item_id = 6 customer = 'DELI' knife_type = 'SUSHI' knife_count = 8 sharp_date = '20260116' )
( item_id = 7 customer = 'CANTEEN' knife_type = 'CHEF' knife_count = 20 sharp_date = '20260120' ) ) ).
COMMIT WORK.
out->write( sy-dbcnt ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,48 @@
# 1. Goal
A mobile knife sharpening service visits restaurants and sharpens their knives.
The office needs a summary of the sharpening fees of each customer for a period.
# 2. Open questions
None.
# 3. Context
- Table {{P}}SHARPEN is in package $TMP and contains data.
Fields: ITEM_ID (INT4, key), CUSTOMER (CHAR 10), KNIFE_TYPE (CHAR 5),
KNIFE_COUNT (INT4), SHARP_DATE (DATS).
One row is one item of a sharpening round.
- Table {{P}}KNTYPE is in package $TMP and contains the price list.
Fields: TYPE_ID (CHAR 5, key), PRICE (DEC 15,2).
PRICE is the fee for one knife of that type.
# 4. Contract
- Create the executable program {{P}}SHARP_SUM in package $TMP.
- Selection screen:
- Parameter P_FROM, type DATS, mandatory: the first sharpening date to include.
- Select-option S_CUST for the customer.
- Show the result with CL_SALV_TABLE. The output table has these columns, with
these names:
- CUSTOMER: the customer.
- KNIVES: the total number of knives.
- FEE: the total fee. FEE is an amount with two decimal places.
# 5. Business rules
1. Include an item only if SHARP_DATE is on or after P_FROM and CUSTOMER is in
S_CUST.
2. Include an item only if its KNIFE_TYPE has an entry in {{P}}KNTYPE.
3. The fee of an item is KNIFE_COUNT multiplied by the PRICE of its knife type.
4. Show one line for each customer that has at least one included item.
5. KNIVES is the sum of KNIFE_COUNT of the included items of the customer.
6. FEE is the sum of the fees of the included items of the customer.
7. Sort the lines by FEE, the highest fee first.
# 6. Constraints
- Release target: 7.58.
- Coding standards: Clean ABAP. Read the sharpening items and the prices with
one database access. Do not read the database inside a loop. Keep the methods
below 40 statements.
- Out of scope: do not change {{P}}SHARPEN and {{P}}KNTYPE.
# 7. Acceptance
- The program is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests as local test classes in the program.

View File

@@ -0,0 +1,67 @@
{
"id": "G1944",
"category": "C",
"object_type": "PROG",
"difficulty": 2,
"release_target": "v758",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}SHARPEN",
"file": "seed/sharpen.tabl.asabap",
"description": "Knife sharpening items"
},
{
"type": "TABL",
"name": "{{P}}KNTYPE",
"file": "seed/kntype.tabl.asabap",
"description": "Knife type price list"
},
{
"type": "CLAS",
"name": "{{P}}T15_SEED",
"file": "seed/t15_seed.clas.abap",
"description": "T15 seed data",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}SHARP_SUM",
"parameters": [
"p_from",
"s_cust"
]
}
],
"out_of_scope": [
"{{P}}SHARPEN",
"{{P}}KNTYPE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T15_HIDDEN",
"file": "hidden/t15_hidden.clas.abap",
"description": "T15 hidden tests"
}
],
"reference": [
{
"type": "PROG",
"name": "{{P}}SHARP_SUM",
"file": "reference/sharp_sum.prog.abap",
"description": "Sharpening fee per customer"
}
],
"craft_checks": [
"db_operation_in_loop",
"method_length"
]
}