Step F first pass: 81/92 accepted; budget floor 60 calls; rejected slots moved for regeneration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
Kral
2026-10-03 12:10:52 +02:00
parent d3250acfb8
commit 39769afce8
741 changed files with 40573 additions and 317 deletions

View File

@@ -0,0 +1,125 @@
CLASS {{p}}zoo_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS all_enclosures FOR TESTING.
METHODS sort_by_cost FOR TESTING.
METHODS tie_break FOR TESTING.
METHODS weight_filter FOR TESTING.
METHODS weight_boundary FOR TESTING.
METHODS enclosure_filter FOR TESTING.
ENDCLASS.
CLASS lcl_zoo_helper DEFINITION FINAL.
PUBLIC SECTION.
TYPES tt_enclosure TYPE RANGE OF {{p}}animal-enclosure.
CLASS-METHODS run
IMPORTING iv_minwg TYPE {{p}}animal-weight_kg
it_enclosure TYPE tt_enclosure OPTIONAL
RETURNING VALUE(rr_data) TYPE REF TO data.
CLASS-METHODS lines_of
IMPORTING ir_data TYPE REF TO data
RETURNING VALUE(rv_lines) TYPE i.
CLASS-METHODS value_of
IMPORTING ir_data TYPE REF TO data
iv_row TYPE i
iv_col TYPE string
RETURNING VALUE(rv_value) TYPE string.
ENDCLASS.
CLASS lcl_zoo_helper IMPLEMENTATION.
METHOD run.
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
SUBMIT {{p}}zoo_feed
WITH p_minwg = iv_minwg
WITH s_encl IN it_enclosure
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 BOUND.
ASSIGN ir_data->* TO <lt_data>.
rv_lines = lines( <lt_data> ).
ENDIF.
ENDMETHOD.
METHOD value_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
ASSIGN ir_data->* TO <lt_data>.
ASSIGN <lt_data>[ iv_row ] TO FIELD-SYMBOL(<ls_line>).
ASSIGN COMPONENT iv_col OF STRUCTURE <ls_line> TO FIELD-SYMBOL(<lv_value>).
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Column { iv_col } missing| ).
rv_value = condense( CONV string( <lv_value> ) ).
ENDMETHOD.
ENDCLASS.
CLASS {{p}}zoo_hidden IMPLEMENTATION.
METHOD all_enclosures.
cl_abap_unit_assert=>assert_equals(
exp = 3
act = lcl_zoo_helper=>lines_of( lcl_zoo_helper=>run( iv_minwg = '0.0' ) ) ).
ENDMETHOD.
METHOD sort_by_cost.
DATA(lr_data) = lcl_zoo_helper=>run( iv_minwg = '0.0' ).
cl_abap_unit_assert=>assert_equals(
exp = `JUNGLE`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 1 iv_col = `ENCLOSURE` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `34.00`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 1 iv_col = `COST` ) ).
ENDMETHOD.
METHOD tie_break.
DATA(lr_data) = lcl_zoo_helper=>run( iv_minwg = '0.0' ).
cl_abap_unit_assert=>assert_equals(
exp = `AQUA`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 2 iv_col = `ENCLOSURE` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `SAVANNA`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 3 iv_col = `ENCLOSURE` ) ).
ENDMETHOD.
METHOD weight_filter.
DATA(lr_data) = lcl_zoo_helper=>run( iv_minwg = '10.0' ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lcl_zoo_helper=>lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals(
exp = `AQUA`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 3 iv_col = `ENCLOSURE` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `1`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 3 iv_col = `ANIMALS` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `15.00`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 3 iv_col = `COST` ) ).
ENDMETHOD.
METHOD weight_boundary.
DATA(lr_low) = lcl_zoo_helper=>run( iv_minwg = '8.0' ).
cl_abap_unit_assert=>assert_equals(
exp = `3`
act = lcl_zoo_helper=>value_of( ir_data = lr_low iv_row = 1 iv_col = `ANIMALS` ) ).
DATA(lr_high) = lcl_zoo_helper=>run( iv_minwg = '9.0' ).
cl_abap_unit_assert=>assert_equals(
exp = `2`
act = lcl_zoo_helper=>value_of( ir_data = lr_high iv_row = 1 iv_col = `ANIMALS` ) ).
ENDMETHOD.
METHOD enclosure_filter.
DATA(lr_data) = lcl_zoo_helper=>run(
iv_minwg = '0.0'
it_enclosure = VALUE #( ( sign = 'I' option = 'EQ' low = 'AQUA' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lcl_zoo_helper=>lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals(
exp = `20.00`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 1 iv_col = `COST` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `2`
act = lcl_zoo_helper=>value_of( ir_data = lr_data iv_row = 1 iv_col = `ANIMALS` ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,160 @@
REPORT {{p}}zoo_feed.
TYPES: BEGIN OF ty_line,
enclosure TYPE {{p}}animal-enclosure,
animals TYPE i,
cost TYPE {{p}}animal-food_cost,
END OF ty_line.
TYPES tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
TYPES tt_enclosure TYPE RANGE OF {{p}}animal-enclosure.
TYPES: BEGIN OF ty_animal,
enclosure TYPE {{p}}animal-enclosure,
food_cost TYPE {{p}}animal-food_cost,
END OF ty_animal.
TYPES tt_animal TYPE STANDARD TABLE OF ty_animal WITH EMPTY KEY.
DATA gv_enclosure TYPE {{p}}animal-enclosure.
PARAMETERS p_minwg TYPE {{p}}animal-weight_kg OBLIGATORY.
SELECT-OPTIONS s_encl FOR gv_enclosure.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
CLASS-METHODS select_lines
IMPORTING iv_min_weight TYPE {{p}}animal-weight_kg
it_enclosure TYPE tt_enclosure
RETURNING VALUE(rt_lines) TYPE tt_line.
CLASS-METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_lines.
DATA: lt_animals TYPE tt_animal,
ls_animal TYPE ty_animal,
ls_line TYPE ty_line.
SELECT enclosure food_cost
FROM {{p}}animal
INTO CORRESPONDING FIELDS OF TABLE lt_animals
WHERE weight_kg >= iv_min_weight
AND enclosure IN it_enclosure.
LOOP AT lt_animals INTO ls_animal.
READ TABLE rt_lines INTO ls_line
WITH KEY enclosure = ls_animal-enclosure.
IF sy-subrc = 0.
ls_line-animals = ls_line-animals + 1.
ls_line-cost = ls_line-cost + ls_animal-food_cost.
MODIFY rt_lines FROM ls_line INDEX sy-tabix.
ELSE.
CLEAR ls_line.
ls_line-enclosure = ls_animal-enclosure.
ls_line-animals = 1.
ls_line-cost = ls_animal-food_cost.
APPEND ls_line TO rt_lines.
ENDIF.
ENDLOOP.
SORT rt_lines BY cost DESCENDING enclosure ASCENDING.
ENDMETHOD.
METHOD display.
DATA: lo_alv TYPE REF TO cl_salv_table,
lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = lo_alv
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO lx_msg.
MESSAGE lx_msg TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA gt_lines TYPE tt_line.
gt_lines = lcl_report=>select_lines( iv_min_weight = p_minwg
it_enclosure = s_encl[] ).
lcl_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_enclosure FOR TESTING.
METHODS weight_filter FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}ANIMAL' ) ) ).
DATA: lt_animal TYPE STANDARD TABLE OF {{p}}animal WITH EMPTY KEY,
ls_animal TYPE {{p}}animal.
ls_animal-animal_id = 1.
ls_animal-enclosure = 'A'.
ls_animal-species = 'LION'.
ls_animal-weight_kg = '100.0'.
ls_animal-food_cost = '10.00'.
APPEND ls_animal TO lt_animal.
CLEAR ls_animal.
ls_animal-animal_id = 2.
ls_animal-enclosure = 'A'.
ls_animal-species = 'CUB'.
ls_animal-weight_kg = '5.0'.
ls_animal-food_cost = '2.00'.
APPEND ls_animal TO lt_animal.
CLEAR ls_animal.
ls_animal-animal_id = 3.
ls_animal-enclosure = 'B'.
ls_animal-species = 'SEAL'.
ls_animal-weight_kg = '50.0'.
ls_animal-food_cost = '7.00'.
APPEND ls_animal TO lt_animal.
go_env->insert_test_data( lt_animal ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_enclosure.
DATA: lt_lines TYPE tt_line,
ls_line TYPE ty_line,
lt_none TYPE tt_enclosure.
lt_lines = lcl_report=>select_lines( iv_min_weight = '0.0'
it_enclosure = lt_none ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
READ TABLE lt_lines INTO ls_line INDEX 1.
cl_abap_unit_assert=>assert_equals( exp = 'A' act = ls_line-enclosure ).
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}animal-food_cost( 12 ) act = ls_line-cost ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_line-animals ).
ENDMETHOD.
METHOD weight_filter.
DATA: lt_lines TYPE tt_line,
ls_line TYPE ty_line,
lt_none TYPE tt_enclosure.
lt_lines = lcl_report=>select_lines( iv_min_weight = '10.0'
it_enclosure = lt_none ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
READ TABLE lt_lines INTO ls_line INDEX 1.
cl_abap_unit_assert=>assert_equals( exp = 1 act = ls_line-animals ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Zoo animals'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}animal {
key client : abap.clnt not null;
key animal_id : abap.int4 not null;
enclosure : abap.char(10);
species : abap.char(20);
weight_kg : abap.dec(5,1);
food_cost : abap.dec(9,2);
}

View File

@@ -0,0 +1,19 @@
CLASS {{p}}zoo_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS {{p}}zoo_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DELETE FROM {{p}}animal.
INSERT {{p}}animal FROM TABLE @( VALUE #(
( animal_id = 1 enclosure = 'SAVANNA' species = 'GIRAFFE' weight_kg = '800.0' food_cost = '12.50' )
( animal_id = 2 enclosure = 'SAVANNA' species = 'ZEBRA' weight_kg = '250.0' food_cost = '7.50' )
( animal_id = 3 enclosure = 'AQUA' species = 'SEAL' weight_kg = '120.0' food_cost = '15.00' )
( animal_id = 4 enclosure = 'AQUA' species = 'OTTER' weight_kg = '6.0' food_cost = '5.00' )
( animal_id = 5 enclosure = 'JUNGLE' species = 'TIGER' weight_kg = '200.0' food_cost = '15.00' )
( animal_id = 6 enclosure = 'JUNGLE' species = 'BEAR' weight_kg = '300.0' food_cost = '15.00' )
( animal_id = 7 enclosure = 'JUNGLE' species = 'MONKEY' weight_kg = '8.0' food_cost = '4.00' ) ) ).
out->write( sy-dbcnt ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,41 @@
# 1. Goal
Show the daily food cost of each enclosure in the zoo in an ALV list. The zoo
keeper uses the list to plan the daily food order.
# 2. Open questions
None.
# 3. Context
- The table {{P}}ANIMAL exists in package $TMP and contains data.
Fields: ANIMAL_ID (INT4, key), ENCLOSURE (CHAR 10), SPECIES (CHAR 20),
WEIGHT_KG (DEC 5,1), FOOD_COST (DEC 9,2).
- FOOD_COST is the daily food cost of one animal in euro.
# 4. Contract
- Create the executable program {{P}}ZOO_FEED in package $TMP.
- Selection screen:
- Parameter P_MINWG, type {{P}}ANIMAL-WEIGHT_KG, mandatory: the smallest
weight of an animal to include.
- Select-option S_ENCL for the enclosure.
- Show the result with CL_SALV_TABLE. The output table has these columns with
these names: ENCLOSURE, ANIMALS, COST.
# 5. Business rules
1. Include an animal only if WEIGHT_KG is greater than or equal to P_MINWG and
ENCLOSURE is in S_ENCL.
2. Show one line for each enclosure that has at least one included animal.
3. ANIMALS is the number of included animals of the enclosure.
4. COST is the sum of FOOD_COST of the included animals of the enclosure.
5. Sort the lines by COST, the highest cost first.
6. If two lines have the same COST, sort them by ENCLOSURE in ascending order.
# 6. Constraints
- Release target: 7.40 SP05. Use only ABAP syntax that is available in this
release. Do not use syntax of a newer release.
- Coding standards: Clean ABAP. Read the data with one database access.
- Out of scope: do not change {{P}}ANIMAL.
# 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,61 @@
{
"id": "G0161",
"category": "G",
"object_type": "PROG",
"difficulty": 2,
"release_target": "v740sp05",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 40,
"max_activations": 10
},
"seed": [
{
"type": "TABL",
"name": "{{P}}ANIMAL",
"file": "seed/animal.tabl.asabap",
"description": "Zoo animals"
},
{
"type": "CLAS",
"name": "{{P}}ZOO_SEED",
"file": "seed/zoo_seed.clas.abap",
"description": "Zoo seed data",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}ZOO_FEED",
"parameters": [
"p_minwg",
"s_encl"
]
}
],
"out_of_scope": [
"{{P}}ANIMAL"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}ZOO_HIDDEN",
"file": "hidden/zoo_hidden.clas.abap",
"description": "Zoo feed hidden tests"
}
],
"reference": [
{
"type": "PROG",
"name": "{{P}}ZOO_FEED",
"file": "reference/zoo_feed.prog.abap",
"description": "Daily food cost per enclosure"
}
],
"craft_checks": [
"db_operation_in_loop",
"method_length",
"no_newer_syntax"
]
}