on 02-13-2014 7:47 AM
Hi
Is it possible to have a table with columns bound to the context node sorted by particular columns when the table is loaded into the browser? If so can the sorting be applied on multiple columns? The aim is to provide the user with a table that is already sorted by the relevant business criteria.
If possible I would like to know if this can be done without Java which I have already found has relevant classes to achieve.
The table has the onSort property set to call a method
method onactionsort_column .
wd_this->go_table_handler->apply_sorting( ).
endmethod.
go_table_handler is of the associated type IF_WD_TABLE_METHOD_HNDL
In the method WDDOMODIFYVIEW I currently have:
lo_table ?= view->get_element( lc_table ).
wd_this->go_table_handler ?= lo_table->_method_handler.
wd_this->go_table_handler->set_key_attribute_name( 'ID' ).
On the columns the 'sortState' property has been set to 'up'.
Thanks.
Jon
Hi Jon,
As suggested by Mr. Kiran, check the property multipColSorting of table as below
Also, refer the below threads
Web Dynpro ABAP - Sorting in Table UI element ~
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh Okay,,,,
You can sort the table entries before binding it to the context.
Example: Let us say your internal table LT_DATA is having fields like this PERNR, BEGDA,....
sort LT_DATA by PERNR BEGDA ascending.
or
sort LT_DATA by PERNR ascending BEGDA descending.
Now, bind it to the context node, so data is sorted on columns PERNR & BEGDA.
Hope this helps you.
Regards,
Rama
Hi Rama
That's definitely a step in the right direction. However the component in question has been customised and it's not proving as straightforward! The items marked with JM130214 are my additions to get the data into an appropriate table to sort. The code compiles but when run in the browser it throws a Dynamic type conflict when assigning references error.
Here is the code in the method enhancement.
method _PST_0QELSXBBVGDTX82TEPJOF5TKY . "Exit of HANDLEIN_RESULTS_UNREG (in Z_HRRCF_C_SEARCH_UI_ENH_01 )
DATA lo_nd_hrrcf_job_hitlist TYPE REF TO if_wd_context_node.
DATA lo_nd_job_hits TYPE REF TO if_wd_context_node.
data lt_elements type WDR_CONTEXT_ELEMENT_SET.
DATA lo_el_job_hits TYPE REF TO if_wd_context_element.
DATA ls_job_hits TYPE wd_this->element_job_hits.
data LS_5125 type hrp5125.
data LS_5126 type hrp5126.
data lt_hrp1001 TYPE hrp1001.
** Begin insert JM 130214 Sort on int group/end date cols
TYPES: BEGIN OF zerc_s_job_list_with_element,
zroc_enddate TYPE Datum,
zint_group TYPE Rcf_Target_Grp_Txt,
element TYPE REF TO if_wd_context_element,
END OF zerc_s_job_list_with_element.
TYPES: zerc_t_job_list_with_element TYPE STANDARD TABLE OF zerc_s_job_list_with_element
WITH DEFAULT KEY.
DATA ls_job TYPE zerc_s_job_list_with_element.
DATA lt_job TYPE zerc_t_job_list_with_element.
** End insert JM 130214
lo_nd_hrrcf_job_hitlist = wd_context->get_child_node( name = wd_this->wdctx_hrrcf_job_hitlist ).
lo_nd_job_hits = lo_nd_hrrcf_job_hitlist->get_child_node( name = wd_this->wdctx_job_hits ).
IF lo_nd_job_hits IS INITIAL.
exit.
ENDIF.
lt_elements = lo_nd_job_hits->get_elements( ).
if lt_elements is initial.
exit.
endif.
data: lv_enddate type datum.
data: ls_hrobject type hrobject,
lo_sobid type sobid.
data: lt_1001 TYPE STANDARD TABLE OF p1001,
ref_requi_bl TYPE REF TO cl_hrrcf_requi_bl,
current_basic_info TYPE rcf_s_requisition_info_text,
t_position_hrobject TYPE rcf_t_hrobject,
lo_exception TYPE REF TO cx_hrrcf.
FIELD-SYMBOLS: <ls_1001> TYPE hrp1001. "p1001.
loop at lt_elements into lo_el_job_hits.
lo_el_job_hits->get_static_attributes( importing static_attributes = ls_job_hits ).
refresh: t_position_hrobject, LT_1001.
clear ls_hrobject.
ls_hrobject = ls_job_hits-hrobject.
APPEND ls_hrobject TO t_position_hrobject.
DATA: lv_dest TYPE rfcdest.
CALL METHOD cl_hrrcf_wd_services=>get_bl_destination
RECEIVING
rfc_dest = lv_dest.
CALL FUNCTION 'Z_GET_HRP1001'
destination lv_dest
EXPORTING
OTYPE = ls_hrobject-otype "'NC'
OBJID = ls_hrobject-OBJID
PLVAR = '01'
rsign = 'A'
relat = '652'
sclas = 'NB'
istat = '1'
IMPORTING
LS_HRP1001 = lt_hrp1001.
IF lt_hrp1001 IS NOT INITIAL.
assign lt_hrp1001 to <ls_1001>.
clear LS_5125.
ls_hrobject-PLVAR = '01'.
ls_hrobject-OTYPE = 'NB'.
ls_hrobject-OBJID = <ls_1001>-sOBID.
call function 'Z_GET_IT5125_DATA'
destination lv_dest
EXPORTING
CAND_HROBJECT = ls_hrobject
IMPORTING
LS_5125 = LS_5125.
ls_job_hits-zroc_enddate = LS_5125-APPLICATION_END."current_basic_info-application_end.
* Begin inseert BDL100310 Add additional fields to hitlist
call function 'Z_GET_IT5126_DATA'
destination lv_dest
EXPORTING
CAND_HROBJECT = ls_hrobject
IMPORTING
LS_5126 = LS_5126.
call function 'Z_GET_EREC_TEXTS'
destination lv_dest
EXPORTING
TGROUP = LS_5125-tgroup
BRANCH = LS_5126-branch
IMPORTING
TGROUP_TXT = ls_job_hits-zint_group
NAME_ORG1 = ls_job_hits-zbranch.
* ls_job_hits-zint_group = 'test1'.
* End inseert BDL100310
lo_el_job_hits->set_static_attributes( exporting static_attributes = ls_job_hits ).
** Begin insert JM130214 Sort on int group/end date cols
ls_job-zroc_enddate = ls_job_hits-zroc_enddate.
ls_job-zint_group = ls_job_hits-zint_group.
ls_job-element = lo_el_job_hits.
APPEND ls_job TO lt_job.
CLEAR ls_job.
** End insert JM130214
endif.
endloop.
" TXS081017+ End.
** Begin insert JM130214 Sort on int group/end date cols
sort lt_job by zint_group ascending.
CLEAR lt_elements.
LOOP AT lt_job INTO ls_job.
APPEND ls_job-element TO lt_elements.
ENDLOOP.
CALL METHOD lo_nd_job_hits->clear_selection.
CALL METHOD lo_nd_job_hits->bind_table
EXPORTING
NEW_ITEMS = lt_elements.
** End insert JM130214
endmethod.
Hi Jon,
Please change your code as below
method _PST_0QELSXBBVGDTX82TEPJOF5TKY . "Exit of HANDLEIN_RESULTS_UNREG (in Z_HRRCF_C_SEARCH_UI_ENH_01 )
DATA lo_nd_hrrcf_job_hitlist TYPE REF TO if_wd_context_node.
DATA lo_nd_job_hits TYPE REF TO if_wd_context_node.
data lt_elements type WDR_CONTEXT_ELEMENT_SET.
DATA lo_el_job_hits TYPE REF TO if_wd_context_element.
DATA ls_job_hits TYPE wd_this->element_job_hits.
data LS_5125 type hrp5125.
data LS_5126 type hrp5126.
data lt_hrp1001 TYPE hrp1001.
lo_nd_hrrcf_job_hitlist = wd_context->get_child_node( name =
wd_this->wdctx_hrrcf_job_hitlist ).
lo_nd_job_hits = lo_nd_hrrcf_job_hitlist->get_child_node( name =
wd_this->wdctx_job_hits ).
IF lo_nd_job_hits IS INITIAL.
exit.
ENDIF.
lt_elements = lo_nd_job_hits->get_elements( ).
if lt_elements is initial.
exit.
endif.
data: lv_enddate type datum.
data: ls_hrobject type hrobject,
lo_sobid type sobid.
data: lt_1001 TYPE STANDARD TABLE OF p1001,
ref_requi_bl TYPE REF TO cl_hrrcf_requi_bl,
current_basic_info TYPE rcf_s_requisition_info_text,
t_position_hrobject TYPE rcf_t_hrobject,
lo_exception TYPE REF TO cx_hrrcf.
FIELD-SYMBOLS: <ls_1001> TYPE hrp1001. "p1001.
loop at lt_elements into lo_el_job_hits.
lo_el_job_hits->get_static_attributes( importing static_attributes
= ls_job_hits ).
refresh: t_position_hrobject, LT_1001.
clear ls_hrobject.
ls_hrobject = ls_job_hits-hrobject.
APPEND ls_hrobject TO t_position_hrobject.
DATA: lv_dest TYPE rfcdest.
CALL METHOD cl_hrrcf_wd_services=>get_bl_destination
RECEIVING
rfc_dest = lv_dest.
CALL FUNCTION 'Z_GET_HRP1001'
destination lv_dest
EXPORTING
OTYPE = ls_hrobject-otype "'NC'
OBJID = ls_hrobject-OBJID
PLVAR = '01'
rsign = 'A'
relat = '652'
sclas = 'NB'
istat = '1'
IMPORTING
LS_HRP1001 = lt_hrp1001.
IF lt_hrp1001 IS NOT INITIAL.
assign lt_hrp1001 to <ls_1001>.
clear LS_5125.
ls_hrobject-PLVAR = '01'.
ls_hrobject-OTYPE = 'NB'.
ls_hrobject-OBJID = <ls_1001>-sOBID.
call function 'Z_GET_IT5125_DATA'
destination lv_dest
EXPORTING
CAND_HROBJECT = ls_hrobject
IMPORTING
LS_5125 = LS_5125.
ls_job_hits-zroc_enddate =
LS_5125-APPLICATION_END."current_basic_info-application_end.
* Begin inseert BDL100310 Add additional fields to hitlist
call function 'Z_GET_IT5126_DATA'
destination lv_dest
EXPORTING
CAND_HROBJECT = ls_hrobject
IMPORTING
LS_5126 = LS_5126.
call function 'Z_GET_EREC_TEXTS'
destination lv_dest
EXPORTING
TGROUP = LS_5125-tgroup
BRANCH = LS_5126-branch
IMPORTING
TGROUP_TXT = ls_job_hits-zint_group
NAME_ORG1 = ls_job_hits-zbranch.
* ls_job_hits-zint_group = 'test1'.
* End inseert BDL100310
lo_el_job_hits->set_static_attributes( exporting
static_attributes = ls_job_hits ).
endif.
endloop.
" TXS081017+ End.
** Begin insert JM130214 Sort on int group/end date cols
data lt_job_hits like TABLE OF ls_job_hits.
CLEAR lt_job_hits.
lo_nd_job_hits->get_static_attributes_table(
IMPORTING
table = lt_job_hits
).
sort lt_job_hits by zint_group ASCENDING.
lo_nd_job_hits->bind_table(
EXPORTING
new_items = lt_job_hits
).
** End insert JM130214
endmethod.
hope you will not change the existing code.
Please find the additional changes to be done from your end. ( green color )
Hope this helps you.
Regards,
Rama
Hi,
If your are on Netweaver 7.3 you can use table.multiColumnSorting to apply sorting on multiple columns. Check this help: Sorting in Tables - Web Dynpro ABAP - SAP Library
Or, after fetching the data you can apply sort on the internal table and then bind the internal table to the context.
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.