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

Sort Data .....

Former Member
0 Likes
365

Dear All ,

Any idea how we going to sort the data like below :

<----- under same field -


>

1325864829-8/5/200110:37:55 AM-RD-164

1325864829-8/5/200910:37:55 AM-RD-165

1325864829-8/5/200310:37:55 AM-RD-166

1325864829-8/5/200710:37:55 AM-RD-167

1325864829-8/5/200910:37:55 AM-RD-168

1325864829-8/5/200810:37:55 AM-RD-169

1325864829-8/5/200410:37:55 AM-RD-170

value 1325864829-8/5/200910:37:55 AM-RD-170 is under 1 field .

when i want to sort this table by refer to this field last 3 digit ... exp last digit 164 .

any idea???

thanks ...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
328

Hi,

Try like this,


data: v_len type i,
         v_len1 type i.

v_len = strlen( wa_tab-field1).
v_len1 = vlen - 3.

sort itab by field1+v_len1(3).

Regards,

Vik

2 REPLIES 2
Read only

Former Member
0 Likes
329

Hi,

Try like this,


data: v_len type i,
         v_len1 type i.

v_len = strlen( wa_tab-field1).
v_len1 = vlen - 3.

sort itab by field1+v_len1(3).

Regards,

Vik

Read only

DirkAltmann
Active Participant
0 Likes
328

Hi Olrang,

you need a second column where you store the last 3 digits for sorting. See the following code:

types: begin of ty_row,

value type string,

sort type string,

end of ty_row.

data gs_row type ty_row.

data gt_table type STANDARD TABLE OF ty_row.

data gf_len type i.

gs_row-value = '1325864829-8/5/200110:37:55 AM-RD-164'.

append gs_row to gt_table.

gs_row-value = '1325864829-8/5/200910:37:55 AM-RD-165'.

append gs_row to gt_table.

gs_row-value = '1325864829-8/5/200310:37:55 AM-RD-166'.

append gs_row to gt_table.

gs_row-value = '1325864829-8/5/200710:37:55 AM-RD-167'.

append gs_row to gt_table.

gs_row-value = '1325864829-8/5/200910:37:55 AM-RD-168'.

append gs_row to gt_table.

gs_row-value = '1325864829-8/5/200810:37:55 AM-RD-169'.

append gs_row to gt_table.

gs_row-value = '1325864829-8/5/200410:37:55 AM-RD-170'.

append gs_row to gt_table.

loop at gt_table into gs_row.

gf_len = strlen( gs_row-value ) - 3.

gs_row-sort = gs_row-value+gf_len(3).

modify gt_table from gs_row.

endloop.

sort gt_table by sort.

Regards,

Dirk