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,14 @@
{
"id": "G1147",
"pool": "train",
"object_type": "PROG",
"category": "H",
"attempts": [
{
"stage": "validate",
"oracle": 100,
"null": 30
}
],
"accepted": true
}

View File

@@ -0,0 +1,85 @@
REPORT {{p}}charge_stat.
PARAMETERS p_from TYPE d OBLIGATORY.
PARAMETERS p_to TYPE d OBLIGATORY.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
station TYPE {{p}}charge-station,
total_kwh TYPE {{p}}charge-energy_kwh,
sessions TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
METHODS select_totals
IMPORTING iv_from TYPE d
iv_to TYPE d
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT station, SUM( energy_kwh ) AS total_kwh, COUNT( * ) AS sessions
FROM {{p}}charge
WHERE session_date >= @iv_from
AND session_date <= @iv_to
GROUP BY station
ORDER BY total_kwh 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 iv_to = p_to ).
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_station FOR TESTING.
METHODS date_filter FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}CHARGE' ) ) ).
DATA lt_charge TYPE STANDARD TABLE OF {{p}}charge WITH EMPTY KEY.
lt_charge = VALUE #( ( session_id = 1 station = 'A' session_date = '20260101' energy_kwh = 10 )
( session_id = 2 station = 'A' session_date = '20260102' energy_kwh = 5 )
( session_id = 3 station = 'B' session_date = '20260101' energy_kwh = 40 ) ).
go_env->insert_test_data( lt_charge ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_station.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' iv_to = '20261231' ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'B' act = lt_lines[ 1 ]-station ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 2 ]-sessions ).
ENDMETHOD.
METHOD date_filter.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260102' iv_to = '20261231' ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}charge-energy_kwh( 5 ) act = lt_lines[ 1 ]-total_kwh ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,12 @@
@EndUserText.label : 'Charging sessions'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}charge {
key client : abap.clnt not null;
key session_id : abap.int4 not null;
station : abap.char(10);
session_date : abap.dats;
energy_kwh : abap.dec(15,2);
}

View File

@@ -0,0 +1,17 @@
CLASS {{p}}charge_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS {{p}}charge_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DELETE FROM {{p}}charge.
INSERT {{p}}charge FROM TABLE @( VALUE #(
( session_id = 1 station = 'ST01' session_date = '20260110' energy_kwh = '120.00' )
( session_id = 2 station = 'ST01' session_date = '20260210' energy_kwh = '80.00' )
( session_id = 3 station = 'ST02' session_date = '20260115' energy_kwh = '300.00' )
( session_id = 4 station = 'ST03' session_date = '20251231' energy_kwh = '500.00' )
( session_id = 5 station = 'ST03' session_date = '20260301' energy_kwh = '20.00' ) ) ).
out->write( sy-dbcnt ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,40 @@
# 1. Goal
Show the energy that each charging station of a charging network delivered in a
period in an ALV list. The network operator uses the list to compare the
stations.
# 2. Open questions
None.
# 3. Context
- Table {{P}}CHARGE exists in package $TMP. It contains data.
Fields: SESSION_ID (INT4, key), STATION (CHAR 10), SESSION_DATE (DATS),
ENERGY_KWH (DEC 15,2).
# 4. Contract
- Create the executable program {{P}}CHARGE_STAT in package $TMP.
- Selection screen:
- Parameter P_FROM, type DATS, mandatory: the first session date to include.
- Parameter P_TO, type DATS, mandatory: the last session date to include.
- Show the result with CL_SALV_TABLE. The output table has these columns, with
these names: STATION, TOTAL_KWH, SESSIONS.
# 5. Business rules
1. Include a session only if SESSION_DATE is on or after P_FROM and on or before
P_TO.
2. Show one line for each station that has at least one included session.
3. TOTAL_KWH is the sum of ENERGY_KWH of the included sessions of the station.
SESSIONS is the number of included sessions of the station.
4. Sort the lines by TOTAL_KWH, the highest total first.
5. Sort the lines by TOTAL_KWH, the lowest total first.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP. Read the data with one database access.
- Out of scope: do not change {{P}}CHARGE.
# 7. Acceptance
- The program is active and has no syntax error.
- The list shows one line for each station that has at least one included
session.
- Write ABAP Unit tests as local test classes in the program.

View File

@@ -0,0 +1,73 @@
{
"id": "G1147",
"category": "H",
"object_type": "PROG",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "stop",
"expected_gap": {
"description": "Business rules 4 and 5 contradict each other: rule 4 sorts the lines by TOTAL_KWH with the highest total first, rule 5 sorts them by TOTAL_KWH with the lowest total first.",
"keywords": [
[
"sort",
"order"
],
[
"contradict",
"rule"
],
[
"conflict",
"rule"
],
[
"total",
"rule"
]
]
},
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}CHARGE",
"file": "seed/charge.tabl.asabap",
"description": "Charging sessions of a charging network"
},
{
"type": "CLAS",
"name": "{{P}}CHARGE_SEED",
"file": "seed/charge_seed.clas.abap",
"description": "Seed data for {{P}}CHARGE",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}CHARGE_STAT",
"parameters": [
"p_from",
"p_to"
]
}
],
"out_of_scope": [
"{{P}}CHARGE"
],
"hidden_tests": [],
"reference": [
{
"type": "PROG",
"name": "{{P}}CHARGE_STAT",
"file": "reference/charge_stat.prog.abap",
"description": "Energy per charging station (reference assumes the highest total first)"
}
],
"craft_checks": [
"method_length"
]
}