Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

help in collect

Former Member
0 Kudos

Hi ,

i have 2 tables same ftype of field-symbols and i wont to collect

<dyn_ac> to <col_ac>

how can i do that

LOOP AT <dyn_ac> ASSIGNING <col_ac>.

COLLECT <dyn_a> INTO <col_ac> .

ENDLOOP.

Regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

What problem are you facing in the above code?

Regards

Sumit Agarwal

7 REPLIES 7

Former Member
0 Kudos

hi,

What problem are you facing in the above code?

Regards

Sumit Agarwal

0 Kudos

Hi,

the error is :

You can only use the COLLECT command in a table if all of its non-keyfields are numeric (type I, P, or F). P or F)

Regards

0 Kudos

This is documentation i found for COLLECT

As of Release 6.10, you can use result to set a reference to the inserted or changed row in the form of a field symbol or data reference.

Prerequisite for the use of this statement is that wa is compatible with the row type of itab and all components that are not part of the table key must have a numeric data type (i, p, f).

0 Kudos

Hi Ricardo,

Thats true, COLLECT statement sums up all the numeric fields taking into consideration of all the non-numeric fields ' combination as key.

Hope this helps you.

Regards,

Chandra Sekhar

0 Kudos

Hi Ricardo,

it means what it says

If you use a STANDARD table ABAP will regard all character fields (including NUMC) as the key of the table. COLLECT will sum up the numeric sums in the numeric fields for all unique character field combinations.

From your code extract it can not be seen what the structure of the tables is or how the tables are declared. Also, the assignment for the second table is not clear. You can definitely not COLLECT INTO <col_ac> as <col_ac> is no internal table.

If <dyn_ac> is assigned to the first internal table and <dyn_a> is assigned to the second internal table,


LOOP AT <dyn_ac> ASSIGNING <col_ac>.
  COLLECT <col_ac> INTO <dyn_a> .
ENDLOOP.

may work because the syntax requires COLLECT <structure> INTO <itab>.

From the naming I'd assume that it is the other way round: If <dyn_a> stands for 'dynamic table - all' and <dyn_ac> means 'dynamic table - all collected' then you should LOOP AT <dyn_a> and COLLECT INTO <dyn_ac>.

But this assumption may be wrong.

If the internal tables are sorted or hashed and you did not name all non-numeric fields as key fields, you' rather search for a different solution like calling a form or method to do the addition of key fields.

Regards,

Clemens

0 Kudos

Hi Clemens Li ,

thanks ,

<dyn_ac> have field type dec 2 the problem is <col_ac>

i try with :

i declare <dyn_ac> like that.

CREATE DATA dy_table TYPE TABLE OF tc_tab .

ASSIGN dy_table->* TO <dyn_ac>

and i try to declare <col_ac> the same but its not solved the problem maybe u have any idea?

CREATE DATA dy_table TYPE TABLE OF tc_tab .

ASSIGN dy_table->* TO <col_ac>

Regards

LOOP AT <dyn_ac> ASSIGNING <col_ac>.

COLLECT <col_ac> INTO <dyn_a> .

ENDLOOP.

Former Member
0 Kudos

hi,

Plz check your non key fields if any one them is non numeric then you may not apply collect to the table.

Regards

Sumit Agarwal