Skip to Content
author's profile photo Former Member
Former Member

starting application on user machine

HI,

I have transferred a .xls file from server to loacl user machine. How do i start excel automatically to display this file thro my abap report. Is there any function module available?

Bye

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 08:50 AM

    Hi

    CALL FUNCTION 'CALL_BROWSER'
           EXPORTING
                URL                    = <path>
           EXCEPTIONS
                FRONTEND_NOT_SUPPORTED = 1
                FRONTEND_ERROR         = 2
                PROG_NOT_FOUND         = 3
                NO_BATCH               = 4
                UNSPECIFIED_ERROR      = 5
                OTHERS                 = 6.
    
      IF SY-SUBRC <> 0.
        MESSAGE S208(00) WITH 'File not found'.
      ENDIF.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 08:43 AM

    Hi,

    Pls check this FM

    MS_EXCEL_OLE_STANDARD_OLE, will build a file, and automatically start Excel - Not in ECC 6.0

    In ECC 6.0 - MS_EXCEL_OLE_STANDARD_DAT - OLE - PC Interface

    Regards

    Guru

    Edited by: Guru Prasad on Oct 22, 2008 10:47 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 08:51 AM

    Use CL_GUI_FRONTEND_SERVICES=>EXECUTE...

    Data: full_path TYPE string VALUE 'c:\Documents and Settings\2q\Desktop\abcd.xls'
    
        CALL METHOD cl_gui_frontend_services=>execute
          EXPORTING
            document               = full_path
          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.
    

    Edited by: Sukriti Saha on Oct 22, 2008 2:22 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 08:53 AM

    Hi

    Use this

    CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
      EXPORTING
        DOCUMENT               = 'C:\Documents and Settings\sap\Desktop\Hi.xls'
    *    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.

    or

    CALL FUNCTION 'GUI_RUN'
      EXPORTING
        COMMAND          = 'C:\Documents and Settings\sap\Desktop\Hi.xls'
    *   PARAMETER        =
    *   CD               =
    * IMPORTING
    *   RETURNCODE       =

    or

    WS_EXECUTE func module is there for the same purpose but the Short text says it is obsolete

    Edited by: Rajvansh Ravi on Oct 22, 2008 10:59 AM

    Edited by: Rajvansh Ravi on Oct 22, 2008 11:00 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 09:01 AM

    Hi Mac,

    There are 2 similar post like your post it was yesterday and today too.

    Anyways the program that i have shown copy paste and execute you can see the excel sheet will be triggered automatically and the EXCEL sheet will be saved in the Local machine where this program is executed in MY DOCUMENTS.

    REPORT ZREDDY_VBAP .

    • sending ABAP data to an

    • EXCEL sheet using OLE automation.

    include ole2incl.

    • handles for OLE objects

    data: h_excel type ole2_object, " Excel object

    h_mapl type ole2_object, " list of workbooks

    h_map type ole2_object, " workbook

    h_zl type ole2_object, " cell

    h_f type ole2_object, " font

    h_c type ole2_object. " color

    data: filename like rlgrap-filename.

    tables: vbap.

    data h type i.

    • table of vbap

    data: it_vbap like vbap occurs 10 with header line.

    &----


    *& Event START-OF-SELECTION

    &----


    start-of-selection.

    • read vbap

    select * from vbap into table it_vbap.

    • display header

    uline (61).

    write: / sy-vline no-gap,

    (6) 'ITEM'(001) color col_heading no-gap, sy-vline no-gap,

    (18) 'MATERIAL'(002) color col_heading no-gap, sy-vline

    no-gap

    ,

    (30) 'DESCRIPTION'(003) color col_heading no-gap, sy-vline

    no-gap,

    (35) 'ORDER_QUANTITY'(004) color col_heading no-gap, sy-vline

    no-gap,

    (8) 'S_UNIT'(005) color col_heading no-gap, sy-vline no-gap.

    uline /(61).

    • display vbap

    loop at it_vbap.

    write: / sy-vline no-gap,

    it_vbap-posnr color col_key no-gap, sy-vline no-gap,

    it_vbap-matwa color col_normal no-gap, sy-vline no-gap,

    it_vbap-arktx color col_normal no-gap, sy-vline no-gap,

    it_vbap-awahr color col_normal no-gap, sy-vline no-gap,

    it_vbap-vrkme color col_normal no-gap, sy-vline no-gap.

    endloop.

    uline /(61).

    • tell user what is going on

    call function 'SAPGUI_PROGRESS_INDICATOR'

    exporting

    • PERCENTAGE = 0

    text = text-007

    exceptions

    others = 1.

    • start Excel

    create object h_excel 'EXCEL.APPLICATION'.

    • PERFORM ERR_HDL.

    set property of h_excel 'Visible' = 1.

    • PERFORM ERR_HDL.

    • tell user what is going on

    call function 'SAPGUI_PROGRESS_INDICATOR'

    exporting

    • PERCENTAGE = 0

    text = text-008

    exceptions

    others = 1.

    • get list of workbooks, initially empty

    call method of h_excel 'Workbooks' = h_mapl.

    perform err_hdl.

    • add a new workbook

    call method of h_mapl 'Add' = h_map.

    perform err_hdl.

    • tell user what is going on

    call function 'SAPGUI_PROGRESS_INDICATOR'

    exporting

    • PERCENTAGE = 0

    text = text-009

    exceptions

    others = 1.

    • output column headings to active Excel sheet

    perform fill_cell using 1 1 1 200 'ITEM'(001).

    perform fill_cell using 1 2 1 200 'MATERIAL'(002).

    perform fill_cell using 1 3 1 200 'DESCRIPTION'(003).

    perform fill_cell using 1 4 1 200 'ORDER_QUANTITY'(004).

    perform fill_cell using 1 5 1 200 'S_UNIT'(005).

    loop at it_VBAP.

    • copy details to active EXCEL sheet

    h = sy-tabix + 1.

    if it_VBAP-POSNR cs '000010'.

    perform fill_cell using h 1 0 000255000 it_VBAP-POSNR.

    elseif it_VBAP-POSNR cs '000020'.

    perform fill_cell using h 1 0 168000000 it_VBAP-POSNR.

    elseif it_VBAP-POSNR cs '000030'.

    perform fill_cell using h 1 0 168168000 it_VBAP-POSNR.

    elseif it_VBAP-POSNR cs '000040'.

    perform fill_cell using h 1 0 111111111 it_VBAP-POSNR.

    elseif it_VBAP-POSNR cs 'SQ'.

    perform fill_cell using h 1 0 100100100 it_VBAP-POSNR.

    else.

    perform fill_cell using h 1 0 000145000 it_VBAP-POSNR.

    endif.

    if it_VBAP-MATWA lt 'P-*'.

    perform fill_cell using h 2 0 255000255 it_VBAP-MATWA.

    elseif it_VBAP-MATWA lt 'M-*'.

    perform fill_cell using h 2 0 770990885 it_VBAP-MATWA.

    elseif it_VBAP-MATWA lt 'L-*'.

    perform fill_cell using h 2 0 077099048 it_VBAP-MATWA.

    else.

    perform fill_cell using h 2 0 246156138 it_VBAP-MATWA.

    endif.

    if it_vbap-arktx cp 'S*'.

    perform fill_cell using h 3 0 155155155 it_vbap-arktx.

    elseif it_vbap-arktx cp 'F*'.

    perform fill_cell using h 3 0 189111222 it_vbap-arktx.

    elseif it_vbap-arktx cp 'J*'.

    perform fill_cell using h 3 0 289111222 it_vbap-arktx.

    else.

    perform fill_cell using h 3 0 111230222 it_vbap-arktx.

    endif.

    if it_vbap-awahr cp 'S*'.

    perform fill_cell using h 4 0 200200200 it_vbap-awahr.

    elseif it_vbap-awahr cp 'N*'.

    perform fill_cell using h 4 0 000111222 it_vbap-awahr.

    else.

    perform fill_cell using h 4 0 130230230 it_vbap-awahr.

    endif.

    if it_vbap-vrkme lt '020000'.

    perform fill_cell using h 5 0 145145145 it_vbap-vrkme.

    elseif it_vbap-vrkme lt '120000' .

    perform fill_cell using h 5 0 015215205 it_vbap-vrkme.

    elseif it_vbap-vrkme lt '180000' .

    perform fill_cell using h 5 0 000215205 it_vbap-vrkme.

    else.

    perform fill_cell using h 5 0 115115105 it_vbap-vrkme.

    endif.

    endloop.

    • EXCEL FILENAME

    concatenate sy-repid '_' sy-datum6(2) '_' sy-datum4(2) '_'

    sy-datum(4) '_' sy-uzeit '.XLS' into filename.

    call method of h_map 'SAVEAS' exporting #1 = filename.

    free object h_excel.

    perform err_hdl.

    -


    • FORM FILL_CELL *

    -


    • sets cell at coordinates i,j to value val boldtype bold *

    -


    form fill_cell using i j bold col val.

    call method of h_excel 'Cells' = h_zl

    exporting

    #1 = i

    #2 = j.

    perform err_hdl.

    set property of h_zl 'Value' = val .

    perform err_hdl.

    get property of h_zl 'Font' = h_f.

    perform err_hdl.

    set property of h_f 'Bold' = bold .

    perform err_hdl.

    set property of h_f 'Color' = col.

    perform err_hdl.

    endform. "FILL_CELL

    &----


    *& Form ERR_HDL

    &----


    • outputs OLE error if any *

    -


    • --> p1 text

    • <-- p2 text

    -


    form err_hdl.

    if sy-subrc <> 0.

    write: / 'OLE-Automation Error:'(010), sy-subrc.

    stop.

    endif.

    endform. " ERR_HDL

    Cheers!!

    Balu

    Edited by: Balu CH on Oct 22, 2008 2:32 PM

    Edited by: Balu CH on Oct 22, 2008 2:33 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 09:05 AM

    Thanks for such prompt replies....its highly appreciated. I'm using FM call_browser. Thanks a lot to all of you:)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.