Skip to Content

After reading


Craig Cmehil
‘s weblog on 
BSP / HowTo: Make your pages Talk , I thought of sharing this small test program which i
have done sometime back doing the same stuff in SAPGUI.

For this program to work you will need to

download the Microsoft text-to-speech control
if you do not have it already.

This program uses ABAP Control Frame Work. There is a nice weblog on ABAP
Control Frame Work by

Thomas Jung

</b>can be found

Using .Net Windows Controls in the ABAP Control Framework .

—-


  • CLASS cl_speaker DEFINITION<br>

—-


CLASS cl_speaker DEFINITION

INHERITING FROM cl_gui_control .

PUBLIC SECTION .

METHODS:

constructor

IMPORTING

value(shellstyle) TYPE i OPTIONAL

value(disp_mode) TYPE i OPTIONAL

value(life_time) TYPE i OPTIONAL

value(name) TYPE string OPTIONAL

EXCEPTIONS

cntl_error

cntl_install_error .

METHODS:

speak

IMPORTING

wf_string TYPE any OPTIONAL .

ENDCLASS . “cl_speaker DEFINITIO

DATA: speaker TYPE REF TO cl_speaker .

********implementation

CLASS cl_speaker IMPLEMENTATION .

METHOD constructor.

DATA: ctrl_name(80) TYPE c ,

wf_clsid(100) TYPE c .

IF NOT cl_gui_object=>activex IS INITIAL .

wf_clsid = ‘{EEE78591-FE22-11D0-8BEF-0060081841DE}’ .

ELSE .

RAISE cntl_error .

ENDIF .

CALL METHOD super->constructor

EXPORTING

clsid = wf_clsid

shellstyle = shellstyle

lifetime = life_time

name = name

EXCEPTIONS

cntl_system_error = 1

OTHERS = 2 .

CASE sy-subrc .

WHEN 1 .

RAISE cntl_install_error .

WHEN 2 .

RAISE cntl_error .

ENDCASE .

CALL METHOD cl_gui_cfw=>subscribe

EXPORTING

ref = me

shellid = me->h_control-shellid

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0 .

RAISE cntl_error .

ENDIF .

ENDMETHOD . “constructor

METHOD speak .

CALL METHOD me->call_method

EXPORTING

method = ‘Speak’

p1 = wf_string

p_count = 1.

ENDMETHOD . “speak

ENDCLASS . “cl_speaker IMPLEMENTATION

INITIALIZATION .

CONCATENATE ICON_VOICE_OUTPUT ‘Speak’ INTO sscrfields-functxt_01 .

AT SELECTION-SCREEN OUTPUT .

IF speaker IS INITIAL.

CREATE OBJECT speaker .

ENDIF.

AT SELECTION-SCREEN .

IF sscrfields-ucomm EQ ‘FC01’ .

IF wf_t IS INITIAL .

MOVE: ‘Enter something to say in selection screen field’ TO wf_t .

ENDIF .

CALL METHOD speaker->speak

EXPORTING

wf_string = wf_t.

ENDIF .

START-OF-SELECTION .

To report this post you need to login first.

12 Comments

You must be Logged on to comment or reply to a post.

  1. Hans-Joachim Schmidt
    Many thanks.. this routine is great and I built it in
    my report and it works fine in my MiniWAS.
    When I fill in a German text the result is a little bit strange but the best result is to use an English text.
    🙂
    (0) 
  2. Santhoshkumar Patil
    Hi,

    Its toooo good.
    I want to know how we can get the class id from the registry.
    is this the class id :
    wf_clsid = ‘{EEE78591-FE22-11D0-8BEF-0060081841DE}’

    Thanks
    Santhosh

    (0) 
  3. Florian Pichler
    Hello Raja,

    first of all thanks for sharing your code. Unfortunately I can’t get it to work although I installed Microsoft’s text-to-speech control successfully and the class ID {EEE78591-FE22-11D0-8BEF-0060081841DE} in the registry seems to be fine. It just doesn’t speak the text.

    Do you have any idea what could be wrong or what else need to be done? Thanks a lot for your help!

    (0) 
  4. Nishant Nayyar
    Hi,

         I copy-pasted the exact same code, but I am encountering a Short Dump. The Constructor is being called successfully, but during “AT SELECTION-SCREEN”, I receive a Short Dump.

         What might be the reason for the same. My OS is Win XP Professional, do I need to install some other component before I use the ActiveX component. Or is there some other issue ?

    Regards,
    Nishant Nayyar.

    (0) 

Leave a Reply