Application Development and Automation 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: 
Read only

Dynamic Sort on table control

Former Member
0 Likes
469

Hi friends,

I am having a problem when sorting the table control dynamically based on the fields selectd.

sorting is not working, when you select multiple fields ( one numeric field and one character field ) I have written code for handling multiple field sort,gettting field names correctly, everything looks fine but internal table is not getting sorted.

Is it related unicode issue..?

Any help will be appreciated.

Sample code:

loop at tc_control into lc_cols.

case lc_cols-selected.

wehn 'X'.

split lc_cols-screen-name at '-' into gv_tabname gv_fieldname.

move gv_fieldname gs_struc+lv_off(20)

add 20 to lv_off.

endcase.

endloop.

if ok_code = 'ASCE'.

sort itab by (gs_struc-field1) (gs_struc-field2) ..... ascending

endif.

Thanks in advance

Thiru.p

2 REPLIES 2
Read only

ferry_lianto
Active Contributor
0 Likes
360

Hi Thiru,

Please check this demo program.

DEMO_DYNPRO_TABCONT_LOOP_AT

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
360

Hi

Try using an internal table for the field names..

Example

-


DATA: BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

END OF ITAB.

DATA: ITAB_FIELD(30) OCCURS 0 WITH HEADER LINE.

  • DATA

ITAB-MATNR = 'ABC'.

ITAB-WERKS = 'ABCD'.

APPEND ITAB.

ITAB-MATNR = 'ABC'.

ITAB-WERKS = 'ABC'.

APPEND ITAB.

  • SORT INTERNAL TABLE

ITAB_FIELD = 'MATNR'.

<b>APPEND ITAB_FIELD.</b>

ITAB_FIELD = 'WERKS'.

<b>APPEND ITAB_FIELD.</b>

<b>SORT ITAB BY (ITAB_FIELD).</b>

LOOP AT ITAB.

WRITE: / ITAB-MATNR,ITAB-WERKS.

ENDLOOP.

Thanks

Naren