Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
83
tasks_gen/train/G1102/seed/farm_shop_old.prog.abap
Normal file
83
tasks_gen/train/G1102/seed/farm_shop_old.prog.abap
Normal file
@@ -0,0 +1,83 @@
|
||||
REPORT {{p}}farm_shop_old.
|
||||
|
||||
DATA: BEGIN OF gt_sale OCCURS 0,
|
||||
sale_id TYPE {{p}}gdsale-sale_id,
|
||||
goods_id TYPE {{p}}gdsale-goods_id,
|
||||
sale_day TYPE {{p}}gdsale-sale_day,
|
||||
qty TYPE {{p}}gdsale-qty,
|
||||
sale_state TYPE {{p}}gdsale-sale_state,
|
||||
grp_code TYPE {{p}}goods-grp_code,
|
||||
unit_price TYPE {{p}}goods-unit_price,
|
||||
END OF gt_sale.
|
||||
|
||||
DATA: BEGIN OF gt_out OCCURS 0,
|
||||
grp_code TYPE {{p}}goods-grp_code,
|
||||
sales TYPE i,
|
||||
turnover TYPE {{p}}goods-unit_price,
|
||||
pct_share TYPE p LENGTH 5 DECIMALS 1,
|
||||
END OF gt_out.
|
||||
|
||||
DATA: gv_total TYPE {{p}}goods-unit_price,
|
||||
go_alv TYPE REF TO cl_salv_table.
|
||||
|
||||
PARAMETERS p_day TYPE d OBLIGATORY.
|
||||
SELECT-OPTIONS s_grp FOR {{p}}goods-grp_code.
|
||||
|
||||
START-OF-SELECTION.
|
||||
PERFORM read_data.
|
||||
PERFORM calc_totals.
|
||||
PERFORM show_list.
|
||||
|
||||
FORM read_data.
|
||||
SELECT * FROM {{p}}gdsale INTO CORRESPONDING FIELDS OF TABLE gt_sale
|
||||
WHERE sale_state = 'P'
|
||||
AND sale_day = p_day.
|
||||
LOOP AT gt_sale.
|
||||
SELECT SINGLE grp_code unit_price FROM {{p}}goods
|
||||
INTO (gt_sale-grp_code, gt_sale-unit_price)
|
||||
WHERE goods_id = gt_sale-goods_id.
|
||||
ENDLOOP.
|
||||
DELETE gt_sale WHERE grp_code IS INITIAL.
|
||||
IF s_grp IS NOT INITIAL.
|
||||
DELETE gt_sale WHERE grp_code NOT IN s_grp.
|
||||
ENDIF.
|
||||
SORT gt_sale BY grp_code.
|
||||
ENDFORM.
|
||||
|
||||
FORM calc_totals.
|
||||
LOOP AT gt_sale.
|
||||
AT NEW grp_code.
|
||||
CLEAR gt_out.
|
||||
gt_out-grp_code = gt_sale-grp_code.
|
||||
ENDAT.
|
||||
gt_out-sales = gt_out-sales + 1.
|
||||
gt_out-turnover = gt_out-turnover + gt_sale-qty * gt_sale-unit_price.
|
||||
AT END OF grp_code.
|
||||
APPEND gt_out.
|
||||
ENDAT.
|
||||
ENDLOOP.
|
||||
|
||||
CLEAR gv_total.
|
||||
LOOP AT gt_out.
|
||||
gv_total = gv_total + gt_out-turnover.
|
||||
ENDLOOP.
|
||||
|
||||
IF gv_total <> 0.
|
||||
LOOP AT gt_out.
|
||||
gt_out-pct_share = gt_out-turnover * 100 / gv_total.
|
||||
MODIFY gt_out.
|
||||
ENDLOOP.
|
||||
ENDIF.
|
||||
|
||||
SORT gt_out BY turnover DESCENDING.
|
||||
ENDFORM.
|
||||
|
||||
FORM show_list.
|
||||
TRY.
|
||||
cl_salv_table=>factory(
|
||||
IMPORTING r_salv_table = go_alv
|
||||
CHANGING t_table = gt_out[] ).
|
||||
go_alv->display( ).
|
||||
CATCH cx_salv_msg.
|
||||
ENDTRY.
|
||||
ENDFORM.
|
||||
13
tasks_gen/train/G1102/seed/gdsale.tabl.asabap
Normal file
13
tasks_gen/train/G1102/seed/gdsale.tabl.asabap
Normal file
@@ -0,0 +1,13 @@
|
||||
@EndUserText.label : 'Farm shop sale'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
@AbapCatalog.tableCategory : #TRANSPARENT
|
||||
@AbapCatalog.deliveryClass : #A
|
||||
@AbapCatalog.dataMaintenance : #RESTRICTED
|
||||
define table {{p}}gdsale {
|
||||
key client : abap.clnt not null;
|
||||
key sale_id : abap.int4 not null;
|
||||
goods_id : abap.char(4);
|
||||
sale_day : abap.dats;
|
||||
qty : abap.int2;
|
||||
sale_state : abap.char(1);
|
||||
}
|
||||
11
tasks_gen/train/G1102/seed/goods.tabl.asabap
Normal file
11
tasks_gen/train/G1102/seed/goods.tabl.asabap
Normal file
@@ -0,0 +1,11 @@
|
||||
@EndUserText.label : 'Farm shop goods'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
@AbapCatalog.tableCategory : #TRANSPARENT
|
||||
@AbapCatalog.deliveryClass : #A
|
||||
@AbapCatalog.dataMaintenance : #RESTRICTED
|
||||
define table {{p}}goods {
|
||||
key client : abap.clnt not null;
|
||||
key goods_id : abap.char(4) not null;
|
||||
grp_code : abap.char(4);
|
||||
unit_price : abap.dec(15,2);
|
||||
}
|
||||
31
tasks_gen/train/G1102/seed/shop_seed.clas.abap
Normal file
31
tasks_gen/train/G1102/seed/shop_seed.clas.abap
Normal file
@@ -0,0 +1,31 @@
|
||||
CLASS {{p}}shop_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES if_oo_adt_classrun.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS {{p}}shop_seed IMPLEMENTATION.
|
||||
METHOD if_oo_adt_classrun~main.
|
||||
DELETE FROM {{p}}gdsale.
|
||||
DELETE FROM {{p}}goods.
|
||||
|
||||
INSERT {{p}}goods FROM TABLE @( VALUE #(
|
||||
( goods_id = 'G001' grp_code = 'VEG' unit_price = '2.50' )
|
||||
( goods_id = 'G002' grp_code = 'VEG' unit_price = '3.00' )
|
||||
( goods_id = 'G003' grp_code = 'FRU' unit_price = '4.00' )
|
||||
( goods_id = 'G004' grp_code = 'DAI' unit_price = '5.00' )
|
||||
( goods_id = 'G005' grp_code = 'DAI' unit_price = '1.50' )
|
||||
( goods_id = 'G006' grp_code = 'BAK' unit_price = '2.00' ) ) ).
|
||||
|
||||
INSERT {{p}}gdsale FROM TABLE @( VALUE #(
|
||||
( sale_id = 1 goods_id = 'G001' sale_day = '20260314' qty = 4 sale_state = 'P' )
|
||||
( sale_id = 2 goods_id = 'G002' sale_day = '20260314' qty = 2 sale_state = 'P' )
|
||||
( sale_id = 3 goods_id = 'G003' sale_day = '20260314' qty = 3 sale_state = 'P' )
|
||||
( sale_id = 4 goods_id = 'G004' sale_day = '20260314' qty = 2 sale_state = 'P' )
|
||||
( sale_id = 5 goods_id = 'G005' sale_day = '20260314' qty = 2 sale_state = 'P' )
|
||||
( sale_id = 6 goods_id = 'G001' sale_day = '20260314' qty = 5 sale_state = 'C' )
|
||||
( sale_id = 7 goods_id = 'G003' sale_day = '20260313' qty = 1 sale_state = 'P' )
|
||||
( sale_id = 8 goods_id = 'G006' sale_day = '20260313' qty = 3 sale_state = 'P' ) ) ).
|
||||
|
||||
out->write( sy-dbcnt ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user