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.