I_OI_DOCUMENT_PROXY and I_OI_SCRIPT_COLLECTION

Afternoon,
Has any one been able to create a macro within an excel document using I_OI_DOCUMENT_PROXY and I_OI_SCRIPT_COLLECTION interfaces? If so how did you go about doing this?
I get a CONTROL_INTERNAL_ERROR from the method gx_script_collection->add_script_from_table and can't seem to get beyond this poing:
MESSAGE_ID    SOFFICEINTEGRATION
MESSAGE_NR  118
MESSAGE         Script contains errors
Any help would be appreciated,
Regards,

Hi John,
I found the error was not actual from EXCEL, but deep in from the Proxy service return error 118.
In the mean time I found the problem :o)
I have by mistake typed in macro wrong !
CALL METHOD lc_document->execute_macro
    EXPORTING
*      macro_string = 'CopySheet.Module1' -> Wrong call!
      macro_string = 'Module1.CopySheet'
*      script_name  = ''
      no_flush     = ''
    IMPORTING
      error        = lo_error
      retcode      = l_retcode.
Thanks for your help my code are working fine now :o)
Jørgen Jensen

Similar Messages

  • Create an XLS file, ZIP it and Email

    Hi All,
    we have a requirement where in we have to create an XLS file from internal table. This xls file then has to be zipped and mailed.
    The problem is we dont have GUI object. We will be executing this in batch.
    If anyone knows how to create an xls file and zip it in with out having GUI Component please let us know. It will be of great help. Also please let us know if it possible with out using OPEN, CLOSE DATA SET etc,
    Thanks,
    Anand

    You could try using SAP Desktop Office Integration. Within the interfaces i_oi_document_proxy and i_oi_spreadsheet there is a method save_to _url. With that method you can save your generated excel file to the appserver.
    The next challenge is to get the excel file and zip it with the help of class cl_abap_gzip.
    The last challenge is to mail the file. The class cl_bcs could be of help to you.
    Hope it helps you,
    Bert

  • How to convert a Word document to text or html in an ABAP program

    Hi,
    At my client's site, for the recruitment system, they have the word processing system set to RTF, instead of SAP Script. This means that all the correspondence is in Word format. A standard SAP program takes the word letter, loads word, does the mail merge with the applicant's info and then sends the document to a printer.
    The program name is RPAPRT05. The program creates a document proxy (interface I_OI_DOCUMENT_PROXY) and manipulates the document using the methods of the interface.
    Now what we want to do is to instead of sending the document to a printer, we want to email the document contents to the applicant. But I don't know how to get the content from the Word document into text or html format so that I can make an email from it.
    I know I can send an email with the word document as an attachment, but we'd prefer not to do that.
    I would appreciate any help very much.
    Thanks

    Ok, here's what I ended up doing:
    First of, in order to call FM 'CONVERT_RTF_TO_ITF' you need the RTF document in a table with line length 156. The document is returned from FM 'DP_CREATE_URL' in a table with line length 132. So first I convert the table:
        Transform data table from 132 character lines to
        256 character lines
          LOOP AT data_table INTO dataline.
            IF newrow = 'X'.
            Add row to new table
              APPEND INITIAL LINE TO xdatatab ASSIGNING .
              newrow = space.
            ENDIF.
          Convert the raw line of old table to characters
            ASSIGN dataline TO .
          Check line lengths to determine how to add the
          next line of old table
            newlinelen = STRLEN( newline ).
            ADD addspaces TO newlinelen.
            linepos = linemax - newlinelen.
            IF linepos > datalen.
            Enough space available in new table line for all of old table line
              newline+newlinelen = oldline.
              oldlinelen = STRLEN( oldline ).
              addspaces = datalen - oldlinelen.
              CONTINUE.
            ELSE.
            Fill up new table line
              newline+newlinelen(linepos) = oldline(linepos).
              ASSIGN newline TO .
              newrow = 'X'.
            Save the remainder of old table to the new table line
              IF linepos < datalen.
                oldlinelen = STRLEN( oldline ).
                addspaces = datalen - oldlinelen.
                CLEAR newline.
                newline = oldline+linepos.
              ELSE.
                CLEAR newline.
              ENDIF.
            ENDIF.
          ENDLOOP.
        Write the last line to the table
          IF newrow = 'X'.
            APPEND INITIAL LINE TO xdatatab ASSIGNING .
    Next I call FM 'CONVERT_RTF_TO_ITF' to get the document in SAPScript format:
        Convert the RTF format to SAPScript
          CALL FUNCTION 'CONVERT_RTF_TO_ITF'
            EXPORTING
              header            = dochead
              x_datatab         = xdatatab
              x_size            = xsize
            IMPORTING
              with_tab_e        = withtab
            TABLES
              itf_lines         = itf_table
            EXCEPTIONS
              invalid_tabletype = 1
              missing_size      = 2
              OTHERS            = 4.
    This returns the document still containing the mail merge fields which needs to be filled in:
          LOOP AT itf_table INTO itf_line.
            WHILE itf_line CS '«'.
              startpos = sy-fdpos + 1.
              IF itf_line CS '»'.
                tokenlength = sy-fdpos - startpos.
              ENDIF.
              token = itf_line+startpos(tokenlength).
              REPLACE '_' IN token WITH '-'.
              ASSIGN (token) TO .
              ENDIF.
              MODIFY itf_table FROM itf_line.
            ENDWHILE.
          ENDLOOP.
    And finally I use FM 'CONVERT_ITF_TO_ASCII' to convert the SAPScript to text. I set the line lengths to 60, since that's a good length to format emails to.
        Convert document to 60 char wide ascii document for emailing
          CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
            EXPORTING
              formatwidth       = 60
            IMPORTING
              c_datatab         = asciidoctab
              x_size            = documentsize
            TABLES
              itf_lines         = itf_table
            EXCEPTIONS
              invalid_tabletype = 1
              OTHERS            = 2.
    And then the text document gets passed to FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' as the email body.

  • Desktop Office Integration in SAP GUI for HTML - dont works?

    Hello all,
    my program reads an Excel-File with multiple Worksheets into SAP by using class:
    CL_GUI_CUSTOM_CONTAINER
    and intefaces:
    I_OI_CONTAINER_CONTROL,
    I_OI_DOCUMENT_PROXY AND
    I_OI_SPREADSHEET.
    All works fine, but when I integrated the SAP Transaction into our Portal and using the Program through the WEBGUI it dont works.
    It looks like that he can't create a container Control, to open the File in Background in Excel.
    I worked with Desktop Office Integration to read all Worksheets into SAP, like here:
    http://abap-explorer.blogspot.com/2008/12/upload-data-from-multiple-worksheets-of.html
    Is there any solution to solve my problem?
    it returns me this message
    "Cannot initialize control"
    It seems that the error comes from this Method in Webgui:
    Data iref_document    type ref to i_oi_document_proxy.
      call method iref_document->open_document
        exporting
          document_title = 'Excel'
          document_url   = v_document_url
          open_inplace   = 'X'
        importing
          error          = iref_error.
      if iref_error->has_failed = 'X'.
        call method iref_error->raise_message
          exporting
            type = 'I'.
        leave list-processing.
        exit.
      endif.
    I hope someone can help me.
    Thanks.
    EDIT:
    Today I tested the ABAP Report SAPRDEMOOFFICEINTEGRATION in our webgui
    it returns me this error:
         In dem Programm "C_OI_CONTAINER_CONTROL_CREATORCP" wurde durch eine                           
          RAISE-Anweisung die Exception                                                                
         (Ausnahmebedingung) "JAVABEANNOTSUPPORTED" ausgelöst.                                         
         Da die Exception nicht durch ein in der Aufrufhierarchie
    Auslösestelle des Laufzeitfehlers                                                                  
         Programm                                 C_OI_CONTAINER_CONTROL_CREATORCP                      
         Include                                  OFFICEINTEGRATIONDCCIMP                               
         Zeile                                    70                                                    
         Modultyp                                 (METHOD)                                              
         Modulname                                I_OI_CONTAINER_CONTROL~INIT_CONTROL
    Edited by: Sascha Baumann on Jul 15, 2009 9:18 AM
    Edited by: Sascha Baumann on Jul 16, 2009 8:04 AM

    Hi Sascha,
    I have the same issue as yours.
    Did you find a way to open your excel file in the WebGui?
    Regards,

  • Excel file in CRM "WITHOUT TAB LIMITED CONVERSION"

    Hi experts,
      tHIS QUESION HAS BEEN ASKED SO MANY TIMES BUT I COULDNT FIND A SINGLE ANSWER WHICH EXPLAINS UPLOADING WITHOUT CONVERTING THE EXCEL FILE IN TAB LIMITED.
    Can somebody please tell me how to upload an excel file in crm without converting the excel file into tab limited.
    the FM "TEXT_CONVERT_XLS_TO_SAP",
    "ALSM_EXCEL_TO_INTERNAL_TABLE"
    "ALSM_EXCEL_TO_INTERNAL_TABLE"
    ARE NOT ABAILABLE IN CRM 5.0.
    I can use GUI_UPLOAD but i need to convert the excel file to tab limited which i dont want to. So, somebody can please help me out FINDING AN ALTERNATE FUNCTION MODULE.

    Hello,
    The FM TEXT_CONVERT_XLS_TO_SAP use class like I_OI_DOCUMENT_PROXY and I_OI_SPREADSHEET which are avalaible in CRM5.O.
    You can maybe check program SAPRDEMO_TABLES_IN_EXCEL and use it to write your own logic.
    Regards,
    Frederic

  • Clear Custom Control Area

    Hi Experts,
    I am using custom-control to embed an excel file in SAP. The problem is that when I m trying to open another excel file the one opened before still exists. I have debugged the program and found that the code is opening the new excel file but it is hidden behind the one opened before that file. I am using interface I_OI_DOCUMENT_PROXY and method 'OPEN_DOCUMENT' to embed the the excel file. I tried 'CLOSE_DOCUMENT', 'CLEAR_DOCUMENT' & 'CLEAR_SELECTION' methods but of no use.
    Below is the code I am using to embed an excel file into SAP. Hope this will help to understand the problem.
    ******Begin of Code**********************************
      IF NOT firsttime IS INITIAL.
        CLEAR firsttime.
        CLEAR: is_gui_container,
               l_document_url.
        lv_cnt = lv_cnt + 1.
        CALL METHOD c_oi_ole_control_creator=>get_ole_container_control
          IMPORTING
            control = g_control
            retcode = g_retcode.
        CALL METHOD c_oi_errors=>show_message
          EXPORTING
            type = 'E'.
        CREATE OBJECT g_container
          EXPORTING
             container_name = 'CONT1'
          EXCEPTIONS
             cntl_error                  = 1
             cntl_system_error           = 2
             create_error                = 3
             lifetime_error              = 4
             lifetime_dynpro_dynpro_link = 5.
        is_gui_container-application_name = 'Our test'.
        is_gui_container-container_name   = 'CONT1'.
        is_gui_container-rep_id           = sy-repid .
        is_gui_container-dynpro_nr        = '0100'.
        PERFORM pc_has_excel_or_excel2003.
        CALL METHOD g_control->destroy_control.
        CALL METHOD g_control->init_control
          EXPORTING
            r3_application_name      = is_gui_container-application_name
            inplace_enabled          = 'X'
            inplace_scroll_documents = 'X'
            parent                   = g_container
            register_on_close_event  = ' '
            register_on_custom_event = ' '
            rep_id                   = is_gui_container-rep_id
            dynpro_nr                = is_gui_container-dynpro_nr
          IMPORTING
            retcode                  = g_retcode.
        CALL METHOD c_oi_errors=>show_message
          EXPORTING
            type = 'E'.
        CALL METHOD g_control->get_table_collection
          IMPORTING
            table_collection = g_table_coll
            retcode          = g_retcode.
        CALL METHOD g_control->get_document_proxy
          EXPORTING
            document_type  = soi_doctype_excel97_sheet
          IMPORTING
            document_proxy = g_document
            retcode        = g_retcode.
        CALL METHOD c_oi_errors=>show_message
          EXPORTING
            type = 'E'.
        CONCATENATE 'file://' p_file INTO l_document_url.
        CALL METHOD g_document->clear_selection
          EXPORTING
            no_flush = ' '
          IMPORTING
            retcode  = g_retcode.
        CALL METHOD g_document->open_document
          EXPORTING
            document_url = l_document_url
            open_inplace = 'X'
          IMPORTING
            retcode      = g_retcode.
      ENDIF.
    ******End of Code*************************************
    Let me know if you want more details.

    Hi Rajesh,
      Try to Rrefresh that custom control, I had a similar problem with table control then i used the below method to solve that problem.
    set row & column to be stable after refresh
        CLEAR l_s_stable.
        l_s_stable-row = 'X'.
        l_s_stable-col = 'X'.
        CALL METHOD alvgrid->refresh_table_display
          EXPORTING
            is_stable      = l_s_stable
            i_soft_refresh = 'X'..
    if you search you may find out any other similar methods for your requirements..
    Reward with points if usefull..
    Regards,
    Srinivas.

  • Upload excel file in crm

    Hi experts,
    Can somebody please tell me how to upload an excel file in crm without converting the excel file into tab limited.
    the FM "TEXT_CONVERT_XLS_TO_SAP",
           "ALSM_EXCEL_TO_INTERNAL_TABLE"
           "ALSM_EXCEL_TO_INTERNAL_TABLE"
    are not available in CRM 5.0.
    I can use GUI_UPLOAD but i need to convert the excel file to tab limited which i dont want to. So, somebody can please help me out.

    Hello,
    The FM TEXT_CONVERT_XLS_TO_SAP use class like I_OI_DOCUMENT_PROXY and I_OI_SPREADSHEET which are avalaible in CRM5.O.
    You can maybe check program SAPRDEMO_TABLES_IN_EXCEL and use it to write your own logic.
    Regards,
    Frederic

  • Excel by DOI

    Hello
    I want to output a internal table to an excel file.
    Now I open an existing file and write data into it.
    Then I have 2 problems: one is how can I save it without prompt a confirm dialog for overwrite the existing file; the other is now the excel is running backgroud, and I want it to be viewable to the user after all the data is output, how to do?.

    I hope you are using the DOI functionality by the classes, I_OI_DOCUMENT_PROXY and I_OI_SPREADSHEET_INTERFACE.
    Then in such a case
    To save the document without prompting the user
    I_OI_DOCUMENT_PROXY->save_as
         EXPORTING
                   file_name      = file_name
                   prompt_user = prompt_user  " Leave it blank to avoid the Prompt
                   no_flush       = no_flush
         IMPORTING error       = error
                   retcode     = retcode.
    To Display the excel,
    I_OI_DOCUMENT_PROXY->OPEN_DOCUMENT
    EXPORTING
    DOCUMENT_TITLE     =
    DOCUMENT_URL       =
    NO_FLUSH                =
    OPEN_INPLACE         =                " For this you need to create a custom container in the module pool
    OPEN_READONLY    =
    PROTECT_DOCUMENT   =
    ONSAVE_MACRO         =
    STARTUP_MACRO        =
    USER_INFO                   =
    IMPORTING
    ERROR                          =
    RETCODE                      =
    Hope this helps
    Cheers!!
    -Mishra

  • DOI and Script collection/Macro in Word

    Hi experts,
    My goal is to upload macro from file and after upload run this macro inside word document.
    I try to upload macro from file in Script collection using get_script_collection(class I_OI_DOCUMENT_PROXY)  & add_script (class I_OI_SCRIPT_COLLECTION)
    After that I want to execute macro using execute_script(class I_OI_DOCUMENT_PROXY) .
    I always get error when executing macro that some object is missing. Probably macro is not correct written in file.
    Can somebody give me example hove this macro must be written so I can execute him.
    Thanks a lot,
    Drazen

    Hi Drazen Lovrencic ,
    Even I am trying to execute the macro but facing problem. Below is the my code of adding vb script(macro) to the excel spreadsheet and executing it. but stil not working. I am getting error message "Cannot initialize control"
      TYPES:
        TS_SOURCE_CODE  TYPE TEXT1024,
        TT_SOURCE_CODE   TYPE STANDARD TABLE OF TS_SOURCE_CODE WITH DEFAULT KEY.
      TYPES: BEGIN OF TY_SCRIPT,
             VALUE(80) TYPE C,
             END OF TY_SCRIPT.
      DATA: LS_SOURCE_CODE  TYPE TY_SCRIPT,"TS_SOURCE_CODE,
               LT_SOURCE_CODE  TYPE TABLE OF TY_SCRIPT,
               L_RETURN_CODE TYPE SOI_RET_STRING.
    Building the Script - every line has to end with cr/lf
      LS_SOURCE_CODE-VALUE = 'Sub Macro1()'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
       LS_SOURCE_CODE-VALUE = 'ActiveSheet.Buttons.Add(234, 57, 109.5, 29.25).Select'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = 'Selection.OnAction = "button"'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = 'Range("G9").Select'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = 'ActiveSheet.PageSetup.PrintArea = ""'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = 'With ActiveSheet.PageSetup'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = '.Orientation = xlLandscape'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = '.PaperSize = xlPaperA4'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = '.FitToPagesWide = 1'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = '.FitToPagesTall = 1'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = 'End With'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
      LS_SOURCE_CODE-VALUE = 'End Sub'.
      CONCATENATE LS_SOURCE_CODE-VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF
      INTO LS_SOURCE_CODE-VALUE.
      APPEND LS_SOURCE_CODE
               TO LT_SOURCE_CODE.
    BREAK-POINT.
    DATA: L_SCRIPT_COLLECTION TYPE REF TO i_oi_script_collection.
    DATA: table_url(256).
    DATA: DOC_COOKIE TYPE I.
          L_RETURN_CODE = c_oi_errors=>ret_document_not_open.
          CALL METHOD c_oi_errors=>create_error_for_retcode
            EXPORTING
              retcode  = L_RETURN_CODE
              no_flush = ''
            IMPORTING
              error    = gc_error.
    CALL FUNCTION 'DP_CREATE_URL'
          EXPORTING
            type    = ''
            subtype = ''
          TABLES
            data    = LT_SOURCE_CODE
          CHANGING
            url     = table_url.
    DATA: CONTAINER_CONTROL TYPE REF TO C_OI_CONTAINER_CONTROL_PROXY.
    CREATE OBJECT CONTAINER_CONTROL.
        CALL METHOD container_control->add_document_script
          EXPORTING
            NO_FLUSH       = 'X'
            document_cookie = doc_cookie
            script_name     = 'Macro'
            script_type     = '1'
            script_url      = table_url
          IMPORTING
            error           = gc_error.
        APPEND gc_error TO gt_error_table.
    Calling the script:
      CALL METHOD GC_DOCUMENT->EXECUTE_MACRO
        EXPORTING
          MACRO_STRING = 'Macro_demo_1'
          SCRIPT_NAME  = 'Macro'
          NO_FLUSH     = SPACE
       IMPORTING error = gc_error.
    APPEND gc_error TO gt_error_table.

  • I_oi_document_proxy - open_document_from_table

    Hello everybody,
    I would like to show an intern table from ABAP in Excel and afetr change save data in table. I try to use the method
    i_oi_document_proxy ->open_document_from_table but it not woks correct. The data are not correct in columns and rows assigned. Can anybody give me a tip or a link to tutorial?
    Regards
    Bogdan

    Hi Jonathan,
    I have analized the SAPRDEMO_SPREADSHEET_INTERFACE Programm. The transfer of data with use the Interface methode get_ranges_data works fine. But when I try use this method in event handler for close_event it return an error code INTERFACE_NOT_SUPPORTED. I suppose that first the sheet is destroyed und then is event fired (during handlig sheet exist no more).
    regards
    Bogdan

  • Opening an Excel document using I_OI_DOCUMENT_PROXY

    Hi,
    I'm currently opening an Excel document using the OPEN_DOCUMENT method of the I_OI_DOCUMENT_PROXY interface. A macro is then run to populate specified columns in the spreadsheet and then proceeds with printing the document.
    Within Excel, we've set Application.ScreenUpdating = False, which hides the document from the user. When launching the document directly from the local drive (not from SAP), it doesn't get displayed.
    However, calling it from SAP seems to bring up Excel, and it shows the processing of the macro as well as the automatic printing and only then will Excel close.
    My question is, is there anyway we'd be able to run the Excel macro and print the spreadsheet without Excel ever opening at all?
    Thanks and regards,
    Adeline.

    Hi,
    I'm currently opening an Excel document using the OPEN_DOCUMENT method of the I_OI_DOCUMENT_PROXY interface. A macro is then run to populate specified columns in the spreadsheet and then proceeds with printing the document.
    Within Excel, we've set Application.ScreenUpdating = False, which hides the document from the user. When launching the document directly from the local drive (not from SAP), it doesn't get displayed.
    However, calling it from SAP seems to bring up Excel, and it shows the processing of the macro as well as the automatic printing and only then will Excel close.
    My question is, is there anyway we'd be able to run the Excel macro and print the spreadsheet without Excel ever opening at all?
    Thanks and regards,
    Adeline.

  • Modify excel sheet from BDN/GOS and add to sales order

    Hello,
    Iu2019ve import a excel-template in OAOR (BDN) and now i want to modify the excel-sheet with my own data.
    After then I want to put it to a Sales Order (BUS2032).
    The excel sheet must indicated in the attachment list of VA02 (GOS).
    Which method I must use to copy a existing excel sheet from BDN?
    How can i modify my excel sheet from BDS and add to a existing sales order?
    Can I set the document write protected?
    Can anyone help me or have any examplesu2026
    Thanks in advance
    Edited by: Thomas Druetschel on Dec 2, 2008 3:20 PM

    Hello,
    now i can get a template from BDN and modify the excel sheet. But i want to modify the excel spreadsheet in BACKGROUND ==> have anybody a idea?
    And i need the correct method to save the modified document to BDS...
    Thanks
    i use the following code:
    TYPE-POOLS: sbdst.
    DATA go_control TYPE REF TO i_oi_container_control.
    DATA go_docking_container TYPE REF TO cl_gui_docking_container.
    DATA go_document_proxy TYPE REF TO i_oi_document_proxy.
    DATA go_excel_iface TYPE REF TO i_oi_spreadsheet.
    DATA go_error TYPE REF TO i_oi_error.
    DATA gc_exceltype TYPE soi_document_type VALUE soi_doctype_excel_sheet.
    DATA gv_retcode TYPE soi_ret_string.
    DATA gv_sheetname TYPE soi_string.
    DATA gv_inplace TYPE c.
    DATA: gv_value TYPE string.
    START-OF-SELECTION.
      PERFORM open_excel_doc_from_bds
                  USING
                      'BUS2032'
                      'BO'
                      '0010163117'
      PERFORM fill_cell
                  USING
                      'TEST123'
                      '1'
                      '2'.
    ==>> Now i want to SAVE the modified Excel Spreadshet to another Sales Order...
    *&      Form  init_excel_proxy
          text
         -->UV_INPLACE text
    FORM init_excel_proxy USING uv_inplace TYPE c.
      DATA lv_repid TYPE sy-repid.
      DATA lv_dynnr TYPE sy-dynnr.
      DATA lv_str   TYPE soi_string.
      lv_repid = sy-repid.
      lv_dynnr = sy-dynnr.
      CALL METHOD c_oi_container_control_creator=>get_container_control
        IMPORTING
          control = go_control
          error   = go_error.
      CREATE OBJECT go_docking_container
        EXPORTING
          repid     = lv_repid
          dynnr     = lv_dynnr
          side      = cl_gui_docking_container=>dock_at_bottom
          extension = 0.
    I don´t want to modify the document in the front*
      CALL METHOD go_control->init_control
        EXPORTING
          r3_application_name = ' '
          inplace_enabled     = uv_inplace
          parent              = go_docking_container
        IMPORTING
          error               = go_error.
      CALL METHOD go_control->get_document_proxy
        EXPORTING
          document_type  = gc_exceltype
        IMPORTING
          document_proxy = go_document_proxy.
    ENDFORM.                    " init_excel_iface
    *&      Form  open_excel_doc_from_bds
          text
         -->UV_CLASSNAME  text
         -->UV_CLASSTYPE  text
         -->UV_OBJECTKEY  text
         -->UV_INPLACE    text
    FORM open_excel_doc_from_bds USING uv_classname TYPE sbdst_classname
                                       uv_classtype TYPE sbdst_classtype
                                       uv_objectkey TYPE sbdst_object_key
                                       uv_inplace TYPE c.
      DATA lt_doc_uris TYPE sbdst_uri.
      DATA ls_doc_uri LIKE LINE OF lt_doc_uris.
      DATA lt_doc_signature TYPE sbdst_signature.
      DATA lv_doc_url TYPE bapiuri-uri.
      DATA lv_repid TYPE sy-repid.
      DATA lv_dynnr TYPE sy-dynnr.
      IF go_document_proxy IS INITIAL.
        PERFORM init_excel_proxy USING uv_inplace.
      ENDIF.
      CHECK NOT go_document_proxy IS INITIAL.
      CALL METHOD cl_bds_document_set=>get_with_url
        EXPORTING
          classname       = uv_classname
          classtype       = uv_classtype
          object_key      = uv_objectkey
        CHANGING
          uris            = lt_doc_uris[]
          signature       = lt_doc_signature[]
        EXCEPTIONS
          nothing_found   = 1
          error_kpro      = 2
          internal_error  = 3
          parameter_error = 4
          not_authorized  = 5
          not_allowed     = 6.
      IF sy-subrc NE 0 .
        MESSAGE 'cl_bds_document_set=>get_with_url error' TYPE 'I'.
        EXIT.
      ENDIF.
      READ TABLE lt_doc_uris INTO ls_doc_uri INDEX 1.
      lv_doc_url = ls_doc_uri-uri.
      CALL METHOD go_document_proxy->open_document
        EXPORTING
          document_url  = lv_doc_url
          open_inplace  = uv_inplace
          open_readonly = ''
        IMPORTING
          error         = go_error.
      IF NOT go_excel_iface IS INITIAL.
        FREE go_excel_iface.
      ENDIF.
      CALL METHOD go_document_proxy->get_spreadsheet_interface
        EXPORTING
          no_flush        = 'X'
        IMPORTING
          sheet_interface = go_excel_iface
          error           = go_error.
    ENDFORM.                    "open_excel_doc_from_bds
    *&      Form  fill_cell
          text
         -->UV_VALUE   text
         -->UV_COLUMN  text
         -->UV_ROW     text
    FORM fill_cell USING uv_value TYPE string
                         uv_column TYPE i
                         uv_row TYPE i.
      CHECK NOT go_document_proxy IS INITIAL.
      CHECK NOT go_excel_iface IS INITIAL.
      DATA: lt_ranges TYPE soi_range_list,
            lt_contents TYPE soi_generic_table,
            ls_contents LIKE LINE OF lt_contents[],
            lt_rangesdef TYPE soi_dimension_table,
            ls_rangesdef LIKE LINE OF lt_rangesdef.
      ls_rangesdef-row = uv_row.
      ls_rangesdef-column = uv_column.
      ls_rangesdef-rows = 1.
      ls_rangesdef-columns = 1.
      APPEND ls_rangesdef TO lt_rangesdef.
      ls_contents-row = 1.
      ls_contents-column = 1.
      ls_contents-value = uv_value.
      APPEND ls_contents TO lt_contents.
      CALL METHOD go_excel_iface->set_ranges_data
        EXPORTING
          ranges    = lt_ranges[]
          contents  = lt_contents[]
          rangesdef = lt_rangesdef[]
          no_flush  = 'X'
        IMPORTING
          error     = go_error.
    ENDFORM.                    "fill_cell
    *&      Form  get_cell
          text
         -->UV_COLUMN  text
         -->UV_ROW     text
         -->CV_VALUE   text
    FORM get_cell USING  uv_column TYPE i
                         uv_row TYPE i
                  CHANGING cv_value.
      DATA: lt_ranges TYPE soi_range_list,
          lt_contents TYPE soi_generic_table,
          ls_contents LIKE LINE OF lt_contents[],
          lt_rangesdef TYPE soi_dimension_table,
          ls_rangesdef LIKE LINE OF lt_rangesdef.
      ls_rangesdef-row = uv_row.
      ls_rangesdef-column = uv_column .
      ls_rangesdef-rows = 1.
      ls_rangesdef-columns = 1.
      APPEND ls_rangesdef TO lt_rangesdef.
      CALL METHOD go_excel_iface->get_ranges_data
        EXPORTING
          rangesdef = lt_rangesdef[]
        IMPORTING
          contents  = lt_contents[]
          error     = go_error
        CHANGING
          ranges    = lt_ranges[].
      cv_value = space.
      READ TABLE lt_contents INTO ls_contents INDEX 1.
      IF sy-subrc = 0.
        cv_value = ls_contents-value.
      ENDIF.
    ENDFORM.                    "get_cell
    *&      Form  insert_table
          text
         -->COLUMN     text
         -->ROW        text
         -->CT_DATA    text
         -->ANY        text
    FORM insert_table USING column TYPE i
                            row TYPE i
                      CHANGING ct_data TYPE table any.
      CHECK NOT go_document_proxy IS INITIAL.
      CHECK NOT go_excel_iface IS INITIAL.
      CALL METHOD go_excel_iface->insert_range_dim
        EXPORTING
          name     = 'Table'
          top      = row
          left     = column
          rows     = 1
          columns  = 1
          no_flush = 'X'
        IMPORTING
          error    = go_error.
      DATA: lt_fields_table TYPE soi_fields_table.
      CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
        TABLES
          data   = ct_data[]
          fields = lt_fields_table.
      go_excel_iface->insert_one_table(
        EXPORTING
          data_table   = ct_data[]
          fields_table = lt_fields_table[]
          rangename    = 'Table'
          no_flush     = 'X'
          wholetable   = 'X'
        IMPORTING
          error        = go_error
    ENDFORM.                    "insert_table=

  • Openig Word document and storing Data into Internal Table.

    Hi Everybody,
    I require one solution.
    Can anybody help in the following.
    When i click on  a pushbutton a Word document should get open.
    I will type in it the following text "Hi from chetan".
    I want the above text to be stored in Internal table.
    Problem is that when is use method
    "i_oi_document_proxy-save_document_to_table"
    data is store in Raw format.
    Please any body give me demo program .Its very urgent.
    Thanks in advance.
    Chetan

    Hi ,
    Please find the code below.
    Click 'Open Word' button to open the word.
    Save the file and close.
    Click upload button to upload to Internal table.
    Click execute button to display.
    REPORT ZWSTEST.
    TABLES sscrfields.
    DATA: BEGIN OF ITAB OCCURS 3,
          LINE(50),
          END OF ITAB.
    PARAMETERS: PROG(70) DEFAULT
                'C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE'.
    PARAMETERS: FILE1(70) DEFAULT 'C:\TEST.TXT'.
    Tick to print the Text file after saving from MS WORDS
    *PARAMETERS: S_UP  AS CHECKBOX.
    Tick to create new or overwrite Text file
    *PARAMETERS: S_NEW AS CHECKBOX.
    selection-screen : begin of block b1 with frame no intervals.
    selection-screen : begin of line.
    selection-screen : pushbutton 2(10) Button1 user-command cbut.
    selection-screen : pushbutton 14(10) Button2 user-command cbut1.
    selection-screen : end of line.
    selection-screen end of block b1.
    initialization.
    Button1 = 'Open Word File'.
    Button2 = 'Upload'.
    AT SELECTION-SCREEN.
    IF sscrfields-ucomm = 'CBUT'.
    CALL FUNCTION 'WS_EXECUTE'
      EXPORTING
         PROGRAM       = PROG
         COMMANDLINE   = 'FILE1'
         INFORM        = ' '
      EXCEPTIONS
         FRONTEND_ERROR           = 1
         NO_BATCH                 = 2
         PROG_NOT_FOUND           = 3
         ILLEGAL_OPTION           = 4
         GUI_REFUSE_EXECUTE       = 5
         OTHERS                   = 6.
    endif.
    if sscrfields-ucomm = 'CBUT1'.
       CALL FUNCTION 'GUI_UPLOAD'
            EXPORTING
                 FILENAME        = 'FILE1'
            TABLES
                 DATA_TAB        = ITAB
            EXCEPTIONS
                 FILE_OPEN_ERROR = 1.
       IF SY-SUBRC <> 0.
           WRITE: / 'File open error.'.
       ENDIF.
    endif.
    CASE SY-SUBRC.
       WHEN 1.
         WRITE: / 'FRONTEND ERROR'.
       WHEN 2.
         WRITE: / 'NO BATCH'.
       WHEN 3.
         WRITE: / 'PROGRAM NOT FOUND'.
       WHEN 4.
         WRITE: / 'ILLEGA OPTION'.
       WHEN 5.
         WRITE: / 'GUI REFUSE EXECUTE'.
       WHEN 6.
         WRITE: / 'OTHERS'.
    ENDCASE.
    Start-of-selection.
    LOOP AT ITAB.
      WRITE: / ITAB.
    ENDLOOP.
    Best Regards
    Suresh

  • Excel opens and does not close when using the OI classes for some users...

    Hello Experts,
    I am using the OI classes(i_oi_container_control, i_oi_error, i_oi_document_proxy, i_oi_spreadsheet) to transfer Excel data to my itab. The problem we are encountering is that for some users the excel automatically opens and does not close. But in my case it is not opening so it is fine in my case. In my code I am already using the 'CLOSE_DOCUMENT' and 'RELEASE_DOCUMENT'.

    Viraylab,
    Check by any case you set the parameter register_on_close_event of the method init_control? Dont set the parameter as it will look for the corressponding custom code in your program. Also try with the method release_all_documents.
    Regards,
    Kiran Bobbala

  • A problem with Threads and loops.

    Hi, I have some code that needs to be constantly running, like while(true)
          //code here
    }However, the code just checks to see if the user has input anything (and then if the user has, it goes to do some other stuff) so I don't need it constantly running and hogging up 98% of the CPU. So I made my class (which has the method that needs to be looped, call it ClassA) implement Runnable. Then I just added the method which needed to be looped into the public void run()
    I have another class which creates an instance of the above class (call it ClassB), and the main(String[] args) is in there.
    public static void main(String[] args)
              ClassA test = new ClassA();
              Thread thread = new Thread(test.getInstanceOfClassA());
              thread.start();
              while(true)
                           //I do not know what to put here
                   try
                        thread.sleep(100);
                   catch(InterruptedException iex)
         }However, the thread only calls run() once,(duh...) but I can't think of away to get it to run - sleep - run -sleep forever. Can someone help me?

    Hi, I have some code that needs to be constantly
    running, like while(true)
    //code here
    }However, the code just checks to see if the user has
    input anything (and then if the user has, it goes to
    do some other stuff) so I don't need it constantly
    running and hogging up 98% of the CPU. Where does the user input come from. Are you reading from an InputStream? If so, then your loop will be blocked anyway when reading from the InputStream until data is available. During that time, the loop will not consume processor cycles.
    public static void main(String[] args)
              ClassA test = new ClassA();
    Thread thread = new Thread(test.getInstanceOfClassA());I have never seen this idiom. If ClassA instanceof Runnable, you simply write new Thread(test).
              thread.start();
              while(true)
    //I do not know what to put
    do not know what to put here
                   try
                        thread.sleep(100);
                   catch(InterruptedException iex)
         }However, the thread only calls run() once,(duh...)Yeah, why would you want to call it more than once given that you have an infinite loop in ClassA.run()?
    Harald.
    Java Text Crunching: http://www.ebi.ac.uk/Rebholz-srv/whatizit/software

