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.