Monday, July 25, 2011

To Play Audio or Video Files or any Office Files in ABAP

Its time to listen musics and see video through Abap.

REPORT  ZVV_TEST.

tables : sscrfields.

SELECTION-SCREEN: BEGIN OF line .
  SELECTION-SCREEN PUSHBUTTON 10(10) word USER-COMMAND as.
SELECTION-SCREEN END OF LINE.

INITIALIZATION.

word = 'Play Audio'.

START-OF-SELECTION.

DATA : obj type ref to CL_GUI_FRONTEND_SERVICES.

CREATE OBJECT obj
*  EXCEPTIONS
*    not_supported_by_gui = 1
*    cntl_error           = 2
*    others               = 3
    .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
AT SELECTION-SCREEN.
if sscrfields-ucomm = 'AS'.
CALL METHOD cl_gui_frontend_services=>execute
  EXPORTING
    document               = 'D:\Vino\test.wma'  "" Path for Audio or Video or Office File with Extension
*    application            =
*    parameter              =
*    default_directory      =
*    maximized              =
*    minimized              =
*    synchronous            =
    operation              = 'OPEN'
*  EXCEPTIONS
*    cntl_error             = 1
*    error_no_gui           = 2
*    bad_parameter          = 3
*    file_not_found         = 4
*    path_not_found         = 5
*    file_extension_unknown = 6
*    error_execute_failed   = 7
*    synchronous_failed     = 8
*    not_supported_by_gui   = 9
*    others                 = 10
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

endif.

No comments:

Post a Comment