Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ABAP table sorted on browser load

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

Tags:
Former Member
replied

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

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question