CRM IC Inbox - Excel Download in background mode

Hi Gurus
I have requirement,
In the result list of the Inbox , we have an icon - Excel which downloads the results to excel sheet. Now we will have execute this in background mode and send a mail once the job is completed.
Could me please let me know how to proceed.
Thanks
Rakesh

You be able to use the function "WS_DONLOAD" ?
parameters: p_fnam like  rlgrap-filename memory id fnam obligatory.
data: begin of t_registro occurs 0,
        registro(1000),
      end of t_registro.
      describe table t_registro lines sy-tfill.
      if sy-tfill gt 0.
        l_tam = strlen( p_fnam ).
        call function 'WS_DOWNLOAD'
             exporting
                  filename                = p_fnam
             tables
                  data_tab                = t_registro
             exceptions
                  file_open_error
                  file_write_error
                  invalid_filesize
                  invalid_type
                  no_batch
                  unknown_error
                  invalid_table_width
                  gui_refuse_filetransfer
                  customer_error.
        if sy-subrc <> 0.
          open dataset p_fnam for output in text mode.
          if sy-subrc = 0.
            loop at t_registro.
              transfer t_registro to p_fnam.
            endloop.
            close dataset p_fnam.
            write:/ 'Se genero el archivo:', p_fnam(l_tam).
          else.
            write:/ 'No se pudo generar el archivo:', p_fnam(l_tam).
          endif.
          close dataset p_fnam.
        else.
          write:/ 'Se genero el archivo:', p_fnam(l_tam).
        endif.
   endif.
I hope this works for you.
See ya.
Ar@

