Simple code implements sound playback in ABAP

Source: Internet
Author: User
Tags sap gui

The function of this Code is to enable sound playback in SAP, which can be used as a program reminder function. It is similar to the 'audio audio audience' in SAP. In the future, if you want sap ABAP to make a sound, you can refer to this program.

Report zplay.
Data: Command type string.

* Local command statement
Concatenate 'vbscript: Execute ("document. Write" "<bgsound src ='
"'File: //" + Replace ("C: \ lg \ bad romance="," \ ","/") + "'"
'Loop = '"'1'"'> ": window. setTimeout" window. Close () ", 300000") 'into command.

* You can check whether the played audio file exists.

Call method cl_gui_frontend_services => file_exist

......

* Playing Sound

 1 CALL METHOD cl_gui_frontend_services=>execute 2   EXPORTING 3 *   document               = 4     application            = ‘mshta‘ 5     parameter              = command 6 *   minimized              = ’X’ 7   EXCEPTIONS 8     cntl_error             = 1 9     error_no_gui           = 210     bad_parameter          = 311     file_not_found         = 412     path_not_found         = 513     file_extension_unknown = 614     error_execute_failed   = 715     synchronous_failed     = 816     not_supported_by_gui   = 917     OTHERS                 = 10.18 IF sy-subrc <> 0.19   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno20   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.21 ENDIF.

 

The code is so simple that nothing else is needed. The blue font can be modified.

Notes:

1. the audio file to be played must exist on the client's computer. Generally, the default files under the Windows system installation disk are relatively reliable. The system sounds under c: \ windows \ media, select one of the most convenient options. Of course, it can also be made into configurable variables, and users can choose their own voices.

2. Loop = '1' indicates playing once, loop = '-1' indicates loop playing, and loop = 'n' indicates playing n times.

3. Window. setTimeout "window. Close ()", 300000 "is used to close the MSHTA process, and 300000 is used to automatically close the process after 300 seconds, which is measured in milliseconds. You can adjust the time according to the sound time.

4. This program will not display any local dialog box or the player interface.
5. If the 'sap GUI security' dialog box appears, you can select Security> security settings in the sap gui Options settings to set the default action to allowed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.