cancel
Showing results for 
Search instead for 
Did you mean: 

Collective Search help for org unit: hierarchy search & search by name

former_member213217
Participant
0 Kudos

Hi Experts,

In the selection screen of my object I need to provide the users with a field Organizational Unit which should have an search help associated with it that would enable the users to perform a hierarchy search and search by org name. I tried searching but though there are similar R/3 search helps they cannot be used from within WDA. I came across an article by Tamil Selvan detailing on how to create such a search help but the image attachments are somehow missing from the article. Did anyone ever have to design such a search help or would have any idea about a standard search help which I can re-use for hierarchy search? And how can I create a collective search help from within WDA? (i.e., providing both a hierarchy search and search by org name)

Regards,

Uday

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor
0 Kudos

Hi Uday,

I had the same requirement and chose to create a Freely Programmed search help modeled after SAPgui search help, HRBAS00OBJID2. For examples of Freely Programmed search helps, see WDA components DEMO_VALUE_HELP (context attribute SFLIGHT-CONNID) and FREE_VALUE_HELP. Since you have full control over the Freely Programmed search help, you can choose to have it return whatever data you need, whether it is one Org Unit, multiple Org Units, a structure, etc.

The usage:

The Freely Programmed search help is a separate web dynpro component:

method supply_structure .

  data lt_structure type wd_this->elements_structure.
  data ls_structure like line of lt_structure.
  data lt_objec type standard table of objec.
  data lt_struc type standard table of struc.
  data lv_date_string type char10.

  field-symbols:  <o> type objec,
                 <s> type struc.

* Read the organizational structure
  call function 'RH_STRUC_GET'
    exporting
      act_otype      = 'O'        " Organizational unit
      act_objid      = '12345678' " Top level organization
      act_wegid      = 'ORGEH'    " Organizational structure
    tables
      result_objec   = lt_objec
      result_struc   = lt_struc
    exceptions
      no_plvar_found = 1
      no_entry_found = 2
      others         = 3.

* Map organizational structure data to the context table
  loop at lt_struc assigning <s>.

    read table lt_objec assigning <o>                        with key realo = <s>-objid.
    check sy-subrc is initial.

    ls_structure-seqnr = <s>-seqnr.
    ls_structure-pup   = <s>-pup.
    ls_structure-plvar = <o>-plvar.
    ls_structure-otype = <o>-otype.
    ls_structure-objid = <o>-objid.
    ls_structure-begda = <o>-begda.
    ls_structure-endda = <o>-endda.
    ls_structure-istat = <o>-istat.
    ls_structure-histo = <o>-histo.
    ls_structure-short = <o>-short.
    ls_structure-stext = <o>-stext.
    ls_structure-realo = <o>-realo.

    concatenate <o>-otype <o>-objid
                into ls_structure-objid_extended separated by space.

*   Does the org unit have children?
    if <s>-pdown is initial.
      ls_structure-is_leaf = abap_true.
    endif.

*   We attempt to mimic search help HRBAS00OBJID2 as closely as possible
    if <o>-endda = '99991231'.
      ls_structure-endda_text = 'Unlimited'.
    else.
      write <o>-endda to lv_date_string mm/dd/yyyy.
      ls_structure-endda_text = lv_date_string.
    endif.

    append ls_structure to lt_structure.
    clear: ls_structure.

  endloop.

* Set the table in the context
  node->bind_table(
    new_items            = lt_structure
    set_initial_elements = abap_true ).

endmethod.

Cheers,

Amy

former_member213217
Participant
0 Kudos

Hi Amy,

Thank you very much for your patient posting. Your inputs were very useful. Love this new feature of SCN where we can even share the UI snapshots.

Could you please clarify as to which context attributes you are binding the below properties of the TreeByKeyTableColumn:

expanded

isLeaf

parentKey

rowKey

Also which attributes are the ID, CODE, VALID_FROM & VALID_TO columns of the table referring to.

Regards,

Uday

amy_king
Active Contributor
0 Kudos

Hi Uday,

Properties of the TreeByKeyTableColumn are bound as follows.

  • expanded is bound to wdy_boolean attribute STRUCTURE.IS_EXPANDED.
  • isLeaf is bound to wdy_boolean attribute STRUCTURE.IS_LEAF.
  • parentKey is bound to STRUCTURE.PUP (see DDIC structure STRUC).
  • rowKey is bound to STRUCTURE.SEQNR (see DDIC structure STRUC).

Columns of the Table are bound as follows.

  • ID is bound to STRUCTURE.OBJID_EXTENDED which is just OBJID and STEXT concatenated together. It's whatever you would like to display for Org Unit short text.
  • CODE is bound to STRUCTURE.SHORT
  • VALID_FROM is bound to STRUCTURE.BEGDA
  • VALID_TO is bound to STRUCTURE.ENDDA_TEXT which is a string version of ENDDA since I sometimes show the end date as "Unlimited"

Cheers,

Amy

former_member213217
Participant
0 Kudos

Hi Amy,

Thank you very much. Your code works like a charm. Its a shame though that I got to learn about working with TreeByKeyTableColumn the lazy way!

Regards,

Uday

amy_king
Active Contributor
0 Kudos

Glad to be of help Uday, and thanks for the points!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Uday,

I also got same requirement few weeks back.... I solved this issue. To do above requirement pls fallow below steps.

->Create Tree structure in webdynpro abap using tree element in one component.

-> Create Another component and create input field and make search help by using freelyprogrammed search help...

If u have any doubs  post here....

Regards,

Krishna

former_member213217
Participant
0 Kudos

Hi Krishna,

Thank you for the reply. Am new to WDA and haven't worked with Tree UI element. I shall try look around through an article and try create one as how you advised.

And would I be able to select multiple org unit values from within the Tree to return back to the field?

Regards,

Uday

Former Member
0 Kudos

Hi Uday

Then U have to create tree with children as checkboxes(With ID's)...  Like that u can do...

Regards,

Venkat