Speaking SAP

This program user controls programming in SAP to achieve text to speech.

This program user controls programming in SAP to achieve text to speech. It uses microsofts' directss control which comes with Windows.
The code was written on 4.6C and should work on 4.5B as well.


******
*****
***
To check whether this program will work in your system, do the following.

Go to 
Start->programs->accessories->accessibility and if accessibility has NARRATOR  submenu this program will work.

Regards
Raja
***
****
*****


REPORT yspeak .

*---------------------------------------------------------------------*
*       CLASS cl_crystal_viewer  DEFINITIO
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS cl_speaker DEFINITION
      INHERITING FROM cl_gui_control .

  PUBLIC SECTION .

    METHODS:
    constructor
    IMPORTING
    !parent TYPE REF TO cl_gui_container
    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 .


DATA: speaker TYPE REF TO cl_speaker ,
my_container TYPE REF TO cl_gui_custom_container,
wf_t(120) .




********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}' .
*      ctrl_name = 'UCl.UCl1' .
    ELSE .
      RAISE cntl_error .
    ENDIF .

    CALL METHOD super->constructor
    EXPORTING
    clsid = wf_clsid
    shellstyle = shellstyle
    lifetime = life_time
    name = name
    parent = parent
    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 .


  METHOD speak .
    CALL METHOD me->call_method
    EXPORTING
    method = 'Speak'
    p1 = wf_string
    p_count = 1 .
  ENDMETHOD .

ENDCLASS .



START-OF-SELECTION .

  CALL SCREEN 9100 .
*&---------------------------------------------------------------------*
*&      Module  STATUS_9100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_9100 OUTPUT.
  SET PF-STATUS 'STATUS'.


  IF my_container IS INITIAL.
    CREATE OBJECT my_container
        EXPORTING
            container_name = 'OUTPUT_CONTAINER'
        EXCEPTIONS
            others = 1.
    CASE sy-subrc.
      WHEN 0.
      WHEN OTHERS.
        RAISE cntl_error.
    ENDCASE.
  ENDIF .

  IF speaker IS INITIAL.


    CREATE OBJECT speaker
         EXPORTING
              parent    = my_container .

    IF sy-subrc NE 0.
      RAISE cntl_error.
    ENDIF.
  ENDIF .

ENDMODULE.                 " STATUS_9100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9100 INPUT.
  CASE sy-ucomm .

    WHEN 'EXIT' .

      IF NOT speaker IS INITIAL .
        CALL METHOD speaker->free.
        FREE speaker .
      ENDIF .
      IF NOT my_container IS INITIAL .
        CALL METHOD my_container->free.
        FREE my_container .
      ENDIF .

      LEAVE PROGRAM .

    WHEN 'SPK' .

      CALL METHOD speaker->speak
      EXPORTING wf_string = wf_t .

    WHEN OTHERS.

  ENDCASE .

ENDMODULE.                 " USER_COMMAND_9100  INPUT

This was first published in January 2003

Dig deeper on SAP trends, strategy and ERP market share

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close