You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CLASSzcl_itab_aggregation DEFINITION PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
TYPESgroup TYPE cLENGTH1.
TYPES: BEGIN OF initial_numbers_type,
group TYPEgroup,
number TYPE i,
END OF initial_numbers_type,
initial_numbers TYPE STANDARD TABLE OF initial_numbers_type WITHEMPTY KEY.
TYPES: BEGIN OF aggregated_data_type,
group TYPEgroup,
count TYPE i,
sum TYPE i,
min TYPE i,
max TYPE i,
average TYPE f,
END OF aggregated_data_type,
aggregated_data TYPE STANDARD TABLE OF aggregated_data_type WITHEMPTY KEY.
METHODS perform_aggregation
IMPORTING
initial_numbers TYPE initial_numbers
RETURNINGVALUE(aggregated_data) TYPE aggregated_data.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASSzcl_itab_aggregation IMPLEMENTATION.
METHODperform_aggregation.
LOOP AT initial_numbers INTODATA(g) GROUPBY g-group .
DATA(group_count) =REDUCE #( INIT i=0FOR cINGROUP g NEXT i+=1 ).
DATA(group_sum) =REDUCE #( INIT j =0FOR s INGROUP g NEXT j += s-number ).
INSERTVALUE #(
group= g-group
count= group_count
sum= group_sum
min =REDUCE #( INIT min_number =9999FORmINGROUP g
NEXT min_number =nmin( val1 = min_number val2 = m-number ) )
max =REDUCE #( INIT max_number =0FOR nINGROUP g
NEXT max_number =nmax( val1 = max_number val2 = n-number ) )
average = group_sum / group_count
) INTO TABLE aggregated_data.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
Error from Exercism: ./zcl_itab_aggregation.clas.abap[56, 7] - Statement does not exist in ABAPopen-abap(or a parser error), "DATA" (parser_error) [E] ./zcl_itab_aggregation.clas.abap[57, 7] - Statement does not exist in ABAPopen-abap(or a parser error), "DATA" (parser_error) [E] ./zcl_itab_aggregation.clas.abap[61, 7] - "group_count" not found, findTop (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[62, 7] - "group_sum" not found, findTop (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[66, 12] - Variable "M" contains unknown: Type error, not a table type g-items (unknown_types) [E] ./zcl_itab_aggregation.clas.abap[67, 7] - Component "items" not found in structure (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[75, 12] - Variable "N" contains unknown: Type error, not a table type g-items (unknown_types) [E] ./zcl_itab_aggregation.clas.abap[76, 7] - Component "items" not found in structure (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[81, 7] - "group_sum" not found, findTop (check_syntax) [E] abaplint: 9 issue(s) found
The text was updated successfully, but these errors were encountered:
Exercism Aggregate error:
Error from Exercism:
./zcl_itab_aggregation.clas.abap[56, 7] - Statement does not exist in ABAPopen-abap(or a parser error), "DATA" (parser_error) [E] ./zcl_itab_aggregation.clas.abap[57, 7] - Statement does not exist in ABAPopen-abap(or a parser error), "DATA" (parser_error) [E] ./zcl_itab_aggregation.clas.abap[61, 7] - "group_count" not found, findTop (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[62, 7] - "group_sum" not found, findTop (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[66, 12] - Variable "M" contains unknown: Type error, not a table type g-items (unknown_types) [E] ./zcl_itab_aggregation.clas.abap[67, 7] - Component "items" not found in structure (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[75, 12] - Variable "N" contains unknown: Type error, not a table type g-items (unknown_types) [E] ./zcl_itab_aggregation.clas.abap[76, 7] - Component "items" not found in structure (check_syntax) [E] ./zcl_itab_aggregation.clas.abap[81, 7] - "group_sum" not found, findTop (check_syntax) [E] abaplint: 9 issue(s) found
The text was updated successfully, but these errors were encountered: