Quantcast
Channel: Web Dynpro ABAP
Viewing all articles
Browse latest Browse all 141

Calling Transaction in SAP GUI

$
0
0

Calling SAP Transaction from WDA is a common requirement. There is a way to call SAP transaction in Web GUI. This is not an option in some cases.


Imagine a client that is using SAP GUI to run both SAP Transactions and WDAs. Such client wants to keep user interface consistent e.g. whenever WDA calls SAP transaction it needs to be run in SAP GUI (no jumps between SAP GUI and Web GUI).


There is an OOTB solution. Simply put, WDA needs to create SAP Shortcut and download it when user clicks on a link.

 

Below are screenshots of demo WDA that runs in SAP GUI and shows a list of SAP Flight model tables. Clicking on a table name from the list will call SE16 transaction in SAP GUI.

 

1. Call Z_WD_2_ABAP Transaction

Call Z_WD_2_ABAP Transaction.jpg

 

2. Click on a link

Click on a link.jpg

 

3. Confirm download

Confirm SAP Shortcut download.jpg

 

4. Voilà

Voilà.jpg

 

Below are step by step instructions how to create this demo WDA:

 

1. Create Z_WD_2_ABAP Component

Create Z_WD_2_ABAP Component.jpg

 

2. Create SFLIGHT context node in MAIN view. Set the context node cardinality to 0..1. Add two attributes: TABLENAME of type TABNAME and DESCRIPTION of type DDTEXT

Create SFLIGHT Context Node.jpg

 

3. Create VIEWCONTAINER ViewContainerUIElement on MAIN view

Create VIEWCONTAINER ViewContainerUIElement.jpg

 

4. Add ALV use of SALV_WD_TABLE Component to Z_WD_2_ABAP Component

Add ALV Component Use of SALV_WD_TABLE Component.jpg

 

5. Add ALV use of SAV_WD_TABLE Component to MAIN View

Add ALV Use of SALV_WD_TABLE to MAIN View.jpg

 

6. Embed TABLE view of SALV_WD_TABLE used component into VIEWCONTAINER element

Embed TABLE View of SALV_WD_TABLE Component into  VIEWCONTAINER Element.jpg

 

7. Implement WDDOINIT method of MAIN view

Note: code below populates ALV table with a list of SAP FLIGHT model tables

 

METHOD wddoinit.
DATA: wd_sflightTYPE wd_this->elements_sflight.
DATA: node_sflightTYPE REF TO if_wd_context_node.
DATA: wa_columnTYPE salv_wd_s_column_ref,
      wt_column
TYPE salv_wd_t_column_ref.
DATA: component      TYPE REF TO if_wd_component_usage,
      interface     
TYPE REF TO iwci_salv_wd_table,
      config         
TYPE REF TO cl_salv_wd_config_table,
      table_settings 
TYPE REF TO if_salv_wd_table_settings,
      std_functions 
TYPE REF TO if_salv_wd_std_functions,
      column_settings
TYPE REF TO if_salv_wd_column_settings,
      column         
TYPE REF TO cl_salv_wd_column,
      column_header 
TYPE REF TO cl_salv_wd_column_header,
      action         
TYPE REF TO cl_salv_wd_uie_link_to_action.

 
SELECT l~tabnameAS tablenamet~ddtextAS description
 
INTO CORRESPONDINGFIELDS OF TABLE wd_sflight
 
FROM ( dd02l AS l INNERJOIN dd02t AS t
                           
ON l~tabname= t~tabname)
                   
INNERJOIN tadirAS d
                           
ON l~tabname= d~obj_name
 
WHERE t~ddlanguage= 'E'
   
AND d~object    = 'TABL'
   
AND d~devclass  = 'SAPBC_DATAMODEL'.
  node_sflight
= wd_context->get_child_node( wd_this->wdctx_sflight).
  node_sflight
->bind_table( new_items= wd_sflight).

  component
wd_this->wd_cpuse_alv( ).
 
IF component->has_active_component( ) IS INITIAL.
    component
->create_component( ).
 
ENDIF.

  interface
= wd_this->wd_cpifc_alv( ).
  interface
->set_data( node_sflight).
  config
= interface->get_model( ).

  table_settings ?= config.
  table_settings
->set_selection_mode(cl_wd_table=>e_selection_mode-none ).
  table_settings
->set_visible_row_count(20 ).

  std_functions ?= config.
  std_functions
->set_view_list_allowed(abap_false).
  std_functions
->set_filter_filterline_allowed(abap_false).
  std_functions
->set_dialog_settings_allowed(abap_false).
  std_functions
->set_pdf_allowed(abap_false).
  std_functions
->set_export_allowed(abap_false).

  column_settings ?= config.
  wt_column
= column_settings->get_columns( ).
 
LOOP AT wt_columnINTO wa_column.
    column
= wa_column-r_column.
   
CASE wa_column-id.
   
WHEN 'TABLENAME'.
     
CREATE OBJECT action.
      action
->set_tooltip_fieldname( wa_column-id).
      action
->set_text_fieldname( wa_column-id).
      action
->set_type( cl_wd_link_to_action=>e_type-navigation ).
      column
->set_cell_editor( action ).
   
WHEN 'DESCRIPTION'.
      column_header
= column->get_header( ).
      column_header
->set_text('Description' ).
      column_header
->set_tooltip('Description' ).
      column_header
->set_ddic_binding_field(
        if_salv_wd_c_column_settings
=>ddic_bind_none).
   
ENDCASE.
 
ENDLOOP.

ENDMETHOD.


8. Create ON_CLICK event handler method for ON_CLICK Event of ALV usage

Create ON_CLICK Event Handler Method for ON_CLICK Event of ALV Usage.jpg

 

9.  Implement ON_CLICK event handler method

Program logic:

- Get clicked table name;

- Set trx. SE16 Table Name field to clicked table name;

- Create SE16 SAP Shortcut skipping first screen. See Note 103019 - SAPshortcut: Program parameters for more information.

- Download SAP Shortcut

 

METHOD on_click.
DATA: w_filenameTYPE string.
DATA: w_parameterTYPE text255.
DATA: w_shortcutTYPE xstring.
DATA: wt_shortcutTYPE soli_tab.
FIELD-SYMBOLS: <tablename> TYPE tabname.

* Get clicked table name
  ASSIGN r_param->value->* TO <tablename>.

* Set trx. SE16 Table Name field to clicked table name
  CONCATENATE 'DATABROWSE-TABLENAME=' <tablename> INTO w_parameter.
* Create SE16 SAP Shortcut skipping first screen
  CALL FUNCTION 'SWN_CREATE_SHORTCUT'
     
EXPORTING
            i_transaction  =
'*SE16'
            i_parameter   
= w_parameter
     
IMPORTING
            shortcut_table
= wt_shortcut.
  w_shortcut
= cl_bcs_convert=>raw_to_xstring(it_soli= wt_shortcut).
  CONCATENATE 'Table_' <tablename> '.sap' INTO w_filename.

 

* Dowload SAP Shortcut
  cl_wd_runtime_services
=>attach_file_to_response(
    i_filename     
= w_filename
    i_content       
= w_shortcut
    i_mime_type     
= 'sap' ).

ENDMETHOD.

 


10. Create Z_WD_2_ABAP Application

Create Z_WD_2_ABAP Application.jpg

 

11. Create Z_WD_2_ABAP parameter transaction

Create Z_WD_2_ABAP Transaction with parameters.jpg


Viewing all articles
Browse latest Browse all 141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>