Similar Messages

  • Download an excel file in background mode

    Hi All,
    I need to download a file from a ABAP  report to the local workstation in background mode. I tried GUI_DOWNLOAD but it is failing in the background.
    Is there any way to download the excel file in the background. I am thinking of generating the spool.
    Please let me know if anybody has worked on the same requirement. Any help would be highly appreciated.
    Thanks a lot.
    Regards,
    Priti

    You be able to use the function "WS_DONLOAD" ?
    parameters: p_fnam like  rlgrap-filename memory id fnam obligatory.
    data: begin of t_registro occurs 0,
            registro(1000),
          end of t_registro.
          describe table t_registro lines sy-tfill.
          if sy-tfill gt 0.
            l_tam = strlen( p_fnam ).
            call function 'WS_DOWNLOAD'
                 exporting
                      filename                = p_fnam
                 tables
                      data_tab                = t_registro
                 exceptions
                      file_open_error
                      file_write_error
                      invalid_filesize
                      invalid_type
                      no_batch
                      unknown_error
                      invalid_table_width
                      gui_refuse_filetransfer
                      customer_error.
            if sy-subrc <> 0.
              open dataset p_fnam for output in text mode.
              if sy-subrc = 0.
                loop at t_registro.
                  transfer t_registro to p_fnam.
                endloop.
                close dataset p_fnam.
                write:/ 'Se genero el archivo:', p_fnam(l_tam).
              else.
                write:/ 'No se pudo generar el archivo:', p_fnam(l_tam).
              endif.
              close dataset p_fnam.
            else.
              write:/ 'Se genero el archivo:', p_fnam(l_tam).
            endif.
       endif.
    I hope this works for you.
    See ya.
    Ar@

  • How to upload a Excel document in background mode

    Hello there, how are you?
    I am doing an interface program that needs to upload an excel document into an internal table, to do this I used the FM ALSM_EXCEL_TO_INTERNAL_TABLE. The problem with this FM is that only works in foregroung mode, If I run the programin bcakground the FM does not work.
    I would like to know if exist a way to upload an excel document into an internal table, for a program that have to be execute in background mode.
    Thanks in advance
    Best Regards
    Alexis Ramirez

    *& Form application_server
    * text
    * --> p1 text
    * <-- p2 text
    *----------------------------------------------------------------------*FORM APPLICATION_SERVER .
    TYPE-POOLS: KCDE.
    DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.*DATA : INTERN1 TYPE KCDE_INTERN.FILE = PATH.
    OPEN DATASET FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.**--- Display error messages if any.IF SY-SUBRC NE 0.
    MESSAGE E001(ZSD_MES).
    EXIT.* ENDIF.ELSE.
    DO.
    READ DATASET FILE INTO Wa_TAB.
    append wa_tab to IT_TAB.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ENDDO.
    clear wa_TAB.
    LOOP AT IT_TAB into wa_tab.
    CASE wa_tab-COL.
    WHEN '0001'.
    WA_TAB2-PLANT = wa_tab-VALUE.
    WHEN '0002'.
    WA_TAB2-STGE_LOC = wa_tab-VALUE.
    WHEN '0003'.
    WA_TAB2-MATERIAL = wa_tab-VALUE.
    WHEN '0004'.
    WA_TAB2-QUANTITY = wa_tab-VALUE.
    WHEN '0005'.
    WA_TAB2-BASE_UOM = wa_tab-VALUE.
    WHEN '0006'.
    WA_TAB2-COSTCENTER = wa_tab-VALUE.
    ENDCASE.
    AT END OF ROW.
    APPEND WA_TAB2 TO IT_TAB2.
    CLEAR WA_TAB2.
    ENDAT.
    clear wa_tab.
    ENDLOOP.
    ENDIF.
    CLOSE DATASET FILE.
    ENDFORM. " application_server
    Refer here:[How to Read Excel file from Application or Presentation Server and Download into Internal Table. |https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/how%252bto%252bread%252bexcel%252bfile%252bfrom%252bapplication%252bor%252bpresentation%252bserver%252band%252bdownload%252binto%252binternal%252btable.]

  • File download in Background mode

    Hi All,
    A file need to be downloaded to the folder
    dc20\nt71data\jsox\" while execution in background mode.
    It is also mentioned that the file need not be sent to the application server.
    I am sure in background mode file couldn't be downloaded to the presentation server.
    Can you please predict where would be this folder and how to proceed?
    Thanks & Regards,
    Lakshmanan

    hi,
    Please check in AL11 transaction.Where you will find the list of folders in Application server.
    Regards,
    Shan

  • Urget::How to download in excel format  in Background

    hi,
            i was using GUI_DOWNLOAD  in a program to download into excel format. but now the user wants to run this in background mode .But gui_download doesn't support the background .can u suggest me any other way to download in background mode into excel format.
    it's urgent .please help.
    Thanks in advance .

    Hi Rasmi,
    In background you can only download it to application server and not on your PC.
    If its ok then you can use OPEN DATASET....CLOSE DATASET to do that.
    Once its downloaded to Application server you can download that into your PC.
    Hope This helps you.
    Thanks,
    Arun

  • Download DMS attachment into an application server in background mode?

    Is it possible to download DMS attachment into an application server in background mode?
    Currently I am using the following code but does not work in background mode
      CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
        EXPORTING
          pf_dokar     = 'Z06'
          pf_doknr     = gs_drad-doknr
          pf_dokvr     = gs_drad-dokvr
          pf_doktl      = gs_drad-doktl
          pf_read_kpro = 'X'
        TABLES
          pt_files      = lt_file
        EXCEPTIONS
          not_found    = 1
          no_auth       = 2
          error            = 3
          OTHERS       = 4.
    *Copy Attachment from DMS to PC File
      CALL FUNCTION 'CVAPI_DOC_VIEW'
        EXPORTING
          pf_dokar      = 'Z06'
          pf_doknr      = gs_drad-doknr
          pf_dokvr       = gs_drad-dokvr
          pf_doktl          = gs_drad-doktl
          pf_appl_start = ' '
          pf_apptp      = '1'
          pf_filename   = 'C:\TEMP\ZLINK.BMP'
          ps_file       = ls_file
        IMPORTING
          pfx_file      = l_pfx_file
        EXCEPTIONS
          OTHERS        = 0.
    *Load BMP into SE78
      PERFORM import_bitmap_bds
        IN PROGRAM saplstxbitmaps
        USING l_filename             "Local File for Upload/Download
                   l_bmpnam             "Name
                  'GRAPHICS'           "Application Object
                  'BMAP'                   "ID
                  'BCOL'                   "Color
                  'BMP'                     "Extension
                  'ZLINK PICTURE'   "Title
                  space          "Resides in Printer Memory in Print Request
                 'X'                 "Reserve Height of Graphic Automatically
                 space           "Graphic Storage: Compressed Bitmaps
        CHANGING l_docid
               l_wf_res.   "Graphic Resolution
    Thanks

    Hi!
    You didn't find answer for this, because it is not possible. If you run your program in background, it is running on the server, and does not have any connection to your local machine. That's why you can't upload/download in background mode.
    You might try to address somehow your local PC, with its IP or MAC address, but I don't think does this task worth so much time.
    Run your program in online mode, or if you want to run it in background, then upload your file into the SAP server.
    Regards
    Tamá

  • XLS from Application server in background mode to internal table

    Hi,
    I need to transfer the content of an excel file in the application server to an internal table while running my program in background. My file is xls, cant use csv. For dataset bin mode, I need to know how to transfer the data to my internal table, already searched on forum but didnt find answer, at least not for background..
    ow, I am using v6 here
    about the ALSM_EXCEL_TO_INTERNAL_TABLE, I get the upload_ole error all the time, and with TEXT_CONVERT_XLS_TO_SAP, conversion_failed all the time too...
    here is the code, just the load part and data declaration:
    REPORT zbeto.
    TYPE-POOLS: truxs.
    TYPES:
    BEGIN OF y_cot,
    text1(12) TYPE c,
    text2(12) TYPE c,
    text3(12) TYPE c,
    text4(12) TYPE c,
    text5(12) TYPE c,
    END OF y_cot.
    DATA: it_datatab TYPE STANDARD TABLE OF y_cot,
    wa_datatab TYPE y_cot,
    it_raw TYPE truxs_t_text_data.
    DATA:
    v_file TYPE rlgrap-filename,
    begin_col TYPE i VALUE '1',
    begin_row TYPE i VALUE '2',
    end_col TYPE i VALUE '5',
    end_row TYPE i VALUE '102',
    t_ctmp TYPE y_cot OCCURS 0 WITH HEADER LINE,
    t_xls TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    START-OF-SELECTION.
    PERFORM f_load_xls.
    FORM : f_load_xls
    FORM f_load_xls.
    v_file = '
    ZSAPDEV\SAPDEVINTERF$\COTACAO\TESTE.XLS'.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    filename = v_file
    i_begin_col = begin_col
    i_begin_row = begin_row
    i_end_col = end_col
    i_end_row = end_row
    TABLES
    intern = t_xls
    EXCEPTIONS
    inconsistent_parameters = 1
    upload_ole = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    I_FIELD_SEPERATOR =
    i_line_header = 'X'
    i_tab_raw_data = it_raw " WORK TABLE
    i_filename = v_file
    TABLES
    i_tab_converted_data = it_datatab[] "ACTUAL DATA
    EXCEPTIONS
    conversion_failed = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    t_ctmp[] = it_datatab[].
    ENDFORM. "f_load_xls
    both FM arent working, and when I try to execute in background mode, before anything, I recieve the following error:
    Message text:
    Error during import of clipboard contents
    Message class:
    ALSMEX
    Message no.:
    037
    Message type:
    A
    and without the ASLM FM, the TEXT_CONVERT give me the conversion_failed exception...
    the directories are right, that I am sure, because I just copy&paste it from CG3Z/CG3Y when I uploaded and downloaded to
    check the file in the server...
    am I missing something?
    thanks again,
    Roberto Macedo
    (PS: I made another topic because none replied the other in 4 days and wasnt solved yet)

    Hi!
    You didn't find answer for this, because it is not possible. If you run your program in background, it is running on the server, and does not have any connection to your local machine. That's why you can't upload/download in background mode.
    You might try to address somehow your local PC, with its IP or MAC address, but I don't think does this task worth so much time.
    Run your program in online mode, or if you want to run it in background, then upload your file into the SAP server.
    Regards
    Tamá

  • Download to Excel In the Background

    Hi,
    Our SAP server is in Windows operating system. Is it possible to download data in Excel file in the background mode?
    Thanks
    Lokman

    1) One way is, using GUI_DOWNLOAD from your program and haedcoding the path to which it should be downloaded.
    2) Check the link below for downloading excel in background... A demo program is also available.
    http://www.sap-img.com/abap/download-in-background-in-excel-format.htm
    Cheers,
    Thomas.
    Please mark points if you got solution.

  • Uploading Excel File in SAP In Background Mode

    Dear All,
    We require to upload Excel File in SAP in Background Mode.
    Could anyone suggest me the Function Module for this?
    Or any other method..........please.
    Thanks in advance for ur kind help.
    Best Regards,
    Prasad

    hi check this..
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2
    Download in Background
    http://sapabap.iespana.es/sap/info/rfcexec/rfcexec_e.htm
    Reward if find useful

  • Download business document (T-code: OAOR) in background mode

    I have attached a file to a production order and it is saved as a business document. From t-code OAOR (business document navigator), I can view the attachment (or directly from the production order).
    I would like to download the attachment in background mode. Up to now, I only find a method export_attachment in the ABAP object cl_gos_document_service which can download the attachment in frontend.
    Is there any ABAP object / FM which can cater this? Or please kindly suggest what can I do in order to achieve this. Your help is greatly appreciatedly. Thanks!
    Below is the material that I can find in this forum
    Re: Sales Order Attachment

    check out this weblog.
    /people/rammanohar.tiwari/blog/2006/03/25/generic-object-services-gos--in-background--part-ii
    this for loading gos documents in background (not downloading) but should give you a pointer on how to go about it.
    Regards
    Raja

  • Download ALV result list as excel-file in background job

    Dear Experts,
    I am looking for a possibily to download the result of an ALV based report as excel-file in a background job. Surely there is a standard function which can be used or at least some hints how to implement this. I searched the forum but couldn't find a thread which was covering this problem exactly.
    Thanks in advance
    Benjamin

    Dear Mr. Krapf,
    it is possible to output an ALV list to an Excel file in the background but there are some limitations.
    Please consider the following notes:
    #7925  Graphics, Upload, Download do not work in backgrnd
    #65050 Data types and file formats in files (DATASET) 
    #145073 - FAQ Report Writer: Excel download 
    #569537 - Incorrect data during import into Excel
    #590126  Sending CSV documents up to Release 4.6
    Please be aware that they are all Basis notes. So for more information you might ask in the Basis SDN Forum.
    Best regards, Christin Angus

  • 'REUSE_ALV_GRID_DISPLAY' Excel-download without dialog

    Hi everybody,
    we have a couple of reports displayed in dialog mode by using FM 'REUSE_ALV_GRID_DISPLAY'.
    Now the question arose if there might be a possibility to perform an Excel-download NOT by pressing the dialog function button but instead with parameters such as path and filename given by the calling program, without any user-interaction, maybe even without having the report started in dialog but in batch/background mode instead. I don't see a solution to this. Does anybody else?
    regards
    Andreas

    basically what you are saying is that as soon as the user executes the program, the output also should get downloaded to a predefined location in the user PC, without any further user interaction.
    Right? if yes
    you have the data in an itab (which is passed to T_OUTTAB tables parameter)
    in the PBO (immediately after filling the itab with data before calling the function 'REUSE_ALV_GRID_DISPLAY'
    call gui_download and pass filename, and the itab.
    but you have to make sure thru a check to see this download happens only once during a session.
    and this wont work in batchmode.
    REgards
    Raja

  • Create an Excel File in background

    Ladies and Gentlemen,
    I have a requirement to create an Excel file in a program that will only be executed in background mode.  This automatically rules out GUI_DOWNLOAD or any download funtion that presents the file on the presentation server.
    I think that the 'Open Dataset...' command will work to create the file on the Application server, but this seems a bit archaic to me.  Is there another way of creating the excel file on the application server in background?  I am working on a 4.7 system at the moment, but this is scheduled for a upgrade to ECC6 sometime in the next 12 months, so I'm after a process that will be valid both before and after the upgrade.
    Cheers,
    Steve

    Hi Stephen,
    Use Open dataset, Transfer, Close dataset to create file on Application server.
    Use FM Z_CONV_ITAB_TO_TAB_DELIMITED to convert your lines in TAB delimited format. you can download file from your application server to presentation server using T Code CG3Y and give extension as .xls ...
    As you data is Tab delimited it will automatically get formatted in columns in your EXCEL file.
    Regards,
    Mohaiyuddin

  • Reagrding Excel download

    Hi,
    I have a query reagrding Excel download. Is it possible to download an Excel from SAP GUI in background using GUI_DOWNLOAD/WS_DOWNLOAD/DOWNLOAD?.
    Please let me know any alternatives for my situation.
    Thanks in advance
    Ravi.

    hi,
    <b>reward if useful</b>
    <b>GUI_* and WS_* function modules do not work in background</b>
    When scheduling a job in the background the appropriate statement to read in your file is OPEN DATASET, and the file must be on the file system that the SAP server can see.
    At anytime, a user can switch of the Personal Computers even though the job is still running in the background.  Therefore GUI_* and WS_* function modules are not designed to work in that way, as they need to access your personal computer  file.
    Download in Background in Excel Format
    How to download the data in excel format directly while executing in background mode? 
    If you will execute it in bacground with ws_download or download, it will be aoutomatically cancel. so what is the procedure to do this.  How is can directly read the spool from program?
    <b>Download from background is possible, if you could setup the environment</b>
    1. create a custom table first
        Table  : Y001
        Displayed fields:   4 of   4  Fixed columns:
           MANDT BNAME       Y_SITE    Y_PATH
           010      <userid>     <site>      cd <novell_path>
    2. rewrite ws_download to z_download (light modification required, see attachment)
    3. ask your basis team to make a copy of command FTP and CHMOD to ZFTP and ZCHMOD resp., make the setting according to your environment.
        1  *----
        2  * Changed By :
        3  * Changed On :
        4  * Changed    : NOVELL directory path based on SAP login id.
        5  *----
        6  TABLES: Y001.                                           
        7
        8  CONSTANTS: C_PATH(14) VALUE '/home/ftpuser/'.
        9
       10  DATA: BEGIN OF C_TAB,
       11          X(1) TYPE X VALUE '09',
       12        END OF C_TAB.
       13
       14  DATA: BUFFER(8000),
       15        FIELDNAME_OFFSET TYPE I,
       16  *     FULLPATH(128),
       17        FULLPATH LIKE SXPGCOLIST-PARAMETERS,
       18  *     CMDFULLPATH(128),
       19        CMDFULLPATH LIKE SXPGCOLIST-PARAMETERS,
       20        CMD(40),
       21        IBTCXPM LIKE BTCXPM OCCURS 0.
       22
       23  FUNCTION Z_DOWNLOAD.
       24  *"----
       25  ""Local interface:
       26  *"  IMPORTING
       27  *"     VALUE(FILENAME)
       28  *"     VALUE(LOCATION)
       29  *"  TABLES
       30  *"      DATA_TAB
       31  *"      FIELDNAMES OPTIONAL
       32  *"----
       33
       34    DATA: WS_LINE TYPE I.
       35
       36    FIELD-SYMBOLS: <F>.
       37
       38    CHECK NOT FILENAME IS INITIAL.
       39
       40    CONCATENATE C_PATH FILENAME INTO FULLPATH.
       41    OPEN DATASET FULLPATH IN TEXT MODE FOR OUTPUT.
       42
       43    DESCRIBE TABLE FIELDNAMES LINES WS_LINE.
       44    IF WS_LINE NE 0.
       45      PERFORM FIELDNAMES_2_BUFFER TABLES FIELDNAMES CHANGING BUFFER.
       46      FIELDNAME_OFFSET = STRLEN( BUFFER ).
       47      TRANSFER BUFFER TO FULLPATH LENGTH FIELDNAME_OFFSET.
       48    ENDIF.
       49
       50    LOOP AT DATA_TAB.
       51      CLEAR BUFFER.
       52      CLEAR FIELDNAME_OFFSET.
       53      DO.
       54        ASSIGN COMPONENT SY-INDEX OF STRUCTURE DATA_TAB TO <F>.
       55        IF SY-SUBRC NE 0.  EXIT.  ENDIF.
       56        WRITE <F> TO BUFFER+FIELDNAME_OFFSET.
       57        CONDENSE BUFFER.
       58        FIELDNAME_OFFSET = STRLEN( BUFFER ).
       59        WRITE C_TAB TO BUFFER+FIELDNAME_OFFSET(1).
       60        ADD 1 TO FIELDNAME_OFFSET.
       61      ENDDO.
       62      TRANSFER BUFFER TO FULLPATH LENGTH FIELDNAME_OFFSET.
       63    ENDLOOP.
       64
       65    CLOSE DATASET FULLPATH.
       66
       67    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
       68         EXPORTING
       69              COMMANDNAME                   = 'ZCHMOD'
       70              ADDITIONAL_PARAMETERS         = FULLPATH
       71         TABLES
       72              EXEC_PROTOCOL                 = IBTCXPM
       73         EXCEPTIONS
       74              NO_PERMISSION                 = 1
       75              COMMAND_NOT_FOUND             = 2
       76              PARAMETERS_TOO_LONG           = 3
       77              SECURITY_RISK                 = 4
       78              WRONG_CHECK_CALL_INTERFACE    = 5
       79              PROGRAM_START_ERROR           = 6
       80              PROGRAM_TERMINATION_ERROR     = 7
       81              X_ERROR                       = 8
       82              PARAMETER_EXPECTED            = 9
       83              TOO_MANY_PARAMETERS           = 10
       84              ILLEGAL_COMMAND               = 11
       85              WRONG_ASYNCHRONOUS_PARAMETERS = 12
       86              CANT_ENQ_TBTCO_ENTRY          = 13
       87              JOBCOUNT_GENERATION_ERROR     = 14
       88              OTHERS                        = 15.
       89
       90    CONCATENATE C_PATH FILENAME '_cmd' INTO CMDFULLPATH.
       91    OPEN DATASET CMDFULLPATH IN TEXT MODE FOR OUTPUT.
       92    CASE LOCATION.     "location A, B, C, D on a network
       93      WHEN 'A  '.
       94 
       95        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.        
       96        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.      
       97      WHEN 'B  '.                                           
       98        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.        
       99        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.    
      100      when 'C  '.
      101        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.
      102        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.
      103      when 'D  '.
      104        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.
      105        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.
      106      WHEN OTHERS.
      107    ENDCASE.
      108
      109
      110
      111
      112  *start>
      113    CLEAR Y001.
      114    SELECT SINGLE Y_PATH INTO Y001-Y_PATH
      115                         FROM Y001 WHERE BNAME = SY-UNAME
      116                                     AND Y_SITE = LOCATION.  
      117    TRANSFER Y001-Y_PATH TO CMDFULLPATH.
      118  *<end
      119    CONCATENATE 'lcd' C_PATH INTO CMD SEPARATED BY SPACE.
      120    TRANSFER CMD TO CMDFULLPATH.
      121    CLEAR CMD.
      122    CONCATENATE 'put' FILENAME INTO CMD SEPARATED BY SPACE.
      123    TRANSFER CMD TO CMDFULLPATH.
      124    TRANSFER 'bye' TO CMDFULLPATH.
      125    CLOSE DATASET CMDFULLPATH.
      126
      127    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
      128         EXPORTING
      129              COMMANDNAME                   = 'ZCHMOD'
      130              ADDITIONAL_PARAMETERS         = CMDFULLPATH
      131         TABLES
      132              EXEC_PROTOCOL                 = IBTCXPM
      133         EXCEPTIONS
      134              NO_PERMISSION                 = 1
      135              COMMAND_NOT_FOUND             = 2
      136              PARAMETERS_TOO_LONG           = 3
      137              SECURITY_RISK                 = 4
      138              WRONG_CHECK_CALL_INTERFACE    = 5
      139              PROGRAM_START_ERROR           = 6
      140              PROGRAM_TERMINATION_ERROR     = 7
      141              X_ERROR                       = 8
      142              PARAMETER_EXPECTED            = 9
      143              TOO_MANY_PARAMETERS           = 10
      144              ILLEGAL_COMMAND               = 11
      145              WRONG_ASYNCHRONOUS_PARAMETERS = 12
      146              CANT_ENQ_TBTCO_ENTRY          = 13
      147              JOBCOUNT_GENERATION_ERROR     = 14
      148              OTHERS                        = 15.
      149
      150    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
      151         EXPORTING
      152              COMMANDNAME                   = 'ZFTP'
      153  **          commandname                   = 'ZFTP'
      154              ADDITIONAL_PARAMETERS         = CMDFULLPATH
      155         TABLES
      156              EXEC_PROTOCOL                 = IBTCXPM
      157         EXCEPTIONS
      158              NO_PERMISSION                 = 1
      159              COMMAND_NOT_FOUND             = 2
      160              PARAMETERS_TOO_LONG           = 3
      161              SECURITY_RISK                 = 4
      162              WRONG_CHECK_CALL_INTERFACE    = 5
      163              PROGRAM_START_ERROR           = 6
      164              PROGRAM_TERMINATION_ERROR     = 7
      165              X_ERROR                       = 8
      166              PARAMETER_EXPECTED            = 9
      167              TOO_MANY_PARAMETERS           = 10
      168              ILLEGAL_COMMAND               = 11
      169              WRONG_ASYNCHRONOUS_PARAMETERS = 12
      170              CANT_ENQ_TBTCO_ENTRY          = 13
      171              JOBCOUNT_GENERATION_ERROR     = 14
      172              OTHERS                        = 15.
      173
      174  ENDFUNCTION.
      175
      176  ----
      177  *       FORM FIELDNAMES_2_BUFFER                                      *
      178  ----
      179  *       ........                                                      *
      180  ----
      181  *  -->  FIELDNAMES                                                    *
      182  *  -->  BUFFER                                                        *
      183  ----
      184  FORM FIELDNAMES_2_BUFFER TABLES FIELDNAMES CHANGING BUFFER.
      185    CLEAR BUFFER.
      186    CLEAR FIELDNAME_OFFSET.
      187    LOOP AT FIELDNAMES.
      188      WRITE FIELDNAMES TO BUFFER+FIELDNAME_OFFSET.
      189      CONDENSE BUFFER.
      190      FIELDNAME_OFFSET = STRLEN( BUFFER ).
      191      WRITE C_TAB TO BUFFER+FIELDNAME_OFFSET(1).
      192      ADD 1 TO FIELDNAME_OFFSET.
      193    ENDLOOP.
      194    FIELDNAME_OFFSET = FIELDNAME_OFFSET - 1.
      195    IF FIELDNAME_OFFSET >= 0.
      196      WRITE SPACE TO BUFFER+FIELDNAME_OFFSET(1).
      197    ENDIF.
      198  ENDFORM.
    Message was edited by: Ashok Kumar Prithiviraj

  • 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

Maybe you are looking for

  • Sort of day events in calendar

    Has any one been able to sort the items for a day? For example: I have 4 lines for a day: Shift 1 - 1 Shift 2 - 2 Shift 3 - 3 Shift 4 - 4 I've been unable to display the Shift in order. I have tried using Order by, but this does not help. Every Day s

  • ITunes crashed during sync, now Podcasts have sound but no video.

    My wife has a 5th gen 30GB iPod. It has the latest system software from iPod Updater, and we're running the latest iTunes. Yesterday she was doing a sync, and iTunes crashed on her in the middle of it. Now, even with an iPod Restore and reset, and a

  • I message not working

    My I message and face time Is not working help?

  • Context menu tab SERVICE not found in IB PI 7.1

    Hi, I am working in PI 7.1 for a scenario IDOC r/3 to PI 7.1 file. Here in IB I dont see any SERVICE tab to configure/create. I am getting error in IDX5 > Message split according to Receiver list>'Party and service not found'. I am new to this. Could

  • Replicating Generic data

    Hi All, Created Generic data source at r/3 side.... Now how shd i replicate in BW, give me steps.. where shd i replicate ( i mean for SD example, will go SD and right click replicate data source, but for generic where shd i select) Pl help me.... Tha