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: 

Sort data in TableView

Former Member
0 Kudos

Using Table Maintenance Generator (SE54) was maked TableView for DB table.

1. How I can dort data in that TableView? (not Key value)

2. Or..can I in TableView change Key values?

4 REPLIES 4

Former Member
0 Kudos

Hi, could you sort your tableview ?? I have the same problem... I need to sort it only by one field, not all the primary key...

Thanks in advance..

Former Member
0 Kudos

Check this link,

https://www.sdn.sap.com/irj/scn/advancedsearch?query=sortwithsm30&cat=sdn_all

Regards,

Joan

Former Member
0 Kudos

Hi,

Refer to the following code snipetts.

option1. instead of using SORT = "SERVER" use "APPLICATION" in this case you have to manually handle the sort.

code sample for the same.

page attributes:

sort_element TYPE STRING

sort_event TYPE STRING

s_event TYPE CHAR1

layout

<% if sort_event is initial .

move: 'A' to sort_event .

endif .

if sort_event eq 'A' .

if not sort_element is initial .

sort <outtab> ascending by (sort_element).

else .

sort <outtab> ascending .

endif .

elseif sort_event eq 'D' .

if not sort_element is initial .

sort <outtab> descending by (sort_element).

else .

sort <outtab> descending .

endif .

endif .

%>

<htmlb:tableView id = "test"

headerVisible = "false"

footerVisible = "true"

onHeaderClick = "<%= sort_event %>"

table = "<%= <outtab> %>"

iterator = "<%= grid_iterator %>"

columnDefinitions = "<%= col_control_tab %>"

width = "100%"

columnHeaderVisible = "true"

sort = "APPLICATION" />

oninputprocessing.

CLEAR s_event .

CLASS cl_htmlb_manager DEFINITION LOAD.

DATA: event TYPE REF TO cl_htmlb_event .

data: tv type ref to cl_htmlb_tableview.

data: tv_data type ref to cl_htmlb_event_tableview.

event = cl_htmlb_manager=>get_event( request ).

IF event->event_type EQ cl_htmlb_event_tableview=>co_header_click .

s_event = 'Y' .

tv ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'tableView'

id = 'test' ).

if tv is not initial.

tv_data = tv->data.

endif .

sort_element = tv_data->column_key .

if event->SERVER_EVENT eq 'A' .

sort_event = 'D' .

elseif event->SERVER_EVENT eq 'D' .

sort_event = 'A' .

endif .

ENDIF .

option 2:

use keyColumn = "<itab key filed name in uppercase>"

<htmlb:tableView id = "test"

design = "ALTERNATING"

headerVisible = "true"

headerText = "List of Low Value Assets"

table = "<%= det_tab %>"

width = "100%"

columnHeaderVisible = "true"

sort = "SERVER"

filter = "SERVER"

filterButtonText = "Go"

columnDefinitions = "<%= col_control_tab %>"

keepSelectedRow = "TRUE"

<b> keyColumn = "KEY_COL"</b>

where key_col is a column in the itab which holds the concatenated value of key fields.

for example if your itab has say order no., item number, value and the key is order number and item number.

concatenate them and place it in the key_col field and dont show that in display mode.

and in oninputprocessing you can read the selected row value like below.

if event->event_type eq cl_htmlb_event_tableview=>co_row_selection .

data: tv type ref to cl_htmlb_tableview.

tv ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'tableView'

id = 'test' ).

if tv is not initial.

data: tv_data type ref to cl_htmlb_event_tableview.

tv_data = tv->data.

if tv_data->selectedrowindex is not initial.

data: row like line of <itab> .

either you can use this index to read the itab or

tv_data->selectedrowkey will hold the selected rows key_col value which you can use to read the itab.

Hope this helps.

Regards

Rajesh Kumar

0 Kudos

Sorry, I dind't read the post correctly...

I created a new Z table and I need a SM30 for it. And now the user wants to make some validations and also sort it by a field which is not the primary key..

My PBO is like this:

PROCESS BEFORE OUTPUT.

MODULE liste_initialisieren.

LOOP AT extract WITH CONTROL

tctrl_zrecodifmasiva CURSOR nextline.

MODULE liste_show_liste.

ENDLOOP.

And the PAI like this..

PROCESS AFTER INPUT.

MODULE liste_exit_command AT EXIT-COMMAND.

MODULE liste_before_loop.

LOOP AT extract.

MODULE liste_init_workarea.

CHAIN.

FIELD zrecodifmasiva-zzcodins .

FIELD zrecodifmasiva-gjahr .

FIELD zrecodifmasiva-zztiprec .

FIELD zrecodifmasiva-zznumnorrec .

FIELD zrecodifmasiva-zzstrorgejerant .

FIELD zrecodifmasiva-zzejerrec .

FIELD zrecodifmasiva-zzstrorgrec .

MODULE set_update_flag ON CHAIN-REQUEST.

ENDCHAIN.

FIELD vim_marked MODULE liste_mark_checkbox.

CHAIN.

FIELD zrecodifmasiva-zzcodins .

FIELD zrecodifmasiva-gjahr .

FIELD zrecodifmasiva-zztiprec .

FIELD zrecodifmasiva-zznumnorrec .

MODULE liste_update_liste.

ENDCHAIN.

  • FIELD zrecodifmasiva-zzcodins .

FIELD zrecodifmasiva-zzstrorgejerant MODULE validar_org_ant.

FIELD zrecodifmasiva-zzstrorgrec MODULE validar_org_act.

chain.

FIELD zrecodifmasiva-zznumnorrec .

FIELD zrecodifmasiva-zzstrorgejerant.

FIELD zrecodifmasiva-zzejerrec.

FIELD zrecodifmasiva-zzstrorgrec.

module grabar on chain-request.

endchain.

ENDLOOP.

MODULE liste_after_loop.

I don't know how to sort the data....

thanks in advance..