SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Run Executable files from Web Dynpro ABAP using Acfexecute

...Previous

Source code:

METHOD WDDOMODIFYVIEW .

   DATA: root_element   TYPE REF TO if_wd_view_element,

              root_container TYPE REF TO cl_wd_transparent_container.

 

   IF first_time = 'X'.

     root_element = view->get_root_element( ).

     root_container ?= root_element.

*   init GAC control

     wd_this->m_control = cl_wd_acf_execute=>new_acf_execute( ).

     wd_this->m_control->set_enabled( abap_true ).

     wd_this->acf_method_handler ?= wd_this->m_control->_method_handler.

*   Create AcfExecute UI

     cl_wd_matrix_data=>new_matrix_data( element = wd_this->m_control ).

     root_container->add_child( wd_this->m_control ).

   ENDIF.

ENDMETHOD

Now create a method CALL_ACF_EXECUTE.

Double click and also create the parameters for the method APPLICATION and ARGUMENTLIST of type string. And write the below code

Source code:

METHOD CALL_ACF_EXECUTE .

 

   DATA: lo_el_context      TYPE REF TO if_wd_context_element,

             lo_el_context_stru TYPE wdr_ext_attribute_pointer,

             lr_acf_exp         TYPE REF TO cx_wd_acf_exception,

             lv_msg_text        TYPE string.

 

   TRY.

 

       lo_el_context = wd_context->get_lead_selection( ).

       lo_el_context_stru-attribute_name = 'ERROR'.

       lo_el_context_stru-element = lo_el_context.

       wd_this->acf_method_handler->if_wd_acfexecute~execute( application  application

                                                                                             argumentlist = argumentlist

                                                                                             errorinformation = lo_el_context_stru ).

   CATCH cx_wd_acf_exception INTO lr_acf_exp.

 

       lv_msg_text = lr_acf_exp->if_message~get_text( ).

*       get message manager

       data lo_api_controller     type ref to if_wd_controller.

       data lo_message_manager    type ref to if_wd_message_manager.

 

       lo_api_controller ?= wd_This->Wd_Get_Api( ).

 

       CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER

         RECEIVING

           MESSAGE_MANAGER = lo_message_manager.

 

*       report message

       CALL METHOD lo_message_manager->REPORT_SUCCESS

         EXPORTING

           MESSAGE_TEXT = lv_msg_text.

 

   ENDTRY.

 

ENDMETHOD.

6. Now go the on action method(ONACTIONOPEN_NOTEPAD) of the button previously created in main view

Double click the write the below code

method ONACTIONOPEN_NOTEPAD .  
DATA lv_application TYPE string.
"MS notepad application path
    lv_application = 
'C:\Windows\system32\notepad.EXE'.
*  Call Execute method
    wd_this->call_acf_execute( application = lv_application ).      
endmethod.

I have specified the location of the executable file as in my system .Use you own file location in case if it is different.

7. Right click on WebDynpro Component and click on Create WebDynpro Application.

8. Activate the program and execute the program

Output

On click on the button the notepad opens

If the file does not opens it means it is on in white list or blocked to unblock it go to tcode WDR_ACF_WLIST

Create a white list and specify the system application location

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image