Display orgaisation selection BSP

This is the orgtest.htm page of the example SAP HR org structure BSP, this is being used to demonstrate the use of javascript retrieve the SAP HR org structure and display it to the SAP bsp user. Please note this page will do very little on it own and needs to be implemented as part of the whole SAP HR org structure BSP

*orgtest.htm

Type Definitions
----------------
types: tt_hrp1001 type standard table of hrp1001 initial size 0.
TYPES: BEGIN OF t_orgdisplay,
  level(40) TYPE c,
  id        type i,
  parent    type i,
  objid TYPE hrp1001-objid,
  orgtx     type string,
  begda TYPE hrp1001-begda,
  endda TYPE hrp1001-endda,
  display type string,
  checked type string,
 END OF t_orgdisplay.
TYPES: tt_orgdisplay TYPE STANDARD TABLE OF t_orgdisplay.
TYPES: tt_RSPARAMS TYPE STANDARD TABLE OF RSPARAMS.
Page Attributes
---------------
gd_count	TYPE	SY-INDEX
gd_id	TYPE	STRING
gd_str	TYPE	STRING
gd_update	TYPE	I
it_hrp1001	TYPE	TT_HRP1001
it_orgdisplay	TYPE	TT_ORGDISPLAY
it_selection	TYPE	tt_RSPARAMS
p_windowsid	TYPE	STRING
tv_iterator	TYPE REF TO	IF_HTMLB_TABLEVIEW_ITERATOR
vIndex	TYPE	I
vSize	TYPE	STRING
wa_orgdisplay	TYPE	T_ORGDISPLAY
On Create
---------------
* this handler is called once the page is first created (stateful mode)
* it performs a once-off data initialization or object creation
    DATA: a_name          TYPE string VALUE 'NONE',
          a_name_space    TYPE string VALUE 'NONE',
          u_name          TYPE string VALUE 'NONE',
          session_id      TYPE string VALUE 'NONE'.
    cl_bsp_server_side_cookie=>get_server_cookie(
      EXPORTING
        name                  = p_windowsid
        application_name      = 'ORG_LIST'
        application_namespace = runtime->application_namespace
        username              = sy-uname
        session_id            = 'SESSION_ID'
        data_name             = 'COOKIE_ID_50CASE1'
      CHANGING
        data_value            = it_orgdisplay ).
    refresh it_orgdisplay." comment when confirmed data retrieval is working
    IF it_orgdisplay IS INITIAL.
      SUBMIT zorg_retrieve AND RETURN.
      IMPORT it_orgdisplay TO it_orgdisplay FROM MEMORY ID 'ZORGSTRUCT'.
      cl_bsp_server_side_cookie=>set_server_cookie(
        EXPORTING
          name                  = p_windowsid
          application_name      = 'ORG_LIST'
          application_namespace = runtime->application_namespace
          username              = sy-uname
          session_id            = 'SESSION_ID'
          data_value            = it_orgdisplay
          data_name             = 'COOKIE_ID_50CASE1'
          expiry_time_rel       = 3600
       ).
    ENDIF.
On Initialization
---------
* event handler for data retrieval
DATA: a_name          TYPE string VALUE 'NONE',
      a_name_space    TYPE string VALUE 'NONE',
      u_name          TYPE string VALUE 'NONE',
      session_id      TYPE string VALUE 'NONE'.
cl_bsp_server_side_cookie=>get_server_cookie(
  EXPORTING
    name                  = p_windowsid
    application_name      = 'ORG_LIST'
    application_namespace =  runtime->application_namespace
    username              = sy-uname
    session_id            = 'SESSION_ID'
    data_name             = 'COOKIE_ID_50CASE1'
*  IMPORTING
*    EXPIRY_DATE           =
*    EXPIRY_TIME           =
  CHANGING
    data_value            = it_orgdisplay ).
On InputProcessing
---------
* event handler for checking and processing user input and
* for defining navigation
    DATA: a_name          TYPE string VALUE 'NONE',
          a_name_space    TYPE string VALUE 'NONE',
          u_name          TYPE string VALUE 'NONE',
          session_id      TYPE string VALUE 'NONE'.
