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,37 @@
{
"id": "G1106",
"pool": "train",
"object_type": "PROG",
"category": "G",
"attempts": [
{
"stage": "bundle",
"errors": [
"seed/bake_seed.clas.abap line 9: syntax error for release v702 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"INSERT\""
],
"by_check": {
"abaplint": 1
}
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "bundle",
"errors": [
"reference/bake_sales.prog.abap line 38: syntax error for release v702 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"SELECT\""
],
"by_check": {
"abaplint": 1
}
}
],
"accepted": false
}

View File

@@ -0,0 +1,113 @@
CLASS {{p}}bake_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES tt_shop TYPE RANGE OF {{p}}deliv-shop.
METHODS run
IMPORTING iv_date TYPE d
it_shop TYPE tt_shop 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_shops_for_date FOR TESTING.
METHODS sorted_by_revenue FOR TESTING.
METHODS totals_and_counts FOR TESTING.
METHODS shop_filter FOR TESTING.
METHODS date_filter FOR TESTING.
METHODS empty_result FOR TESTING.
METHODS tie_break_by_shop FOR TESTING.
ENDCLASS.
CLASS {{p}}bake_hidden IMPLEMENTATION.
METHOD run.
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
SUBMIT {{p}}bake_sales WITH p_date = iv_date WITH s_shop IN it_shop 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>.
DESCRIBE TABLE <lt_data> LINES rv_lines.
ENDIF.
ENDMETHOD.
METHOD value_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
FIELD-SYMBOLS <ls_line> TYPE any.
FIELD-SYMBOLS <lv_value> TYPE any.
DATA lv_text TYPE string.
ASSIGN ir_data->* TO <lt_data>.
READ TABLE <lt_data> ASSIGNING <ls_line> INDEX iv_row.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'row not found' ).
ASSIGN COMPONENT iv_col OF STRUCTURE <ls_line> TO <lv_value>.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'column not found' ).
lv_text = <lv_value>.
SHIFT lv_text LEFT DELETING LEADING space.
SHIFT lv_text RIGHT DELETING TRAILING space.
rv_value = lv_text.
ENDMETHOD.
METHOD all_shops_for_date.
cl_abap_unit_assert=>assert_equals( exp = 5 act = lines_of( run( '20260401' ) ) ).
ENDMETHOD.
METHOD sorted_by_revenue.
DATA lr_data TYPE REF TO data.
lr_data = run( '20260401' ).
cl_abap_unit_assert=>assert_equals( exp = 'SUED' act = value_of( ir_data = lr_data iv_row = 1 iv_col = 'SHOP' ) ).
cl_abap_unit_assert=>assert_equals( exp = 'OST' act = value_of( ir_data = lr_data iv_row = 5 iv_col = 'SHOP' ) ).
ENDMETHOD.
METHOD totals_and_counts.
DATA lr_data TYPE REF TO data.
lr_data = run( '20260401' ).
cl_abap_unit_assert=>assert_equals( exp = 'NORD' act = value_of( ir_data = lr_data iv_row = 2 iv_col = 'SHOP' ) ).
cl_abap_unit_assert=>assert_equals( exp = '150' act = value_of( ir_data = lr_data iv_row = 2 iv_col = 'LOAVES' ) ).
cl_abap_unit_assert=>assert_equals( exp = '400.00' act = value_of( ir_data = lr_data iv_row = 2 iv_col = 'REVENUE' ) ).
cl_abap_unit_assert=>assert_equals( exp = '2' act = value_of( ir_data = lr_data iv_row = 2 iv_col = 'DELIVERIES' ) ).
ENDMETHOD.
METHOD shop_filter.
DATA lr_data TYPE REF TO data.
DATA lt_shop TYPE tt_shop.
DATA ls_shop LIKE LINE OF lt_shop.
ls_shop-sign = 'I'.
ls_shop-option = 'EQ'.
ls_shop-low = 'NORD'.
APPEND ls_shop TO lt_shop.
lr_data = run( iv_date = '20260401' it_shop = lt_shop ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals( exp = '150' act = value_of( ir_data = lr_data iv_row = 1 iv_col = 'LOAVES' ) ).
cl_abap_unit_assert=>assert_equals( exp = '400.00' act = value_of( ir_data = lr_data iv_row = 1 iv_col = 'REVENUE' ) ).
ENDMETHOD.
METHOD date_filter.
DATA lr_data TYPE REF TO data.
lr_data = run( '20260331' ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals( exp = '999' act = value_of( ir_data = lr_data iv_row = 1 iv_col = 'LOAVES' ) ).
cl_abap_unit_assert=>assert_equals( exp = '9980.01' act = value_of( ir_data = lr_data iv_row = 1 iv_col = 'REVENUE' ) ).
ENDMETHOD.
METHOD empty_result.
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines_of( run( '20200101' ) ) ).
ENDMETHOD.
METHOD tie_break_by_shop.
DATA lr_data TYPE REF TO data.
lr_data = run( '20260401' ).
cl_abap_unit_assert=>assert_equals( exp = 'MITT' act = value_of( ir_data = lr_data iv_row = 3 iv_col = 'SHOP' ) ).
cl_abap_unit_assert=>assert_equals( exp = 'WEST' act = value_of( ir_data = lr_data iv_row = 4 iv_col = 'SHOP' ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,173 @@
REPORT {{p}}bake_sales.
DATA gv_shop TYPE {{p}}deliv-shop.
PARAMETERS p_date TYPE d OBLIGATORY.
SELECT-OPTIONS s_shop FOR gv_shop.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES: BEGIN OF ty_raw,
shop TYPE {{p}}deliv-shop,
loaves TYPE {{p}}deliv-loaves,
unit_price TYPE {{p}}deliv-unit_price,
END OF ty_raw.
TYPES tt_raw TYPE STANDARD TABLE OF ty_raw.
TYPES: BEGIN OF ty_line,
shop TYPE {{p}}deliv-shop,
loaves TYPE i,
revenue TYPE {{p}}deliv-unit_price,
deliveries TYPE i,
END OF ty_line.
TYPES tt_line TYPE STANDARD TABLE OF ty_line.
METHODS aggregate
IMPORTING it_raw TYPE tt_raw
CHANGING ct_lines TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD aggregate.
DATA lt_sorted TYPE tt_raw.
DATA ls_raw TYPE ty_raw.
DATA ls_line TYPE ty_line.
CLEAR ct_lines.
lt_sorted = it_raw.
SORT lt_sorted BY shop.
LOOP AT lt_sorted INTO ls_raw.
AT NEW shop.
CLEAR ls_line.
ls_line-shop = ls_raw-shop.
ENDAT.
ls_line-loaves = ls_line-loaves + ls_raw-loaves.
ls_line-revenue = ls_line-revenue + ls_raw-loaves * ls_raw-unit_price.
ls_line-deliveries = ls_line-deliveries + 1.
AT END OF shop.
APPEND ls_line TO ct_lines.
ENDAT.
ENDLOOP.
SORT ct_lines BY revenue DESCENDING shop ASCENDING.
ENDMETHOD.
METHOD display.
DATA lo_alv TYPE REF TO cl_salv_table.
DATA lx_error 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_error.
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
DATA go_report TYPE REF TO lcl_report.
DATA gt_raw TYPE lcl_report=>tt_raw.
DATA gt_lines TYPE lcl_report=>tt_line.
START-OF-SELECTION.
SELECT * FROM {{p}}deliv
WHERE deliv_date = p_date
AND shop IN s_shop
INTO CORRESPONDING FIELDS OF TABLE gt_raw.
CREATE OBJECT go_report.
go_report->aggregate( EXPORTING it_raw = gt_raw CHANGING ct_lines = gt_lines ).
go_report->display( CHANGING ct_lines = gt_lines ).
CLASS ltc_report DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS add_raw
IMPORTING iv_shop TYPE {{p}}deliv-shop
iv_loaves TYPE i
iv_price TYPE {{p}}deliv-unit_price
CHANGING ct_raw TYPE lcl_report=>tt_raw.
METHODS sums_one_shop FOR TESTING.
METHODS sorts_by_revenue FOR TESTING.
METHODS keeps_shops_apart FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD add_raw.
DATA ls_raw TYPE lcl_report=>ty_raw.
ls_raw-shop = iv_shop.
ls_raw-loaves = iv_loaves.
ls_raw-unit_price = iv_price.
APPEND ls_raw TO ct_raw.
ENDMETHOD.
METHOD sums_one_shop.
DATA lt_raw TYPE lcl_report=>tt_raw.
DATA lt_lines TYPE lcl_report=>tt_line.
DATA ls_line TYPE lcl_report=>ty_line.
DATA lo_report TYPE REF TO lcl_report.
DATA lv_exp TYPE {{p}}deliv-unit_price.
DATA lv_count TYPE i.
add_raw( EXPORTING iv_shop = 'NORD' iv_loaves = 10 iv_price = '2.00'
CHANGING ct_raw = lt_raw ).
add_raw( EXPORTING iv_shop = 'NORD' iv_loaves = 5 iv_price = '4.00'
CHANGING ct_raw = lt_raw ).
CREATE OBJECT lo_report.
lo_report->aggregate( EXPORTING it_raw = lt_raw CHANGING ct_lines = lt_lines ).
DESCRIBE TABLE lt_lines LINES lv_count.
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_count ).
READ TABLE lt_lines INTO ls_line INDEX 1.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = 15 act = ls_line-loaves ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_line-deliveries ).
lv_exp = '40.00'.
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = ls_line-revenue ).
ENDMETHOD.
METHOD sorts_by_revenue.
DATA lt_raw TYPE lcl_report=>tt_raw.
DATA lt_lines TYPE lcl_report=>tt_line.
DATA ls_line TYPE lcl_report=>ty_line.
DATA lo_report TYPE REF TO lcl_report.
DATA lv_exp TYPE {{p}}deliv-shop.
add_raw( EXPORTING iv_shop = 'A' iv_loaves = 10 iv_price = '1.00'
CHANGING ct_raw = lt_raw ).
add_raw( EXPORTING iv_shop = 'B' iv_loaves = 10 iv_price = '9.00'
CHANGING ct_raw = lt_raw ).
CREATE OBJECT lo_report.
lo_report->aggregate( EXPORTING it_raw = lt_raw CHANGING ct_lines = lt_lines ).
READ TABLE lt_lines INTO ls_line INDEX 1.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
lv_exp = 'B'.
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = ls_line-shop ).
ENDMETHOD.
METHOD keeps_shops_apart.
DATA lt_raw TYPE lcl_report=>tt_raw.
DATA lt_lines TYPE lcl_report=>tt_line.
DATA lo_report TYPE REF TO lcl_report.
DATA lv_count TYPE i.
add_raw( EXPORTING iv_shop = 'A' iv_loaves = 1 iv_price = '1.00'
CHANGING ct_raw = lt_raw ).
add_raw( EXPORTING iv_shop = 'B' iv_loaves = 1 iv_price = '1.00'
CHANGING ct_raw = lt_raw ).
CREATE OBJECT lo_report.
lo_report->aggregate( EXPORTING it_raw = lt_raw CHANGING ct_lines = lt_lines ).
DESCRIBE TABLE lt_lines LINES lv_count.
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_count ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,57 @@
CLASS {{p}}bake_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PRIVATE SECTION.
TYPES tt_deliv TYPE STANDARD TABLE OF {{p}}deliv.
METHODS add_delivery
IMPORTING iv_id TYPE {{p}}deliv-deliv_id
iv_shop TYPE {{p}}deliv-shop
iv_date TYPE {{p}}deliv-deliv_date
iv_loaves TYPE {{p}}deliv-loaves
iv_price TYPE {{p}}deliv-unit_price
CHANGING ct_deliv TYPE tt_deliv.
ENDCLASS.
CLASS {{p}}bake_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA lt_deliv TYPE tt_deliv.
DELETE FROM {{p}}deliv.
add_delivery( EXPORTING iv_id = 1 iv_shop = 'NORD' iv_date = '20260401'
iv_loaves = 100 iv_price = '2.50'
CHANGING ct_deliv = lt_deliv ).
add_delivery( EXPORTING iv_id = 2 iv_shop = 'NORD' iv_date = '20260401'
iv_loaves = 50 iv_price = '3.00'
CHANGING ct_deliv = lt_deliv ).
add_delivery( EXPORTING iv_id = 3 iv_shop = 'SUED' iv_date = '20260401'
iv_loaves = 200 iv_price = '3.00'
CHANGING ct_deliv = lt_deliv ).
add_delivery( EXPORTING iv_id = 4 iv_shop = 'WEST' iv_date = '20260401'
iv_loaves = 40 iv_price = '5.00'
CHANGING ct_deliv = lt_deliv ).
add_delivery( EXPORTING iv_id = 5 iv_shop = 'MITT' iv_date = '20260401'
iv_loaves = 80 iv_price = '2.50'
CHANGING ct_deliv = lt_deliv ).
add_delivery( EXPORTING iv_id = 6 iv_shop = 'OST' iv_date = '20260401'
iv_loaves = 10 iv_price = '2.50'
CHANGING ct_deliv = lt_deliv ).
add_delivery( EXPORTING iv_id = 7 iv_shop = 'NORD' iv_date = '20260331'
iv_loaves = 999 iv_price = '9.99'
CHANGING ct_deliv = lt_deliv ).
INSERT {{p}}deliv FROM TABLE lt_deliv.
out->write( sy-dbcnt ).
ENDMETHOD.
METHOD add_delivery.
DATA ls_deliv TYPE {{p}}deliv.
ls_deliv-deliv_id = iv_id.
ls_deliv-shop = iv_shop.
ls_deliv-deliv_date = iv_date.
ls_deliv-loaves = iv_loaves.
ls_deliv-unit_price = iv_price.
APPEND ls_deliv TO ct_deliv.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Bread deliveries'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}deliv {
key client : abap.clnt not null;
key deliv_id : abap.int4 not null;
shop : abap.char(4);
deliv_date : abap.dats;
loaves : abap.int4;
unit_price : abap.dec(13,2);
}

