Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
122
tasks_gen/train/G1148/faulty/m0_studio_bill.prog.abap
Normal file
122
tasks_gen/train/G1148/faulty/m0_studio_bill.prog.abap
Normal file
@@ -0,0 +1,122 @@
|
||||
REPORT {{p}}studio_bill.
|
||||
|
||||
TYPES ty_amount TYPE p LENGTH 15 DECIMALS 2.
|
||||
|
||||
DATA gv_customer TYPE {{p}}studio-customer.
|
||||
|
||||
PARAMETERS p_from TYPE d OBLIGATORY.
|
||||
PARAMETERS p_min TYPE ty_amount OBLIGATORY.
|
||||
SELECT-OPTIONS s_cust FOR gv_customer.
|
||||
|
||||
CLASS lcl_billing DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_line,
|
||||
customer TYPE {{p}}studio-customer,
|
||||
sessions TYPE i,
|
||||
tracks TYPE i,
|
||||
fee TYPE {{p}}studio-fee,
|
||||
END OF ty_line,
|
||||
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
|
||||
TYPES tt_customer TYPE RANGE OF {{p}}studio-customer.
|
||||
|
||||
METHODS select_bills
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_min TYPE ty_amount
|
||||
it_customer TYPE tt_customer
|
||||
RETURNING VALUE(rt_lines) TYPE tt_line.
|
||||
|
||||
METHODS display
|
||||
CHANGING ct_lines TYPE tt_line.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_billing IMPLEMENTATION.
|
||||
METHOD select_bills.
|
||||
SELECT customer,
|
||||
COUNT( * ) AS sessions,
|
||||
SUM( tracks ) AS tracks,
|
||||
SUM( fee ) AS fee
|
||||
FROM {{p}}studio
|
||||
WHERE rec_date < @iv_from
|
||||
AND tracks > 0
|
||||
AND customer IN @it_customer
|
||||
GROUP BY customer
|
||||
HAVING SUM( fee ) >= @iv_min
|
||||
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_billing) = NEW lcl_billing( ).
|
||||
DATA(gt_lines) = go_billing->select_bills( iv_from = p_from
|
||||
iv_min = p_min
|
||||
it_customer = s_cust[] ).
|
||||
go_billing->display( CHANGING ct_lines = gt_lines ).
|
||||
|
||||
CLASS ltc_billing 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 date_filter FOR TESTING.
|
||||
METHODS zero_tracks_ignored FOR TESTING.
|
||||
METHODS min_fee_filter FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_billing IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}STUDIO' ) ) ).
|
||||
DATA lt_studio TYPE STANDARD TABLE OF {{p}}studio WITH EMPTY KEY.
|
||||
lt_studio = VALUE #(
|
||||
( rec_id = 1 customer = 'ACME' rec_date = '20260101' tracks = 10 fee = 100 )
|
||||
( rec_id = 2 customer = 'ACME' rec_date = '20260102' tracks = 5 fee = 50 )
|
||||
( rec_id = 3 customer = 'BLUE' rec_date = '20260101' tracks = 0 fee = 0 )
|
||||
( rec_id = 4 customer = 'BLUE' rec_date = '20251201' tracks = 7 fee = 70 ) ).
|
||||
go_env->insert_test_data( lt_studio ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD totals_per_customer.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 1 ]-sessions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 15 act = lt_lines[ 1 ]-tracks ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}studio-fee( 150 ) act = lt_lines[ 1 ]-fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_tracks_ignored.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0
|
||||
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'BLUE' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD min_fee_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 120 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ACME' act = lt_lines[ 1 ]-customer ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
122
tasks_gen/train/G1148/faulty/m1_studio_bill.prog.abap
Normal file
122
tasks_gen/train/G1148/faulty/m1_studio_bill.prog.abap
Normal file
@@ -0,0 +1,122 @@
|
||||
REPORT {{p}}studio_bill.
|
||||
|
||||
TYPES ty_amount TYPE p LENGTH 15 DECIMALS 2.
|
||||
|
||||
DATA gv_customer TYPE {{p}}studio-customer.
|
||||
|
||||
PARAMETERS p_from TYPE d OBLIGATORY.
|
||||
PARAMETERS p_min TYPE ty_amount OBLIGATORY.
|
||||
SELECT-OPTIONS s_cust FOR gv_customer.
|
||||
|
||||
CLASS lcl_billing DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_line,
|
||||
customer TYPE {{p}}studio-customer,
|
||||
sessions TYPE i,
|
||||
tracks TYPE i,
|
||||
fee TYPE {{p}}studio-fee,
|
||||
END OF ty_line,
|
||||
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
|
||||
TYPES tt_customer TYPE RANGE OF {{p}}studio-customer.
|
||||
|
||||
METHODS select_bills
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_min TYPE ty_amount
|
||||
it_customer TYPE tt_customer
|
||||
RETURNING VALUE(rt_lines) TYPE tt_line.
|
||||
|
||||
METHODS display
|
||||
CHANGING ct_lines TYPE tt_line.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_billing IMPLEMENTATION.
|
||||
METHOD select_bills.
|
||||
SELECT customer,
|
||||
COUNT( * ) AS sessions,
|
||||
SUM( tracks ) AS tracks,
|
||||
SUM( fee ) AS fee
|
||||
FROM {{p}}studio
|
||||
WHERE rec_date >= @iv_from
|
||||
OR tracks > 0
|
||||
AND customer IN @it_customer
|
||||
GROUP BY customer
|
||||
HAVING SUM( fee ) >= @iv_min
|
||||
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_billing) = NEW lcl_billing( ).
|
||||
DATA(gt_lines) = go_billing->select_bills( iv_from = p_from
|
||||
iv_min = p_min
|
||||
it_customer = s_cust[] ).
|
||||
go_billing->display( CHANGING ct_lines = gt_lines ).
|
||||
|
||||
CLASS ltc_billing 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 date_filter FOR TESTING.
|
||||
METHODS zero_tracks_ignored FOR TESTING.
|
||||
METHODS min_fee_filter FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_billing IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}STUDIO' ) ) ).
|
||||
DATA lt_studio TYPE STANDARD TABLE OF {{p}}studio WITH EMPTY KEY.
|
||||
lt_studio = VALUE #(
|
||||
( rec_id = 1 customer = 'ACME' rec_date = '20260101' tracks = 10 fee = 100 )
|
||||
( rec_id = 2 customer = 'ACME' rec_date = '20260102' tracks = 5 fee = 50 )
|
||||
( rec_id = 3 customer = 'BLUE' rec_date = '20260101' tracks = 0 fee = 0 )
|
||||
( rec_id = 4 customer = 'BLUE' rec_date = '20251201' tracks = 7 fee = 70 ) ).
|
||||
go_env->insert_test_data( lt_studio ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD totals_per_customer.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 1 ]-sessions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 15 act = lt_lines[ 1 ]-tracks ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}studio-fee( 150 ) act = lt_lines[ 1 ]-fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_tracks_ignored.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0
|
||||
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'BLUE' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD min_fee_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 120 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ACME' act = lt_lines[ 1 ]-customer ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
122
tasks_gen/train/G1148/faulty/m2_studio_bill.prog.abap
Normal file
122
tasks_gen/train/G1148/faulty/m2_studio_bill.prog.abap
Normal file
@@ -0,0 +1,122 @@
|
||||
REPORT {{p}}studio_bill.
|
||||
|
||||
TYPES ty_amount TYPE p LENGTH 15 DECIMALS 2.
|
||||
|
||||
DATA gv_customer TYPE {{p}}studio-customer.
|
||||
|
||||
PARAMETERS p_from TYPE d OBLIGATORY.
|
||||
PARAMETERS p_min TYPE ty_amount OBLIGATORY.
|
||||
SELECT-OPTIONS s_cust FOR gv_customer.
|
||||
|
||||
CLASS lcl_billing DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_line,
|
||||
customer TYPE {{p}}studio-customer,
|
||||
sessions TYPE i,
|
||||
tracks TYPE i,
|
||||
fee TYPE {{p}}studio-fee,
|
||||
END OF ty_line,
|
||||
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
|
||||
TYPES tt_customer TYPE RANGE OF {{p}}studio-customer.
|
||||
|
||||
METHODS select_bills
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_min TYPE ty_amount
|
||||
it_customer TYPE tt_customer
|
||||
RETURNING VALUE(rt_lines) TYPE tt_line.
|
||||
|
||||
METHODS display
|
||||
CHANGING ct_lines TYPE tt_line.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_billing IMPLEMENTATION.
|
||||
METHOD select_bills.
|
||||
SELECT customer,
|
||||
COUNT( * ) AS sessions,
|
||||
SUM( tracks ) AS tracks,
|
||||
SUM( fee ) AS fee
|
||||
FROM {{p}}studio
|
||||
WHERE rec_date >= @iv_from
|
||||
AND tracks <= 0
|
||||
AND customer IN @it_customer
|
||||
GROUP BY customer
|
||||
HAVING SUM( fee ) >= @iv_min
|
||||
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_billing) = NEW lcl_billing( ).
|
||||
DATA(gt_lines) = go_billing->select_bills( iv_from = p_from
|
||||
iv_min = p_min
|
||||
it_customer = s_cust[] ).
|
||||
go_billing->display( CHANGING ct_lines = gt_lines ).
|
||||
|
||||
CLASS ltc_billing 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 date_filter FOR TESTING.
|
||||
METHODS zero_tracks_ignored FOR TESTING.
|
||||
METHODS min_fee_filter FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_billing IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}STUDIO' ) ) ).
|
||||
DATA lt_studio TYPE STANDARD TABLE OF {{p}}studio WITH EMPTY KEY.
|
||||
lt_studio = VALUE #(
|
||||
( rec_id = 1 customer = 'ACME' rec_date = '20260101' tracks = 10 fee = 100 )
|
||||
( rec_id = 2 customer = 'ACME' rec_date = '20260102' tracks = 5 fee = 50 )
|
||||
( rec_id = 3 customer = 'BLUE' rec_date = '20260101' tracks = 0 fee = 0 )
|
||||
( rec_id = 4 customer = 'BLUE' rec_date = '20251201' tracks = 7 fee = 70 ) ).
|
||||
go_env->insert_test_data( lt_studio ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD totals_per_customer.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 1 ]-sessions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 15 act = lt_lines[ 1 ]-tracks ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}studio-fee( 150 ) act = lt_lines[ 1 ]-fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_tracks_ignored.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0
|
||||
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'BLUE' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD min_fee_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 120 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ACME' act = lt_lines[ 1 ]-customer ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
122
tasks_gen/train/G1148/faulty/m3_studio_bill.prog.abap
Normal file
122
tasks_gen/train/G1148/faulty/m3_studio_bill.prog.abap
Normal file
@@ -0,0 +1,122 @@
|
||||
REPORT {{p}}studio_bill.
|
||||
|
||||
TYPES ty_amount TYPE p LENGTH 15 DECIMALS 2.
|
||||
|
||||
DATA gv_customer TYPE {{p}}studio-customer.
|
||||
|
||||
PARAMETERS p_from TYPE d OBLIGATORY.
|
||||
PARAMETERS p_min TYPE ty_amount OBLIGATORY.
|
||||
SELECT-OPTIONS s_cust FOR gv_customer.
|
||||
|
||||
CLASS lcl_billing DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_line,
|
||||
customer TYPE {{p}}studio-customer,
|
||||
sessions TYPE i,
|
||||
tracks TYPE i,
|
||||
fee TYPE {{p}}studio-fee,
|
||||
END OF ty_line,
|
||||
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
|
||||
TYPES tt_customer TYPE RANGE OF {{p}}studio-customer.
|
||||
|
||||
METHODS select_bills
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_min TYPE ty_amount
|
||||
it_customer TYPE tt_customer
|
||||
RETURNING VALUE(rt_lines) TYPE tt_line.
|
||||
|
||||
METHODS display
|
||||
CHANGING ct_lines TYPE tt_line.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_billing IMPLEMENTATION.
|
||||
METHOD select_bills.
|
||||
SELECT customer,
|
||||
COUNT( * ) AS sessions,
|
||||
SUM( tracks ) AS tracks,
|
||||
SUM( fee ) AS fee
|
||||
FROM {{p}}studio
|
||||
WHERE rec_date >= @iv_from
|
||||
AND tracks > 0
|
||||
OR customer IN @it_customer
|
||||
GROUP BY customer
|
||||
HAVING SUM( fee ) >= @iv_min
|
||||
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_billing) = NEW lcl_billing( ).
|
||||
DATA(gt_lines) = go_billing->select_bills( iv_from = p_from
|
||||
iv_min = p_min
|
||||
it_customer = s_cust[] ).
|
||||
go_billing->display( CHANGING ct_lines = gt_lines ).
|
||||
|
||||
CLASS ltc_billing 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 date_filter FOR TESTING.
|
||||
METHODS zero_tracks_ignored FOR TESTING.
|
||||
METHODS min_fee_filter FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_billing IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}STUDIO' ) ) ).
|
||||
DATA lt_studio TYPE STANDARD TABLE OF {{p}}studio WITH EMPTY KEY.
|
||||
lt_studio = VALUE #(
|
||||
( rec_id = 1 customer = 'ACME' rec_date = '20260101' tracks = 10 fee = 100 )
|
||||
( rec_id = 2 customer = 'ACME' rec_date = '20260102' tracks = 5 fee = 50 )
|
||||
( rec_id = 3 customer = 'BLUE' rec_date = '20260101' tracks = 0 fee = 0 )
|
||||
( rec_id = 4 customer = 'BLUE' rec_date = '20251201' tracks = 7 fee = 70 ) ).
|
||||
go_env->insert_test_data( lt_studio ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD totals_per_customer.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 1 ]-sessions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 15 act = lt_lines[ 1 ]-tracks ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}studio-fee( 150 ) act = lt_lines[ 1 ]-fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_tracks_ignored.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0
|
||||
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'BLUE' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD min_fee_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 120 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ACME' act = lt_lines[ 1 ]-customer ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
122
tasks_gen/train/G1148/faulty/m4_studio_bill.prog.abap
Normal file
122
tasks_gen/train/G1148/faulty/m4_studio_bill.prog.abap
Normal file
@@ -0,0 +1,122 @@
|
||||
REPORT {{p}}studio_bill.
|
||||
|
||||
TYPES ty_amount TYPE p LENGTH 15 DECIMALS 2.
|
||||
|
||||
DATA gv_customer TYPE {{p}}studio-customer.
|
||||
|
||||
PARAMETERS p_from TYPE d OBLIGATORY.
|
||||
PARAMETERS p_min TYPE ty_amount OBLIGATORY.
|
||||
SELECT-OPTIONS s_cust FOR gv_customer.
|
||||
|
||||
CLASS lcl_billing DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_line,
|
||||
customer TYPE {{p}}studio-customer,
|
||||
sessions TYPE i,
|
||||
tracks TYPE i,
|
||||
fee TYPE {{p}}studio-fee,
|
||||
END OF ty_line,
|
||||
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
|
||||
TYPES tt_customer TYPE RANGE OF {{p}}studio-customer.
|
||||
|
||||
METHODS select_bills
|
||||
IMPORTING iv_from TYPE d
|
||||
iv_min TYPE ty_amount
|
||||
it_customer TYPE tt_customer
|
||||
RETURNING VALUE(rt_lines) TYPE tt_line.
|
||||
|
||||
METHODS display
|
||||
CHANGING ct_lines TYPE tt_line.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_billing IMPLEMENTATION.
|
||||
METHOD select_bills.
|
||||
SELECT customer,
|
||||
COUNT( * ) AS sessions,
|
||||
SUM( tracks ) AS tracks,
|
||||
SUM( fee ) AS fee
|
||||
FROM {{p}}studio
|
||||
WHERE rec_date >= @iv_from
|
||||
AND tracks > 0
|
||||
AND customer IN @it_customer
|
||||
GROUP BY customer
|
||||
HAVING SUM( fee ) < @iv_min
|
||||
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_billing) = NEW lcl_billing( ).
|
||||
DATA(gt_lines) = go_billing->select_bills( iv_from = p_from
|
||||
iv_min = p_min
|
||||
it_customer = s_cust[] ).
|
||||
go_billing->display( CHANGING ct_lines = gt_lines ).
|
||||
|
||||
CLASS ltc_billing 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 date_filter FOR TESTING.
|
||||
METHODS zero_tracks_ignored FOR TESTING.
|
||||
METHODS min_fee_filter FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltc_billing IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}STUDIO' ) ) ).
|
||||
DATA lt_studio TYPE STANDARD TABLE OF {{p}}studio WITH EMPTY KEY.
|
||||
lt_studio = VALUE #(
|
||||
( rec_id = 1 customer = 'ACME' rec_date = '20260101' tracks = 10 fee = 100 )
|
||||
( rec_id = 2 customer = 'ACME' rec_date = '20260102' tracks = 5 fee = 50 )
|
||||
( rec_id = 3 customer = 'BLUE' rec_date = '20260101' tracks = 0 fee = 0 )
|
||||
( rec_id = 4 customer = 'BLUE' rec_date = '20251201' tracks = 7 fee = 70 ) ).
|
||||
go_env->insert_test_data( lt_studio ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD totals_per_customer.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 1 ]-sessions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 15 act = lt_lines[ 1 ]-tracks ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}studio-fee( 150 ) act = lt_lines[ 1 ]-fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD date_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 0 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_tracks_ignored.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20260101' iv_min = 0
|
||||
it_customer = VALUE #( ( sign = 'I' option = 'EQ' low = 'BLUE' ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_lines ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD min_fee_filter.
|
||||
DATA(lt_lines) = NEW lcl_billing( )->select_bills(
|
||||
iv_from = '20251201' iv_min = 120 it_customer = VALUE #( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ACME' act = lt_lines[ 1 ]-customer ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user