CLASS cl_htmlb_manager DEFINITION LOAD.
DATA: event TYPE REF TO cl_htmlb_event.
event ?= cl_htmlb_manager=>get_event( runtime->server->request ).
data: wa_next type string,
      wa_string type string,
      wa_selection like line of it_selection.
constants: con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
  IF event->id = 'orgButton' AND event->event_type = 'click'.
    DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
    data ?= CL_HTMLB_MANAGER=>GET_DATA(
                                      request = runtime->server->request
                                           name     = 'inputField'
                                           id       = 'id1'
                                        ).
    IF data IS NOT INITIAL.
      gd_id = data->value.
      wa_string = gd_id.
        DO.
          IF wa_string is initial.
            EXIT.
          ELSE.
           SPLIT wa_string AT ',' INTO wa_next
                                           wa_string.
           read table it_orgdisplay into wa_orgdisplay
                                         with key id = wa_next.
           if wa_orgdisplay-checked = 'CHECKED'.
             wa_orgdisplay-checked = 'UNCHECKED'.
           else.
             wa_orgdisplay-checked = 'CHECKED'.
           endif.
           modify it_orgdisplay from wa_orgdisplay index sy-tabix.
          ENDIF.
        ENDDO.
        if sy-subrc eq 0.
          cl_bsp_server_side_cookie=>set_server_cookie(
            EXPORTING
              name                  = p_windowsid
              application_name      = 'ORG_LIST'
              application_namespace = runtime->application_namespace
              username              = sy-uname
              session_id            = 'SESSION_ID'
              data_value            = it_orgdisplay
              data_name             = 'COOKIE_ID_50CASE1'
*             EXPIRY_TIME_ABS       =
*             EXPIRY_DATE_ABS       =
              expiry_time_rel       = 3600
*             EXPIRY_DATE_REL       =
          ).
          loop at it_orgdisplay into wa_orgdisplay where
                                            checked = 'CHECKED'.
            wa_selection-selname = 'S_DEPT'.
            wa_selection-sign    = 'I'.
            wa_selection-option  = 'EQ'.
            wa_selection-low     = wa_orgdisplay-objid.
            wa_selection-high    = wa_orgdisplay-objid.
            append wa_selection to it_selection.
          endloop.
          cl_bsp_server_side_cookie=>set_server_cookie(
            EXPORTING
              name                  = p_windowsid
              application_name      = 'SEL_SCREEN'
              application_namespace = runtime->application_namespace
              username              = sy-uname
              session_id            = 'SESSION_ID'
              data_value            = it_selection
              data_name             = 'COOKIE_ID_50CASE1'
*             EXPIRY_TIME_ABS       =
*             EXPIRY_DATE_ABS       =
              expiry_time_rel       = 3600
*             EXPIRY_DATE_REL       =
          ).
          navigation->goto_page('closewindow.htm').
        endif.
    ENDIF.
ENDIF.
Layout
------
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="classic">
  <htmlb:page title = " ">
    <htmlb:form>
<html>
<head>
  <SCRIPT TYPE="text/javascript">
<!--
window.focus();
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function close_window(mylink, windowname)
{
  javascript:window.close();
//Implementation
//<A HREF="?topic=orgtest"  onClick="return close_window(this, 'OrgUnit')"></A>
}
</script>
  <title>Organisational Structure</title>
  <link rel="StyleSheet" href="dtree.css" type="text/css" />
  <script type="text/javascript" src="dtree.js"></script>
</head>
<body>
      <htmlb:inputField id            = "id1"
                        invalid        = "true"
                        value          = "<%=gd_id%>"
                        required       = "true"
                        visible        = " "/>
          <htmlb:button id      = "orgButton"
                        text    = "Done"
                        onClick = "orgButton"/>
<div class="dtree">
  <p><a href="javascript: d.openAll();">open all</a> |
  <a href="javascript: d.closeAll();">close all</a></p>
  <script type="text/javascript">
    <!--
              var count = 1;
              var count2 = 0;
              var str = ' ';
    d = new dTree('d');
      d.add(0,-1,'My Org');
<% loop at it_orgdisplay into wa_orgdisplay.%>
     d.add(<%=wa_orgdisplay-id %>,<%=wa_orgdisplay-parent %>,
     '<%=wa_orgdisplay-objid %> | <%=wa_orgdisplay-orgtx %>',
     'orgupdate.htm?gd_id=<%=wa_orgdisplay-id %>&gd_update=2','',
     'MAIN','','','','','<%=wa_orgdisplay-checked %>');
     count++;
<% endloop. %>
   document.write(d);
    //-->
  </script>
</div>
<p>©sapdev</p>
          <htmlb:button id      = "orgButton"
                        text    = "Done"
                        onClick = "orgButton"/>
<IFRAME marginwidth="0" marginheight="0" src="top/top.htm" name="MAIN" width="1"
 height="1" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>
</body>
</html>
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

Related Articles

Javascript to capture when a user closes or leaves sap bsp html page
Using AJAX functionality within our SAP BSP
Close BSP Session (type 'Pluggin HTTP') including when in SAP portal
SAP BSP to auto select region when user selects country using HTML and Javascript
HTML and Javascript code to force enter key to perform tab
JavaScrip command getElementById useful examples
MVC BSP input field - Demonstrate how to retrieve a value entered into text input field
Allowing multiple instances of a BSP application to be run by a user
Execute Standard SAP Transaction from BSP using dynamically created shortcut
Uplaod file within SAP BSP application using HTML and ABAP coding
UUseful SAP BSP application code - ABAP, HTML, HTMLB, Javascript, CSS
Creating a BSP Application class to help store and pass data betwenn your BSP pages
Training Course and Workshop Booking Form
BSP checkboxes using HTML and the OnInputProcessing BSP Event
BSP checkboxes using HTML and the OnInputProcessing BSP Event
Check HTML checkbox is checked using Javascript within your SAP BSP
BSP Dropdown List - create a BSP dropdown list which allows user selection!!
ABAP BSP to allow user to select from SAP HR org structure - CSS file
Java script to display tree structure on your SAP BSP web page
Create a Simple BSP - Simple BSP to display text and call section BSP page using HTML
SAP BSP Training course booking - Creating an example training course booking form using BSP
Creating an SAP BSP which executes an ABAP report to retrieve data for use within BSP application
org selection BSP - detials.htm page
Display page of the SAP BSP example application to store favourite tcodes as a cookie
Execute.htm page of the SAP BSP example application to store favourite tcodes as a cookie
Favourites cookie bsp - initial page to display input fields and retrieve user input
BSP using cookies - Demonstrate use of cookies within a BSP to store user favourits
ABAP Export data to memory - Demonstrate use of ABAP program to retrieve data for use in BSP
MVC BSP HTMLB input field - Demonstrate how to retrieve a value entered into text input field
BSP development using standard HTML code instead of Business HTML (HTMLB)
Business HTML (HTMLB) - List of business HTML tags you can use within your BSP
Adding JavaScript to BSP (HTML) pages - Shows how to add javascript to your BSP pages
Example JavaScript code which can be added to your BSP application
BSP MIME Objects for Org. search application
Call onInputProcessing event from SAP BSP page via href or button
Organisation selection BSP - close internet window using javascript
Organisation selection BSP - get server side cookie ( get_server_cookie )
orgaisation selection BSP - set and get server side cookie ( set_server_cookie )
BSP which allows HR Organisation Structure search and selection using javascript
Organisation update program - get server side cookie ( get_server_cookie )
BSP to capture user entry into HTML input fields
Capture BSP radiobutton selection using HTML and the OnInputProcessing BSP Event
BSP checkboxes using HTML and the OnInputProcessing BSP Event
Stateful and stateless BSP applications
Get user entry into HTML input fields with SAP BSP
Javascript to capture when a user closes or leaves sap bsp html page
Creating a BSP using the Model View Controller ( MVC ) technique
Using SAP Model View Controller (MVC) development techniques to develop BSPs
Adding a JavaScript date selection field to a BSP
Creating a BSP using the Model View Controller ( MVC ) technique
Creating a BSP using the Model View Controller(MVC) technique
Creating a BSP using the Model View Controller ( MVC ) technique
Retrieve value from input text field within a model view controller ( MVC) BSP
Web Application Development - Example code and information on development using BSP
SAP BSP / Business Server Pages combine ABAP and other web technologies such as HTML, CSS
BSP development screen - developing application using business server pages
Standard Program created in SE38 or SE80