2009 Jan 06 9:44 AM
Hi All,
I have a dynamic internal tables like <dy_table> , i want to get distinct values from this internal tables,
how to do that, structure of dynamic internal tables is dynamic acc. to user conditions.
regards,
Anuj
2009 Jan 06 9:57 AM
Hi
use the fieldcatalog structure for geting the fields
and sort dyn table with the fields available in the dynamic fieldcat.
delete adjacent duplicates based on these fields.
reg
Ramya
Hi All,
I have a dynamic internal tables like <dy_table> , i want to get distinct values from this internal tables,
how to do that, structure of dynamic internal tables is dynamic acc. to user conditions.
regards,
Anuj
2009 Jan 06 9:48 AM
Hi Anuj
Just try this,
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = tb_fields_for_it
IMPORTING
ep_table = gp_dyn_table.
ASSIGN gp_dyn_table->* TO <gt_table>.
ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <fs_table>.
LOOP AT tb_output.
*To assign value for serial number.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_table> TO <ls_field>.
<ls_field> = tb_output-sno.
UNASSIGN <ls_field>.
*To assign value for Sales Organization.
ASSIGN COMPONENT 2 OF STRUCTURE <fs_table> TO <ls_field>.
<ls_field> = tb_output-vkorg.
UNASSIGN <ls_field>.
*To assign Rate for its respective Condition type.
LOOP AT tb_konp WHERE knumh = tb_output-knumh.
READ TABLE tb_fieldcat1 WITH KEY fieldname = tb_output-kschl.
IF sy-subrc EQ 0.
lv_count = tb_fieldcat1-col_pos.
ASSIGN COMPONENT lv_count OF STRUCTURE <fs_table> TO <ls_field>.
IF tb_konp-konwa EQ '%'.
tb_konp-kbetr = tb_konp-kbetr / co_10.
<ls_field> = tb_konp-kbetr.
ELSE.
<ls_field> = tb_konp-kbetr.
ENDIF.
ENDIF.
ENDLOOP.
lv_count = lv_count + 1.
APPEND <fs_table> TO <gt_table>.
CLEAR <fs_table>.
ENDLOOP.
Hope this proves helpful to you.
2009 Jan 06 9:54 AM
Hi,
Sort the table, delete adjacent duplicates from itab this will solve your problem
2009 Jan 06 9:55 AM
Hi
even though it is dynamic
the structure or the fieldcatalog for creating this dynamic table will have a structure.
use the fields from the structure and sort itab based on those fields
and delete adjacent duplicates
reg
Ramya
2009 Jan 06 9:57 AM
Hi
use the fieldcatalog structure for geting the fields
and sort dyn table with the fields available in the dynamic fieldcat.
delete adjacent duplicates based on these fields.
reg
Ramya
2009 Jan 06 10:01 AM
Hi,
If you want the distinct values for all columns, then
SORT itab. "If required use the addition BY
DELETE ADJACENT DUPLICATES FROM connection_tab. "If required use COMPARING addition"Now your internal table contains unique entries
Or else if you want distinct values of a particular column,
LOOP AT itab INTO wa_tab.
AT NEW <column name>.
(write your logic to store the value).
ENDAT.
ENDLOOP.Regards,
Manoj Kumar P
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |