ABAP OLE EXCEL

Hi Expert,
I got a problem using OLE2 to passing the logo into excel file. the rest of data I have already passed in. but except the logo I can't pass it, anybody know the function module or method used to print the logo in excel using OLE2 ? Thank you
Best regards,
Kohokoho

Hi,
Check this links for inserting a picture to an excel using OLE2:
Wiki:
http://wiki.sdn.sap.com/wiki/display/Community/InsertPictureImageinExcelusingOLE+Automation
Thread:
Re: download output with logo to excel file.
Regards,
Swarna Munukoti

Similar Messages

  • Problem in running a ABAP OLE Excel program in Web Portal

    Hi,
    Do anyone know how to solve the following problem ?
    I have write a ABAP program in R/3 to use OLE to create a Excel file.
    The program can run successful in front end workstation through SAPGUI.
    However, when I run this ABAP program through the Web Portal by "Workset"
    After I input the selection criteria and execute the program:
    The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
    How can I solve it ?
    Can OLE Excel Abap Program can run on Web Portal through the "Workset" ?
    Thanks so much,
    Mark

    Hi
    check this might help
    Re: Displaying Error while uploading Excel Sheets
    jo

  • Error in using ABAP OLE wrong cell value

    Dear All..
    I'm facing a problem while using ABAP OLE..
    the problem is the ABAP OLE writes the wrong value in Excel file
    the value is 121.000 but it written in Excel file : 121
    the weird thing is .. other value of  9.000.000 written correctly in Excel File .. and also lots of other values..
    i've trace the value until it goes to the method of :
    CALL METHOD OF h_excel 'Cells' = h_zl
         EXPORTING
           #1 = i_row
           #2 = i_col.
       SET PROPERTY OF h_zl 'Value' = i_value.
       GET PROPERTY OF h_zl 'Font' = h_f.
       IF i_bold = 'X'.
         SET PROPERTY OF h_f 'Bold' = 1.
       ENDIF.
       and the values of variable i_value is still correct which is : 121.000 but after writing in excel it becomes 121
       i believe it will become faulty at the specific amount with format of XXX.000  because if I changed the value to 121.001 it displays correctly in Excel file..
    i_value is a pass value from variable ld_val with data type of is --> ld_val(20) type n.
    is this are originally bugs from the OLE ? how to solved it ?
    please advice ..

    yes it is clear, but how excel manage the passed data is unclear.
    However, to solve you can try this:
    DATA : ld_val(20).
    WRITE value1 TO ld_val CURRENCY CURR.
    REPLACE ALL OCCURRENCES OF '.' IN ld_val WITH space.
    CALL METHOD OF h_excel 'Cells' = h_zl
         EXPORTING
         #1 = i_row
         #2 = i_col.
       SET PROPERTY OF h_zl 'Value' = ld_val.
       GET PROPERTY OF h_zl 'Font' = h_f.
       IF i_bold = 'X'.
         SET PROPERTY OF h_f 'Bold' = 1.
       ENDIF.
    Regards,
    Angelo.

  • Dump while running a program with OLE Excel download facility in ITS

    Hi,
    Because of some complex requirment, I had created a report program which will download the data to an Excel sheet using SAP OLE Automation Controller. For this report i had created a tcode too.
    The report which i developed is perfectly working fine in SAPGUI. But if i access the same report throught SAP ITS serice. I am getting a dump. Please find below the dump details. I am not able to figure it out why the dump is not coming in SAPGUI.
    Runtime Errors         MESSAGE_TYPE_X
    Date and Time          09.03.2010 05:35:41
    Short text
    The current application triggered a termination with a short dump.
    What happened?
    The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X).
    |
    Error analysis
    Short text of error message:
    Control Framework : Error processing control
    Long text of error message:
    Diagnosis
    An error occurred when the system tried to process the commands
    from the Automation Queue on the presentation server.
    There are several possible reasons for this:
    - The installation of the SAP GUI on the presentation server is
    faulty or obsolete.
    - There is an error in the application program
    - There is an error in the SAPGUI or an integrated control
    Procedure
    1. Make sure that you have imported the appropriate Support
    Package, the current kernel, and GUI patch for the release of your
    system
    2. Check whether the error occurs locally on one or a few PCs, or
    generally on all PCs. Note whether the error only occurs for some
    users, for example because of a specific Customizing setting.
    If it only occurs locally, this suggests an installation problem
    with the PC. Check the installation; if necessary, reinstall the
    software. In the dump, search for the SY-MSGLI field, since it may
    point to the cause of the error.
    3. Activate the Automation Trace (in accordance with SAP Note
    158985).
    4.Start the transaction and continue until the screen immediately
    before the dump.
    5. From the System -> Utilities menu, choose Autom. Queue,
    Synchronous Processing.
    The status bar of the GUI displays the text:
    "Automation synchron flush mode on"
    6. If you now proceed with the application, the short dump will
    display the ABAP call that caused the error; the Automation Trace
    will contain the error on the presentation server.
    7. If necessary, load the short dump and trace files on to
    sapservX, so that SAP can analyze them.
    Technical information about the message:
    Message class....... "CNDP"
    Number.............. 006
    Variable 1.......... " "
    Variable 2.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    How to correct the error
    Probably the only way to eliminate the error is to correct the program.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "MESSAGE_TYPE_X" " "
    "SAPLOLEA" or "LOLEAU02"
    "AC_SYSTEM_FLUSH"
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
    To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
    Display the system log by calling transaction SM21.
    Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
    In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    User and Transaction
    Client.............. 120
    User................ "XXXXXX"
    Language Key........ "E"
    Transaction......... "ZGA_BEACON_SOX_RPT "
    Transactions ID..... "4B95E2560EB62F9AE10000000A241C33"
    Program............. "SAPLOLEA"
    Screen.............. "ZGA_REP_BEACON_SOX_REPORT 9000"
    Screen Line......... 0
    Information on Caller ofr "HTTP" Connection:
    Plug-in Type.......... "HTTP"
    Caller IP............. "10.36.28.52"
    Caller Port........... 8000
    Universal Resource Id. "/sap/bc/gui/sap/its/webgui/~flNUQVRFPTIzNzIxLjAxNC4wNC4
    wNA=="

    Hi All,
    FYI.....
    As I said because of my complex requirement, i am using OLE excel download facilities to download the data. ITS wont support this OLE download facility.  This can be done only through local SAP GUI.
    The reason for this is that, when i am using this download facility through SAP GUI, OLE object thats used in my report program will directly talk to the Local OLE excel objects (i.e. the local installed Excell application) and download the data. But if it's through ITS, my program wont be able to communicate with the local excel OLE objects because of this i am getting a DUMP.
    Thank You all for the support. All the best in future. 
    Regards
    Maneesh Chandran

  • OLE excel

    Hello all,
    1.
    I shoud output a excel file using ABAP development. And my excel file is very complex, it have some fixed headers. i am new to ole excel, so who  can give me some examples or some useful website. then i can learn how to do it ?
    2.
    anther question: in which situation, i can't output a excel file? pls tell me asap.
    Thanks in advance.

    Hello Ming,
    Try this program... i have used lots of excel formatting in it.. revert back incase you need help
    *& Report  ZKRIS_OLE2
    REPORT  zkris_ole2.
    TYPE-POOLS ole2 .
    DATA:  count TYPE i,
           application TYPE ole2_object,
           workbook TYPE ole2_object,
           excel     TYPE ole2_object,
           sheet TYPE ole2_object,
           cells TYPE ole2_object.
    CONSTANTS: row_max TYPE i VALUE 256.
    DATA index TYPE i.
    DATA:
          h_cell        TYPE ole2_object,        " cell
          h_f           TYPE ole2_object,        " font
          h_range       TYPE ole2_object,
          h_range2      TYPE ole2_object,
          h_merge       TYPE ole2_object,
          h_int         TYPE ole2_object,
          h_int2         TYPE ole2_object,
          h_width       TYPE ole2_object,
          h_columns     TYPE ole2_object,
          h_rows        TYPE ole2_object,
          h_actwindow   TYPE ole2_object,
          h_select      TYPE ole2_object,
          h_select2     TYPE ole2_object,
          h_hyperlink   TYPE ole2_object,
          h_addhyper    TYPE ole2_object,
          h_borderstop  TYPE ole2_object,
          h_entirecol   TYPE ole2_object.
    CREATE OBJECT excel 'EXCEL.APPLICATION'.
    IF sy-subrc NE 0.
      WRITE: / 'No EXCEL creation possible'.
      STOP.
    ENDIF.
    SET PROPERTY OF excel 'DisplayAlerts' = 0.
    CALL METHOD OF excel 'WORKBOOKS' = workbook .
    SET PROPERTY OF excel 'VISIBLE' = 1.
    * creating workbook
    SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
    CALL METHOD OF workbook 'ADD'.
    CALL METHOD OF excel 'WORKSHEETS' = sheet.
    CALL METHOD OF sheet 'ADD'.
    FREE OBJECT sheet.
    CALL METHOD OF excel 'WORKSHEETS' = sheet
      EXPORTING
        #1 = 1.
    SET PROPERTY OF sheet 'NAME' = 'Company Codes'.
    CALL METHOD OF sheet 'ACTIVATE'.
    DATA: col TYPE i VALUE 1,
    row TYPE i VALUE 2,
    col1 TYPE i VALUE 2,
    col_real TYPE i VALUE 1.
      index = row_max * ( row - 2 ) + 1.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
          #1 = index.
      SET PROPERTY OF cells 'Value' = 'thsi is some larger amount of data blahhhh'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '1:1'.
      SET PROPERTY OF h_rows 'WrapText' = 1.
    DO 5 TIMES.
      index = row_max * ( row - 1 ) + col.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
          #1 = index.
    *  SET PROPERTY OF cells 'Value' = '=TRIM("1234     2")'.
      SET PROPERTY OF cells 'Value' = 'thsi is some large data'.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      SET PROPERTY OF h_cell  'Align' = 'Center'.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
    *  SET PROPERTY OF h_int  'ColorIndex' = col_real .
      GET PROPERTY OF h_cell 'Font'    = h_f.
    *  SET PROPERTY OF h_f 'ColorIndex' = 1.
    get property of h_cell 'Borders' = h_borderstop.
    set property of h_borderstop 'LineStyle' = 1.
    set property of h_borderstop 'Weight' = 2.
      SET PROPERTY OF h_f 'Bold' = 1.                    "bold
      SET PROPERTY OF h_cell 'HorizontalAlignment' = 2.  "left align
      SET PROPERTY OF h_cell 'Orientation' = 45.         "angled
      col = col + 1.
      col_real = col_real + 1.
      IF col = 16.
        col = 1.
        row = row + 1.
      ENDIF.
      col1 = col_real + 1.
    ENDDO.
    index = row_max * ( 10 - 1 ) + 1.
    CALL METHOD OF sheet 'Cells' = cells
      EXPORTING
        #1 = index.
    SET PROPERTY OF cells 'Value' = '123'.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = 10
        #2 = 1.
    GET PROPERTY OF h_cell 'Interior'   = h_int.
    SET PROPERTY OF h_int  'ColorIndex' = 4 .
    *range
    CALL METHOD OF excel 'Range' = h_range
      EXPORTING
        #1 = 'A10'
        #2 = 'K10'.
    CALL METHOD OF h_range 'Merge' = h_merge .
    * width or autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'A:E'.
    *SET PROPERTY OF h_columns 'ColumnWidth' = 17.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    set property of h_entirecol 'Autofit' = 1.
    * hyperlink
    ** simple method
    *get property of sheet 'Hyperlinks' = h_hyperlink.
    *call method of h_hyperlink 'Add' = h_addhyper
    *  exporting
    *  #1 = h_range
    *  #3 = '#Sheet1!A1'.
    index = row_max * ( 12 ) + 1.
    CALL METHOD OF sheet 'Cells' = cells
      EXPORTING
        #1 = index.
    SET PROPERTY OF cells 'Value' = 'test data'.
    GET PROPERTY OF sheet 'Hyperlinks' = h_hyperlink.
    CALL METHOD OF h_hyperlink 'Add' = h_addhyper
      EXPORTING
        #1 = cells
        #3 = '#Sheet1!A1'.
    * borders
    CALL METHOD OF excel 'Range' = h_range2
      EXPORTING
        #1 = 'A5'
        #2 = 'L28'.
    GET PROPERTY OF h_range2 'Select' = h_select2.
    *CALL METHOD OF h_hyperlink 'Add' = h_addhyper
    *  EXPORTING
    *    #1 = h_range2
    *    #3 = '#Sheet1!A1'.
      GET PROPERTY OF h_select2 'Interior'   = h_int2.
      SET PROPERTY OF h_int2  'ColorIndex' = 6 .
    get property of h_range2 'Borders' = h_borderstop.
    set property of h_borderstop 'LineStyle' = 1.
    set property of h_borderstop 'Weight' = 2.
    * freeze panes
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '3:3'.
    GET PROPERTY OF h_rows 'Select' = h_select.
    GET PROPERTY OF excel 'ActiveWindow' = h_actwindow.
    SET PROPERTY OF h_actwindow 'FreezePanes' = 1.

  • ABAP & OLE Automation Controller

    Hi everybody,
    When I use ABAP & OLE Automation Controller to build a Excel file, I don't find a documentation about the values of the properties parameters.
    For example:
    (DATA gs_cell TYPE ole2_object.)
    SET PROPERTY OF gs_cell  'HorizontalAlignment' = -4108 .
    I found in Visual Basic Editor all properties of the OLE objects. But the number -4108 remains a mystery for me.
    Where can we find this value ?
    I tried to read the official Microsoft and ABAP documentation without success.
    Can you help me ?
    I thank you in advance.
    Patrocle

    Hi,
    I use http://msdn.microsoft.com/en-us/library/ms262200.aspx site
    In the documentation for Range.HorizontalAlignment You can find it uses XlHAlign:
    http://msdn.microsoft.com/en-us/library/bb241313(v=office.12).aspx
    Name                    Value     Description
    xlHAlignCenter               -4108     Center.
    xlHAlignCenterAcrossSelection         7     Center across selection.
    xlHAlignDistributed          -4117     Distribute.
    xlHAlignFill                   5     Fill.
    xlHAlignGeneral                   1     Align according to data type.
    xlHAlignJustify               -4130     Justify.
    xlHAlignLeft               -4131     Left.
    xlHAlignRight               -4152     Right.
    Regards,
    Przemysław

  • Failed to Run OLE Excel program in background JOB (SM36)

    Please help.
    I have write a program to use OLE to create a Excel file.
    The program can run successful in front end workstation. However, when I run the program in background job by SM36.
    The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
    How can I solve it ?
    Can OLE Excel be run on background job ?
    Thanks so much,
    Mark

    Hi Mark:
    Your need is a very common one. I also was asked to generate an Excel in Background.
    It is not possible to work with OLE in background mode.
    The reason is: In background mode there is no presentation server. OLE is executed in presentation server.
    Below I paste the code I wrote to solve my problem.
    This class sends a mail with an excel attached. The Excel content will be the internal table you pass to the class. But the Excel is not binary, it is a plain text file, separated by tabulators. Anyway, when you open it with Excel, the columns are properly shown.
    Sorry. Comments are in spanish, I don't have time to translate it.
    I kindly ask to everybody which want to use it to keep my name in the code.
    * Autor: Jordi Escoda, 30/10/2008.
    * Descripción: Esta clase genera un correo electrónico destinado a
    *  una persona, adjuntando el contenido de una tabla interna como
    *  Excel (campos separados por tabuladores).
    *  La virtud de esta clase es su sencillez de utilización. Para lanzar
    *  el mail con el excel adjunto basta con declarar la tabla interna,
    *  llenarla, colocar el asunto del mensaje, el destinatario, el nombre
    *  del excel adjunto, y pasar la tabla interna.
    * Ejemplo de utilización:
    *  DATA: lc_mail TYPE REF TO cl_mail_builder_xls_attach.
    *  DATA: lt_anla TYPE STANDARD TABLE OF anla.
    *    SELECT * INTO TABLE lt_anla  FROM anla.
    *    CREATE OBJECT lc_mail.
    *    CALL METHOD lc_mail->set_subject( 'Excel adjunto' ).
    *    CALL METHOD lc_mail->set_recipient( 'XXX@XXXDOTCOM' ).
    *    CALL METHOD lc_mail->set_attach_filename( 'ANLA' ).
    *    APPEND 'Cuerpo del mensaje' TO  lt_body.
    *    APPEND 'Saludos cordiales' TO  lt_body.
    *    CALL METHOD lc_mail->set_bodytext( lt_body ).
    *    CALL METHOD lc_mail->set_attach_table( lt_anla ).
    *    CALL METHOD lc_mail->send( ).
    *       CLASS cl_mail_builder_xls_attach DEFINITION
    CLASS cl_mail_builder_xls_attach DEFINITION.
      PUBLIC SECTION.
        METHODS: set_subject
                               IMPORTING im_subject TYPE so_obj_des,
                 set_bodytext
                               IMPORTING im_body TYPE bcsy_text,
                 set_recipient
                               IMPORTING im_recipient TYPE ad_smtpadr,
                 set_attach_table
                               IMPORTING im_table TYPE ANY TABLE,
                 set_attach_filename
                               IMPORTING im_attach_name TYPE sood-objdes,
                 send.
      PRIVATE SECTION.
        CONSTANTS:
          c_tab  TYPE c VALUE cl_bcs_convert=>gc_tab,
          c_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf,
          c_singlequote TYPE c VALUE '.
        DATA: l_recipient_addr TYPE ad_smtpadr.
        DATA: send_request   TYPE REF TO cl_bcs,
              document       TYPE REF TO cl_document_bcs,
              recipient      TYPE REF TO if_recipient_bcs,
              bcs_exception  TYPE REF TO cx_bcs.
        DATA: binary_content TYPE solix_tab,
              size           TYPE so_obj_len.
        DATA: l_string TYPE string,
              l_body_text TYPE bcsy_text,
              l_subject TYPE so_obj_des,
              l_attach_name TYPE sood-objdes.
        METHODS: create_binary_content,
                 get_dataelement_medium_text
                        IMPORTING im_table_name TYPE tabname
                                  im_field_name TYPE fieldname
                        EXPORTING ex_medium_text TYPE scrtext_m.
    ENDCLASS.                    "cl_mail_builder_xls_attach DEFINITION
    *       CLASS cl_mail_builder_xls_attach IMPLEMENTATION
    CLASS cl_mail_builder_xls_attach IMPLEMENTATION.
      METHOD set_bodytext.
        l_body_text[] = im_body[].
      ENDMETHOD.                    "add_bodytext
      METHOD set_subject.
        l_subject = im_subject.
      ENDMETHOD.                    "add_subject
      METHOD set_attach_filename.
        l_attach_name = im_attach_name.
      ENDMETHOD.                    "add_subject
      METHOD set_recipient.
        l_recipient_addr = im_recipient.
      ENDMETHOD.                    "add_subject
      METHOD set_attach_table.
    *   Rellena en un string el contenido de la tabla interna recibida
        DATA: ref_to_struct  TYPE REF TO cl_abap_structdescr.
        DATA: my_like TYPE fieldname,
              nombretabla TYPE tabname,
              nombrecampo TYPE fieldname,
              texto_mediano TYPE scrtext_m.
        DATA: l_idx TYPE i,
              l_valorcampo(16) TYPE c,
              l_long TYPE i.
        FIELD-SYMBOLS: <fs_linea> TYPE ANY,
                       <fs_campo> TYPE ANY.
        FIELD-SYMBOLS: <comp_descr> TYPE abap_compdescr.
        CHECK NOT im_table[] IS INITIAL.
    *   Línea con los nombres de las columnas.
        CLEAR l_string.
        LOOP AT im_table ASSIGNING <fs_linea>.
    *     Toma los atributos del componente
          ref_to_struct  =
                     cl_abap_structdescr=>describe_by_data( <fs_linea> ).
          LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
            ASSIGN COMPONENT <comp_descr>-name
                                OF STRUCTURE <fs_linea> TO <fs_campo>.
    *       Obtenemos el origen de donde proviene (like). Ej:BKPF-BUDAT
            DESCRIBE FIELD <fs_campo> HELP-ID my_like.
            SPLIT my_like AT '-' INTO nombretabla nombrecampo.
            CALL METHOD get_dataelement_medium_text
              EXPORTING
                im_table_name  = nombretabla
                im_field_name  = nombrecampo
              IMPORTING
                ex_medium_text = texto_mediano.
            IF texto_mediano IS INITIAL.
              CONCATENATE l_string <comp_descr>-name INTO l_string.
            ELSE.
              CONCATENATE l_string texto_mediano INTO l_string.
            ENDIF.
            AT LAST.
              CONCATENATE l_string c_crlf INTO l_string.
              EXIT.
            ENDAT.
            CONCATENATE l_string c_tab INTO l_string.
          ENDLOOP.
          EXIT.
        ENDLOOP.
    *   Contenido de la tabla
        LOOP AT im_table ASSIGNING <fs_linea>.
    *     Toma los atributos del componente
          ref_to_struct  =
                     cl_abap_structdescr=>describe_by_data( <fs_linea> ).
          LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
    *       Asignamos el componente ue tratamos, para obtener
    *       el valor del mismo
            ASSIGN COMPONENT <comp_descr>-name OF STRUCTURE <fs_linea>
                                            TO <fs_campo>.
            CASE <comp_descr>-type_kind.
              WHEN 'P'. "Packed Number
    *           Convierte a caracter
                WRITE <fs_campo> TO l_valorcampo.
                CONCATENATE l_string l_valorcampo INTO l_string.
              WHEN OTHERS.
                l_long = STRLEN( <fs_campo> ).
                IF l_long > 11 AND <fs_campo> CO ' 0123456789'.
    *             El Excel muestra un número tal como 190000000006
    *             en formato 1,9E+11.
    *             Para eviarlo, los números de más de 11 dígitos los
    *             concatenamos con comillas simples.
                  CONCATENATE l_string c_singlequote
                              <fs_campo> c_singlequote INTO l_string.
                ELSE.
                  CONCATENATE l_string <fs_campo> INTO l_string.
                ENDIF.
            ENDCASE.
            AT LAST.
    *         Añade CRLF
              CONCATENATE l_string c_crlf INTO l_string.
              EXIT.
            ENDAT.
    *       Añade tabulador
            CONCATENATE l_string c_tab INTO l_string.
          ENDLOOP.
        ENDLOOP.
        create_binary_content( ).
      ENDMETHOD.                    "set_attach_table
      METHOD create_binary_content.
        DATA: l_size TYPE so_obj_len.
    *   convert the text string into UTF-16LE binary data including
    *   byte-order-mark. Mircosoft Excel prefers these settings
    *   all this is done by new class cl_bcs_convert (see note 1151257)
        TRY.
            cl_bcs_convert=>string_to_solix(
              EXPORTING
                iv_string   = l_string
                iv_codepage = '4103'  "suitable for MS Excel, leave empty
                iv_add_bom  = 'X'     "for other doc types
              IMPORTING
                et_solix  = binary_content
                ev_size   = size ).
          CATCH cx_bcs.
            MESSAGE e445(so).
        ENDTRY.
      ENDMETHOD.                    "create_binary_content
      METHOD send.
        DATA: l_sent_to_all TYPE os_boolean.
        TRY.
    *       create persistent send request
            send_request = cl_bcs=>create_persistent( ).
    *       create and set document with attachment
    *       create document object
            document = cl_document_bcs=>create_document(
              i_type    = 'RAW'
              i_text    = l_body_text
              i_subject = l_subject ).
    *       add the spread sheet as attachment to document object
            document->add_attachment(
              i_attachment_type    = 'xls'
              i_attachment_subject = l_attach_name
              i_attachment_size    = size
              i_att_content_hex    = binary_content ).
    *       add document object to send request
            send_request->set_document( document ).
    *       add recipient (e-mail address)
            recipient =
               cl_cam_address_bcs=>create_internet_address(
                                          l_recipient_addr ).
    *       add recipient object to send request
            send_request->add_recipient( recipient ).
    *       send document
            l_sent_to_all = send_request->send(
                                 i_with_error_screen = 'X' ).
            COMMIT WORK.
            IF l_sent_to_all IS INITIAL.
              MESSAGE i500(sbcoms) WITH l_recipient_addr.
            ELSE.
              MESSAGE s022(so).
            ENDIF.
          CATCH cx_bcs INTO bcs_exception.
            MESSAGE i865(so) WITH bcs_exception->error_type.
        ENDTRY.
      ENDMETHOD.                    "lcl_mail_xls_attachment
      METHOD get_dataelement_medium_text.
        DATA: lt_fld_info TYPE STANDARD TABLE OF dfies,
          wa_fld_info TYPE dfies.
    *   Busca en el diccionario los datos del campo
        CALL FUNCTION 'DDIF_FIELDINFO_GET'
          EXPORTING
            tabname        = im_table_name
            fieldname      = im_field_name
            langu          = sy-langu
          TABLES
            dfies_tab      = lt_fld_info
          EXCEPTIONS
            not_found      = 1
            internal_error = 2
            OTHERS         = 3.
        CLEAR ex_medium_text.
        IF sy-subrc = 0.
          READ TABLE lt_fld_info INDEX 1 INTO wa_fld_info.
    *     Si lo ha podido tomar del diccionario...
          IF NOT wa_fld_info-scrtext_m IS INITIAL.
    *       Toma el nombre del nombre de campo del diccionario
            ex_medium_text = wa_fld_info-scrtext_m.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "get_dataelement_medium_text
    ENDCLASS.                    "cl_mail_builder_xls_attach IMPLEMENTATION

  • ABAP OLE Word - Delete last page

    Dear all,
    I have a SAP program which prints some documents in Microsoft Word by using ABAP OLE Objects.
    I use a template to take the main context, and after that I send some variables in order to populate the word document.
    The problem is when I create the new word document, I paste the template text in a new document, but at the end I have always an empty page. I don't know how to delete this final page, I don't find the corresponding OLE method to do it.
    I have found a method to cut a line, but the problem is that line is also empty, and I cannot cut it.
    Could anyone help me?
    Many thanks in advance and best regards.

    Hi,
    post some code lines. Format as code, use preview.
    Regards,
    Clemens

  • Invoking Openoffice calc through ABAP OLE Object

    I want to show the output of my ABAP process  through openoffice calc worksheet.
    I tried to invoke calc using ABAP OLE object.
    But even a blank calc sheet is not getting opened with the following statements.
    Type-pools: OLE2.
    TYPES:
    service_manager type OLE2_OBJECT,
    DESKTOP type OLE2_OBJECT,
    DOCUMENT type OLE2_OBJECT.
    CREATE OBJECT service_manager 'com.sun.star.ServiceManager'.
    CALL METHOD OF SERVICE_MANAGER 'createInstance' = DESKTOP
    EXPORTING #1 = 'com.sun.star.frame.Desktop'.
    CALL METHOD OF DESKTOP 'loadComponentFromURL' = DOCUMENT
    EXPORTING #1 = 'private:factory/scalc'
              #2 = '_blank'
              #3 = 0
              #4 = '' .
    What is wrong with this code?. Is there any other setting required at the system/OS/ABAP/BASIS
    level to invoke openoffice applications?.
    I have registered the classid for openservice manager in the transaction SOLE. Still it is not working.
    Iam able to invoke openoffice applications with Visual Basic/Power builder lanaguages.
    Please respond.
    Thanks in advance
    Liju

    I don't think it's possible.
    4th parameter of loadComponentFromURL method is an array ( http://api.openoffice.org/docs/common/ref/com/sun/star/frame/XComponentLoader.html )
    Arrays are not supported as parameters in ABAP OLE Automation. (see note [633105|https://service.sap.com/sap/support/notes/633105] - OLE automation: ABAP type for OLE array parameters )

  • OLE Excel Questions

    Guys,
    I am working on OLE excel to download data from SAP.I have few basic questions for OLE excel
    1. I want to merge Cells in EXCEL , how can i do it?
    2. I want to make alignment right in some Cell,how can i do it?
    3. I have been reading post in SDN for OLE ,so in that one i notice different numbers for colors like 
    SET PROPERTY OF O_INTERIOR 'Color' = '10092543'.
    .how can i know the code for color. as well as for alignment of text in cell . 
    SET PROPERTY OF O_CELL 'HorizontalAlignment' = -4108 .
    ..so from where do you know -4180 is for center alignment
    4. How can i know different methods and properties of excel cell as well as workbook.
    I know these are lot of questions,but basic ones i guess.If someone can give me guidance that would be helpful and points will be given.

    Suppose EXCEL is your EXCEL.APPLICATION handler
    All H_ objects are of  TYPE OLE2_OBJECT type
    1. for merging
    data:
          H_RANGE       TYPE OLE2_OBJECT,
          H_MERGE       TYPE OLE2_OBJECT.
    CALL METHOD OF EXCEL 'Range' = H_RANGE
      EXPORTING
        #1 = 'A10'
        #2 = 'K10'.
    CALL METHOD OF H_RANGE 'Merge' = H_MERGE .
    2. for aligning, row and col are of type i.. referring to the cell you wish to change
    1 = default
    2 = left
    3 = center
    4 = right
    5 = justify
      CALL METHOD OF EXCEL 'Cells' = H_CELL
        EXPORTING
          #1 = ROW
          #2 = COL.
      SET PROPERTY OF h_cell 'HorizontalAlignment' = 3.
    3. For color coding see this program
    *& Report  ZKRIS_OLE3_PALETTE
    *& Displays the full OLE color range in excel
    REPORT  ZKRIS_OLE3_PALETTE.
    TYPE-POOLS ole2 .
    DATA:  count TYPE i,
           count_real TYPE i,
           application TYPE ole2_object,
           workbook TYPE ole2_object,
           excel     TYPE ole2_object,
           sheet TYPE ole2_object,
           cells TYPE ole2_object.
    CONSTANTS: row_max TYPE i VALUE 256.
    DATA index TYPE i.
    DATA:
          h_cell        TYPE ole2_object,        " cell
          h_f           TYPE ole2_object,        " font
          h_int         TYPE ole2_object,
          h_width       TYPE ole2_object,
          h_columns     TYPE ole2_object,
          h_rows        TYPE ole2_object,
          h_font        TYPE ole2_object,
          h_entirecol   TYPE ole2_object.
    DATA: h_range       TYPE ole2_object.
    DATA: h_merge       TYPE ole2_object.
    CREATE OBJECT excel 'EXCEL.APPLICATION'.
    IF sy-subrc NE 0.
      WRITE: / 'No EXCEL creation possible'.
      STOP.
    ENDIF.
    SET PROPERTY OF excel 'DisplayAlerts' = 0.
    CALL METHOD OF excel 'WORKBOOKS' = workbook .
    SET PROPERTY OF excel 'VISIBLE' = 1.
    * creating workbook
    SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
    CALL METHOD OF workbook 'ADD'.
    CALL METHOD OF excel 'WORKSHEETS' = sheet
      EXPORTING
        #1 = 1.
    SET PROPERTY OF sheet 'NAME' = 'Color Palette'.
    CALL METHOD OF sheet 'ACTIVATE'.
    DATA: col TYPE i VALUE 1,
    row TYPE i VALUE 2,
    col1 TYPE i VALUE 2,
    col_real TYPE i VALUE 1.
    row = 1.
    col = 3.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'No.'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '2:2'.
    SET PROPERTY OF h_rows 'WrapText' = 1.
    col = 9.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'No.'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
    SET PROPERTY OF h_cell 'Bold' = 1.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '1:1'.
    SET PROPERTY OF h_rows 'WrapText' = 1.
    GET PROPERTY OF h_rows 'Font' = h_font.
    SET PROPERTY OF h_font 'Bold' = 1.
    count = 1.
    count_real = count.
    row = 2.
    col = 3.
    DO 56 TIMES.
      PERFORM write_num_and_color.
    ENDDO.
    * autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'C:L'.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    SET PROPERTY OF h_entirecol 'Autofit' = 1.
    * write palette on lhs
    *range
    CALL METHOD OF excel 'Range' = h_range
      EXPORTING
        #1 = 'A2'
        #2 = 'A20'.
    CALL METHOD OF h_range 'Merge' = h_merge .
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = 2
        #2 = 1.
    SET PROPERTY OF h_cell 'Value' = 'Palette'.
    SET PROPERTY OF h_cell 'Orientation' = 90.         "angled.
    SET PROPERTY OF h_cell 'HorizontalAlignment' = 3.  "center align
    GET PROPERTY OF h_cell 'Font'    = h_f.
    SET PROPERTY OF h_f 'Bold' = 1.                    "bold
    SET PROPERTY OF h_f 'Name' = 'Comic Sans MS'.
    SET PROPERTY OF h_f 'Size' = '14'.
    SET PROPERTY OF h_cell 'VerticalAlignment' = 2.  "center align
    * autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'A:A'.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    SET PROPERTY OF h_columns 'ColumnWidth' = 4.
    *&      Form  write_num_and_color
    *       text
    FORM write_num_and_color.
      index = row_max * ( row - 1 ) + col.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
          #1 = index.
      SET PROPERTY OF cells 'Value' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
      SET PROPERTY OF h_int  'ColorIndex' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
      GET PROPERTY OF h_cell 'Font'    = h_f.
      SET PROPERTY OF h_f 'ColorIndex' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
      SET PROPERTY OF h_int  'ColorIndex' = 1.
      SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
      GET PROPERTY OF h_cell 'Font'    = h_f.
      SET PROPERTY OF h_f 'ColorIndex' = count_real.
      row = row + 1.
      col = col - 3.
      count = count + 1.
      IF count = 29.
        count = 1.
        row = 2.
        col = col + 6.
      ENDIF.
      count_real = count_real + 1.
    ENDFORM.                    "write_num_and_color
    4. To know the different OLE properties, you need to examine the macros in excel and then use a bit of trial and error at first

  • ABAP OLE data transfer

    Hi.. m working on a program..where i have to transfer data from sap to word doc using abap OLE..
    i have an internal table itab where all the related fields are stored and this table's contents are  pasted to word document using the function  'clpb_export'.. now this itab contains some 20 odd fields with some having static values(constant values) and others being populated by values from selections.
    When i run the program , there is an error.
    the error is in the function module 'clpb_export'. the line of error is:
      ASSIGN COMPONENT 1 OF STRUCTURE <fs> TO <f>.
    The error says:
    ' You attempted to assign a field to a typed field symbol, but the field does not have the required type.  '    
    Now wen i remove those fields with static values , the program runs fine.
    so pls help

    Use gui_download function module u will get .doc(word format).

  • Interface between ABAP and Excel-report

    Hi anyone!
    I need to implement a BAdI (CRM_MKTTG_SEG_MEM_EX) for displaying an aggregated BW field in the CRM Segment Builder. However my programmer knows little about the interface between ABAP an Excel. He therefore struggles with the programming. Have anyone of you any suggestions for how he can call a field in a query. Has anyone used this BAdI for the same purpose?
    Thanks, Camilla

    Hello Camilla,
    i think you should ask your question in a generic form in the BW forum. Ask them for access to a Query via RFC.
    Regards
    Gregor

  • A number in a CHAR in OLE excel

    Hi,
    I've got a problem with and OLE Excel.
    I must pass to the excel file a numeric value written in a char variables (es: '01111') and, in the excel file, it is written like '111111'.
    I try to convert it with this:
       GET PROPERTY OF g_cell1 'SET_FORMAT' = g_text.
       SET PROPERTY OF g_text  'CATEGORY' = 4.
    but it doesn't work.
    Please, help me.
    Thanks

    Hi,
    I think the value is passed correctly but this is excel's output format.
    When you open the file, right click on cell -> Format Cells -> Custom -> enter 5 zeros '00000' (exact number of places which should be displayed). Now the value will come as '01111'.
    Regards
    Marcin

  • Regarding OLE Excel

    Hi gurus,
    I am creating Excel file passing values to different sheets A,B,C from internal table.
    But when my program is under execution, if i try open new excel sheet then datas are getting written into new sheet. so the out put of real excel sheet is different from as expected.
    Do i have to maintain any property in OLE excel to avoid this situation. because i want to open some other excel file, while my program is executing with OLE excel creation.
    Regards
    Ambichan

    INCLUDE ole2incl.
    DATA: application TYPE ole2_object,
           workbook TYPE ole2_object,
           sheet TYPE ole2_object,
           cells TYPE ole2_object,
           gs_chart TYPE ole2_object.
    CONSTANTS: row_max TYPE i VALUE 256.
    DATA index TYPE i.
    CREATE OBJECT application 'excel.application'.
        SET PROPERTY OF application 'visible' = 1.
        CALL METHOD OF application 'Workbooks' = workbook.
    *CALL METHOD OF workbook 'Add'. "if you want to create a file
        CALL METHOD OF workbook 'Open'
          EXPORTING
            #1 = p_file.
             #1 =    'C:\Temp\XXX0099_Support_20XX.xls'.  "your excel file
                                                               name here
    Create second Excel sheet  "Timesheets
        CALL METHOD OF application 'Worksheets' = sheet
          EXPORTING
            #1 = 2.
        SET PROPERTY OF sheet 'Name' = 'Timesheets'.
        CALL METHOD OF sheet 'Activate'.
        CLEAR: w_index.
        SORT itab BY budat hiden.
        LOOP AT itab.
          w_index = sy-tabix + w_lin.
          CALL METHOD OF application 'Cells' = cells
            EXPORTING
              #1 = w_index      " line
              #2 = 1.           " column
          SET PROPERTY OF cells 'Value' = itab-hiden .  "need to be changed
    Save excel spreadsheet to particular filename
        CALL METHOD OF sheet 'Save'   "'Save'
          EXPORTING
       #1 = p_file
            #1 =  p_file
            #2 = 1."filename
        "fileFormat
    Closes excel window, data is lost if not saved
    SET PROPERTY OF application 'visible' = 0.
    reward points if its helpful

  • Using Existing OLE Excel Object

    Hi
    I have created an ole excel object to download my report data.
    My requirement is to use an existing excel object.
    Existing OLE object would act like a template with the Header Information and my company's logo in it.
    Can anyone suggest suitable procedures for the same.
    AK

    I dont know more about it.
    Just have look below function module.
    <b>EXCEL_OLE_STANDARD_DAT</b> Just calls MS_EXCEL_OLE_STANDARD_DAT
    <b>MS_EXCEL_OLE_STANDARD</b>_DATDownloads internal table and opens it in MS Excel
    <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b> Uploads an *.xls file to internal table (max cell length = 32).
    <b>ALSM_EXCEL_TO_INTERNAL_TABLE</b> the same as KCD_EXCEL_OLE_TO_INT_CONVERT but max cell length = 50
    <b>FTBU_START_EXCEL</b> just [download internal table to file and] start Excel (w/o OLE).
    regards
    vinod

Maybe you are looking for

  • MacBook Pro to Canon MP-600 Bluetooth troubleshooting

    I recently (and successfully) connected my MacBook Pro to my Canon Pixma MP600 using a Motorola Bluetooth dongle. However, once I'd switched off the printer and then later switched it back on the connection between the two was lost. The bluetooth and

  • Lumia 520 SMS disappeared!!!!

    i bought nokia lumia 520 for about 1 month. the text messages disappear automatically!!! right now, the only text message is the acknowledgement message from the mobile operator saying i've delivered the message. that's the only message that can exis

  • Motion 4 Opinion

    I am sure this has been asked numerous times before, but believe it or not it is not easy finding the right information about this subject. I am a film student and am studying all aspects of filmmaking. One of them is compositing, editing and digital

  • Family sharing says I do not have a valid payment method

    I'm Trying to set up family sharing and it says "your family must have a valid payment option".  Yet the credit card is valid and is used to make iTunes purchases all the time.  Help!

  • Iphone 3 g does not boot cannot shot off  Apple icon constantly on

    iPhone 3 G cannot turne offor on, Allpe icon consttantly on