Maybe you are looking for

  • Calling Webservice from Netweaver Portal to SAP XMII 12.0 using SSO

    Hello, we have a Netweaver 2004s based Portal and a Netweaver-based SAP XMII (v12.0) System providing Webservices. What we try to do is to call a webservice out of the Portal EAR Application using SSO. SSO-Konfiguration between Portal and XMII is don

  • Using javascript to read bex variables in WAD

    Hello, I'm using BI 7.0. In Query Designer I defined a variable of type customer exit. The variable is called "TESTVAR". How can I access to the value of this variable in WAD by using javascript? I know I can use the Web Item "Script" or I can includ

  • .Mac 'Personal Domain' and Aperture Galleries?

    hi all. I have a personal domain www.gregory.hk and I've arranged with my DNS guys to set up a subdomain gallery.gregory.hk with the CNAME pointing to web.mac.com I'm getting two impressions from searches I've done on Apple: 1. personal domains only

  • GW Interface Questions

    We are looking for direction regarding communicating with Groupwise 7 for the purpose of generating 'Tasks', 'Alerts' and E-mail messages to individuals and groups. It has been suggested that communicating with the Groupwise Gateway API or SOAP would

  • Reg:business packages updation

    Hi all If ESS MSS 1.3 Business Package is deployed in development Again ESS MSS 1.4 is need to deploy so whether will it be override or will it take separate location where it will store in portal side .please share your experience or knowledge on th