Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

   PO Display Transaction Code from WebDynpro Aplication

      By Ashwini Shirke ,  Pune.

  1 : Open transaction SE80 and from the drop down list select WebDynpro Component.

  2 : Enter the application name (Here Zcall Transaction ).

  3 : You will get a pop up as shown above. Click YES.

4 : A Web Dynpro component will then be created. A COMPONENT CONTROLLER, WINDOW and INTERFACE COMPONENTS will be created automatically.

  5 : Double click on the Component controller. You will see an empty context.

      Right click on the CONTEXT and click on create > node.

6 : Enter the details on the pop up as shown below. (Create NODE)

7 : Inside the Node , Create one Attribute by Right Clicking that Node and Select Create a Attribute.

  8 : Give the Attribute Name as EBELN, with Type EKPO-EBELN. Then Press Enter.

  9 : In the Layout Tab of the View, Right click the ROOTUIELEMENTCONTAINER and give Insert Element. It will open a Pop-Up for Creating an Element.

10 : Enter GROUP in the Name Field and Select GROUP in the Type Field and Press Enter.

11: Insert a new UI elements of type GROUP,CAPTION,RADIOBUTTONGROUPBYINDEX and Textview under ROOTUIELEMENTCONTAINER .

 

12 : Create Context Binding For the RADIOBUTTON by Clicking the Button in the Right Side Of the Texts in the Properties. It will open a Popup with the Context Element . In that Select the Attribute EBELN.

13 : Then create one Action for onSelect Event of the Dropdown by Clicking the Create Button as shown below. Then Give the Action Name as FIND_DATA and press Enter.

14 : Create another Element by Right clicking the ROOTUIELEMENTCONTAINER and give Insert Element. It will open a Pop-Up for Creating an Element.

  15 : Enter ‘OPEN_PO’ in the Name Field and Select ‘Button’ from the ID for the Type Field and Press Enter.

16 : Create an Action In properties Events under OnSelect click on New Button and Enter name of the Action “ON_OPEN”.

17 : Now save everything and right click on the Component (ZCALL_TRANSACTION).

Click the link Create > Application. Enter the following details.

18 : Now this is the most important step of all. CODING J

For coding, go to the Input View and click on METHODS, which is the last tab.

  Method WDDOINIT .

  data v_element type ref to if_wd_context_element.

  data : items_node type ref to if_wd_context_node,

            v_index type i,

            v_text type string.

  data : itemlist type wd_this->elements_node."rdgroup.

  data : w_list type wd_this->element_node."rdgroup.

select DISTINCT ebeln from ekpo into table itemlist

   where ebeln like '**********' AND bukrs = '***' and meins = 'EA' and matkl = '001' .

            items_node = wd_context->get_child_node( name = `NODE` ).

           items_node->bind_table( itemlist ).

           items_node->set_lead_selection_index( 3 ).

            v_index = items_node->get_lead_selection_index( ).

            clear w_list.

             read table itemlist into w_list index v_index.

             v_text = w_list-ebeln.

   Endmethod.

There you will find a method ONACTIONACTION_DATA already created. This is the event handler method of the action FIND.

Method ONACTIONFIND_DATA .

data : v_element type ref to if_wd_context_element,

       items_node type ref to if_wd_context_node,

        v_index type i,

        v_text type string.

data : itemlist type wd_this->elements_node.

data : w_list type wd_this->element_node.

  items_node = wd_context->get_child_node( name = `NODE` ).

items_node->get_static_attributes_table( importing table = itemlist ).

v_index = items_node->get_lead_selection_index( ).

  clear w_list.

  read table itemlist into w_list index v_index.

  v_text = w_list-ebeln.

Endmethod.

There is the event handler method of the action ONACTION_OPEN.

  Method ONACTIONON_OPEN .

  data : v_text type string, url type string,host type string ,port type string.

data lo_nd_rdgroup type ref to if_wd_context_node.

data lo_el_rdgroup type ref to if_wd_context_element.

  data ls_rdgroup type wd_this->element_node.

  data lv_ebeln type wd_this->element_node-ebeln.

  data lo_window_manager type ref to if_wd_window_manager.

  data lo_api_component type ref to if_wd_component.

data lo_window type ref to if_wd_window.

cl_http_server=>if_http_server~get_location(

         importing host = host

          port = port ).

  lo_nd_rdgroup = wd_context->get_child_node( name = wd_this->wdctx_node ).

* get element via lead selection

  lo_el_rdgroup = lo_nd_rdgroup->get_element( ).

  if lo_el_rdgroup is initial.

endif.

* get single attribute

lo_el_rdgroup->get_attribute(

   exporting

      name =  `EBELN`

   importing

    value = lv_ebeln ).

  concatenate 'http'

'://' host ':' port

            '/sap/bc/gui/sap/its/webgui?~transaction=ME23N&%20EKKO-EBELN=' lv_ebeln

           into url.

lo_api_component = wd_comp_controller->wd_get_api( ).

lo_window_manager = lo_api_component->get_window_manager( ).

* call the url which we created above

lo_window_manager->create_external_window(

   exporting

            url = url

   receiving

           window = lo_window ).

lo_window->open( ).

Endmethod.

19 : SAVE the application and activate the Component.

20 : Now run the application. Here’s the output

Regards,

Ashwini

3 Comments