View File

@@ -0,0 +1,49 @@
# 1. Goal
Show the bread sales of each shop for one delivery day in an ALV list. The
bakery manager uses the list to compare the shops.
# 2. Open questions
None.
# 3. Context
- Table {{P}}DELIV exists in package $TMP and contains data.
Fields: DELIV_ID (INT4, key), SHOP (CHAR 4), DELIV_DATE (DATS),
LOAVES (INT4), UNIT_PRICE (DEC 13,2).
- One row of {{P}}DELIV is one delivery of bread to one shop on one day.
LOAVES is the number of loaves in this delivery. UNIT_PRICE is the price of
one loaf in this delivery.
# 4. Contract
- Create the executable program {{P}}BAKE_SALES in package $TMP.
- Selection screen:
- Parameter P_DATE, type DATS, mandatory: the delivery day.
- Select-option S_SHOP for the shop.
- Show the result with CL_SALV_TABLE. The output table has these columns with
these names:
- SHOP: the shop.
- LOAVES: the number of loaves.
- REVENUE: the revenue.
- DELIVERIES: the number of deliveries.
# 5. Business rules
1. Include a delivery only if DELIV_DATE is equal to P_DATE and SHOP is in
S_SHOP. An empty S_SHOP includes every shop.
2. Show one line for each shop that has at least one included delivery.
3. LOAVES is the sum of the LOAVES of the included deliveries of the shop.
4. REVENUE is the sum of LOAVES multiplied by UNIT_PRICE of the included
deliveries of the shop.
5. DELIVERIES is the number of included deliveries of the shop.
6. Sort the lines by REVENUE, the highest revenue first. If two shops have the
same REVENUE, the shop with the smaller SHOP value comes first.
7. If no delivery is included, show an empty list.
# 6. Constraints
- Release target: 7.02. Use only language elements that exist in release 7.02.
Do not use inline declarations, constructor expressions, or table expressions.
- Coding standards: Clean ABAP. Read the data with one database access.
- Out of scope: do not change {{P}}DELIV.
# 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,60 @@
{
"id": "G1106",
"category": "G",
"object_type": "PROG",
"difficulty": 2,
"release_target": "v702",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}DELIV",
"file": "seed/deliv.tabl.asabap",
"description": "Bread deliveries"
},
{
"type": "CLAS",
"name": "{{P}}BAKE_SEED",
"file": "seed/bake_seed.clas.abap",
"description": "Bread delivery seed data",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}BAKE_SALES",
"parameters": [
"p_date",
"s_shop"
]
}
],
"out_of_scope": [
"{{P}}DELIV"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}BAKE_HIDDEN",
"file": "hidden/bake_hidden.clas.abap",
"description": "Hidden tests for {{P}}BAKE_SALES"
}
],
"reference": [
{
"type": "PROG",
"name": "{{P}}BAKE_SALES",
"file": "reference/bake_sales.prog.abap",
"description": "Bread sales per shop and day"
}
],
"craft_checks": [
"db_operation_in_loop",
"method_length"
]
}