Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in group / Aggreation #207

Open
hendrik77 opened this issue Sep 27, 2022 · 1 comment
Open

Error in group / Aggreation #207

hendrik77 opened this issue Sep 27, 2022 · 1 comment
Assignees

Comments

@hendrik77
Copy link

Exercism Aggregate error:

CLASS zcl_itab_aggregation DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    TYPES group TYPE c LENGTH 1.
    TYPES: BEGIN OF initial_numbers_type,
             group  TYPE group,
             number TYPE i,
           END OF initial_numbers_type,
           initial_numbers TYPE STANDARD TABLE OF initial_numbers_type WITH EMPTY KEY.

    TYPES: BEGIN OF aggregated_data_type,
             group   TYPE group,
             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 WITH EMPTY KEY.

    METHODS perform_aggregation
      IMPORTING
        initial_numbers        TYPE initial_numbers
      RETURNING
        VALUE(aggregated_data) TYPE aggregated_data.
  PROTECTED SECTION.
  PRIVATE SECTION.

ENDCLASS.

CLASS zcl_itab_aggregation IMPLEMENTATION.
  METHOD perform_aggregation.
    LOOP AT initial_numbers INTO DATA(g) GROUP BY g-group .
      DATA(group_count) = REDUCE #( INIT i = 0 FOR c IN GROUP g NEXT i += 1 ).
      DATA(group_sum)   = REDUCE #( INIT j = 0 FOR s IN GROUP g NEXT j += s-number ).
      INSERT VALUE #(
        group = g-group
        count = group_count
        sum = group_sum
        min = REDUCE #( INIT min_number = 9999
                        FOR m IN GROUP g
                        NEXT min_number = nmin( val1 = min_number val2 = m-number ) )
        max = REDUCE #( INIT max_number = 0
                        FOR n IN GROUP 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

@larshp
Copy link
Member

larshp commented Sep 28, 2022

first fix = abaplint/abaplint#2706

@larshp larshp self-assigned this Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants