‎2009 May 11 1:51 PM
Hello everybody.
How can I sort a dynamic internal table ???
The sentence sort <gt_table> by matnr werks doesn' t work... How can I do it ??
Thanks a lot.
Regards
‎2009 May 11 1:58 PM
DATA otab TYPE ABAP_SORTORDER_TAB .
SORT <fs_tab> BY (otab).Table ABAP_SORTORDER_TAB has fields
NAME
DESCENDING
ASTEXT
fill it accordingly
‎2009 May 11 1:57 PM
‎2009 May 11 1:57 PM
Hi, try the following link...it might be helpful!
Regards,
Vin
‎2009 May 11 1:58 PM
DATA otab TYPE ABAP_SORTORDER_TAB .
SORT <fs_tab> BY (otab).Table ABAP_SORTORDER_TAB has fields
NAME
DESCENDING
ASTEXT
fill it accordingly
‎2009 May 11 1:58 PM
Hi use this.
SORT <itab> BY (MATNR) (WERKS).
look into this link also.
it will work for you.
.
‎2009 May 11 1:59 PM
Here is an example:
PARAMETERS dbtab TYPE c LENGTH 30.
SELECT-OPTIONS columns FOR dbtab NO INTERVALS.
DATA: otab TYPE abap_sortorder_tab,
oline TYPE abap_sortorder,
dref TYPE REF TO data.
FIELD-SYMBOLS: <column> LIKE LINE OF columns,
<itab> TYPE STANDARD TABLE.
TRY.
CREATE DATA dref TYPE STANDARD TABLE OF (dbtab).
***I have assigned the value dref to internal table as follows***
ASSIGN dref->* TO <itab>.
CATCH cx_sy_create_data_error.
MESSAGE 'Wrong data type!' TYPE 'I' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDTRY.
TRY.
SELECT *
FROM (dbtab)
INTO TABLE <itab>.
CATCH cx_sy_dynamic_osql_semantics.
MESSAGE 'Wrong database table!' TYPE 'I' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDTRY.
LOOP AT columns ASSIGNING <column>.
oline-name = <column>-low.
APPEND oline TO otab.
ENDLOOP.
TRY.
SORT <itab> BY (otab).
CATCH cx_sy_dyn_table_ill_comp_val.
MESSAGE 'Wrong column name!' TYPE 'I' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDTRY.