EXCEL WORKBOOK ON APPLICATION SERVER IN BACKGROUND

Dear Experts,
I have to download a file as excel workbook in background on application server.
I have used open / close data set using  that I am able to download .CSV and Tab Delimated file(with extension as .xls) but not excel workbook.
Regards and Thanks,
Vikas

Hi Vikas,
    what i understood is , u hav a excel file on presentation server (desktop)  and want to upload it to the appln server. if so do the following :
step one :  save the excel file with all the data u wanted in it.
step two : save as  the excel file  in tab delimited format.
step three : save as the tab delimited file in ansi    .txt format.
Now cg3z to upload the text file (.txt) in appln server .
open the file as below:
DATA: begin of itab,
           col1  type <>,
           col2  type <>,
          end of itab.
DATA : wa_itab   like itab.
DATA: wa(100)       TYPE c,
           xeof(1)        TYPE c.
PARAMETERS: p_file(30) TYPE c DEFAULT 'appln server path .txt' LOWER CASE
                                         OBLIGATORY,
OPEN DATASET  <p_file> FOR INPUT IN TEXT MODE
                       ENCODING DEFAULT.
  IF sy-subrc NE 0.
    WRITE  : ' error opening the file "
    EXIT.
  ELSE.
    DO.
      READ DATASET p_file INTO wa.
      IF sy-subrc NE 0.
        xeof = 'X'.
        EXIT.
      ENDIF.
      IF sy-subrc EQ 0.
        PERFORM split_data.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    CLOSE DATASET p_file .
FORM split_data .
  SPLIT wa AT  cl_abap_char_utilities=>horizontal_tab
                                      INTO  wa_itab-col1  wa_itab-col2  wa_itab-col3.
  APPEND wa_itab TO gi_itab.
ENDFORM.                    " SPLIT_DATA

Similar Messages

  • Upload and download of  excel file in the application server in background

    Hi all,
    i want to download the excel file from application server into internal table and after processing i have to upload to excel file in the application server in the background mode..
    i mean i'll schedule the program in background.
    im using FM ALSM_EXCEL_TO_INTERNAL_TABLE its working fine in fore ground but not in back ground.
    what method i have to follow ?

    Hi Ankit,
    I think this is not possible to open a Excel-File from the application server because the Excel format before Office 2007 where a binary format (Suffix: .xls). The newer Office file format (Suffix: xlsx) is a zipped XML Format. To read the binary Excel-Format you need an OLE Connection between SAP GUI and Office. But at the application server in background you doesn't have this OLE Connection.
    In my opinion you have two possibilities:
    1. Convert all files in the CSV format. This file format can be read with open dataset.
    2. Upload the files from the presentation server in forground. There are some funktion modules in the standard which can read the xls format. But they have some limits regarding the length of cells content.
    My recommendation is solution no. 1. If you know an VBA expert, he can write an Excel-macro which converts all Excel Files in the CSV-Fomat.
    Regards
    Dirk

  • Uploading Excel File in application server

    Hi,
    I am uploading data from internal table to excel file in application server.I am using Open dataset to put in appln server.(background job).But the problem is it is not sitting in different colums,all data goes to single column.I want every field in separate columns.Please suggest to proceed.

    Hi,
    save the internal table as a desktop file and then use CG3Z transaction to put the data from desktop to application server.
    then to read the application file use the logic given below:
    DATA: wa_file_data TYPE text4096,
    lv_app_server_file TYPE string.
      lv_app_server_file = pa_afile.
    To read file from Application server
      OPEN DATASET lv_app_server_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      DO.
        READ DATASET lv_app_server_file INTO wa_file_data.
        IF sy-subrc = 0.
          APPEND wa_file_data TO gi_file_data.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET lv_app_server_file.
    DATA: lv_file_separator TYPE c.
      lv_file_separator = cl_abap_char_utilities=>horizontal_tab.
    To upload file in other formats(CSV, Tab delimited etc)
      CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
        EXPORTING
          i_field_seperator    = lv_file_separator
          i_tab_raw_data       = gi_file_data
        TABLES
          i_tab_converted_data = gi_zhralcon_file
        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.
    Hope it helps.
    Regards,
    Rajesh Kumar

  • Sending an Email by taking excel sheet from Application Server.

    Hi.
    I Searched in SDN related 'Sending an Email by taking excel sheet from Application Server'.
    But i didnt get. I got sending mails from local pc.
    Can some bdy provide me sample code how to send mail with an attachment. the attached file should get from Application Server
    Regards,
    Renu

    Hi,
    For writing data to app server from internal table:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/prog%252bon%252bopen%252bdataset%252binput
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/prog%252bon%252bopen%252bdataset%252boutput
    Checkout this wiki for sending XL in mail attachment:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/multiple%252battachment%252bon%252be_mail
    Thanks,
    Krishna

  • Open data set for reading excel file on application server in back ground

    open data set for reading excel file on application server in back ground

    hi Vijay,
    I am afraid you won't be able to read from Excel file on Appl. Server.
    ec

  • Error while reading excel file from application server into internal table.

    Hi experts,
    My requirement is to read an excel file from application server into internal table.
    Hence I have created an excel file fm_test_excel.xls in desktop and uploaded to app server using CG3Z tcode (as BIN file type).
    Now in my program I have used :
    OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    DO.
    READ DATASET v_filename INTO wa_tab.
    The statement OPEN DATASET works fine but I get a dump (conversion code page error) at READ DATASET statement.
    Error details:
    A character set conversion is not possible.
    At the conversion of a text from codepage '4110' to codepage '4103':
    - a character was found that cannot be displayed in one of the two
    codepages;
    - or it was detected that this conversion is not supported
    The running ABAP program 'Y_READ_FILE' had to be terminated as the conversion
    would have produced incorrect data.
    The number of characters that could not be displayed (and therefore not
    be converted), is 445. If this number is 0, the second error case, as
    mentioned above, has occurred.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
    caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Characters are always displayed in only a certain codepage. Many
    codepages only define a limited set of characters. If a text from a
    codepage should be converted into another codepage, and if this text
    contains characters that are not defined in one of the two codepages, a
    conversion error occurs.
    Moreover, a conversion error can occur if one of the needed codepages
    '4110' or '4103' is not known to the system.
    If the conversion error occurred at read or write of  screen, the file
    name was '/usr/sap/read_files/fm_test_excel.xls'. (further information about
    the file: "X 549 16896rw-rw----201105170908082011051707480320110517074803")
    Also let me know whether this is the proper way of reading excel file from app server, if not please suggest an alternative .
    Regards,
    Karthik

    Hi,
    Try to use OPEN DATASET v_filename FOR INPUT IN BINARY mode encoding default. instead of OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    As I think you are uploading the file in BIN format to Application server and trying to open text file.
    Regards,
    Umang Mehta

  • Creating a folder in application server in background.

    Hi experts,
    Is it possible to Creating a folder in application server in background.?
    My requirement is like this , every time a PO is created it has to be saved locally.
    When atlast i manged to do this, i get stuck again by this CR ,
    The PO has to be saved in a folder with the same name as PO number,
    I do not know if it is possible.
    So as always I am looking for inputs/suggestions or knowledge if you had come across scenario like this one.
    Thanks and Regards,
    K

    Hi,
    You could create a system command in SM69 to create a directory and then use the function module SXPG_CALL_SYSTEM to invoke the command and pass in the directory name as a parameter at run time.
    Darren

  • Downloading logo in excel sheet from application server

    hi all
    how can i download a logo in excel sheet from the application server(logo is in OAOR tcode) .you can also specify with OOPS concept.
    rewards assured.
    Reagrds
    Swarnali Basu

    hi naresh
    i think there is some miscommunication in case of my question,my requirement is to add a logo in excel sheet from application server,i mean when the user clicks to download the excel sheet the logo should immediately appear in the excel sheet,and it is not a fixed logo it can be anything which appears in applicaton server(on that program).
    as far as excel sheet stanalone is concerned i know to do it and as well as to get the logo  in the application server standalone ,but i cant download the logo in excel sheet from the application server.now does my question make sense ?
    Reagrds
    Swarnali

  • Create Excel file in application server but the field value is incorrect

    Hi Experts,
    i am facing a problem when create excel file in application server using OPEN DATASET command.
    the internal table have 4 field and one of those field contains 19 digit number --> ICCID.
    the code running well, successfully create EXCELfile in application server but the problem is SAP only copy exactly first 15 digit numeric only and the rest became zero 0
    Example :
    the field value in internal table is 8962118800000447654 but when i opened in the excel file the value became 8962118800000440000.
    and if i add alphabet like a8962118800000447654 then it is correct.
    is there is anything wrong with my code?
    here is my code
    CONSTANTS: c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab. "Tab Char
    Data : begin of lt_zdsdmmdt00005 occurs 0,
             SERNR (18) type c,
             MSISDNl(20) type c,
             BOX1 (20) type c,
             ICCID(30) type c,
           end of lt_zdsdmmdt00005.
    data : ld_temp(100) type c.
    i_file = '/usr/sap/DM/test_excel.xls'.
    open dataset i_file for output in legacy text mode.
      loop at lt_zdsdmmdt00005.
        move lt_zdsdmmdt00005-ICCID to ld_iccid .
        concatenate lt_zdsdmmdt00005-sernr  lt_zdsdmmdt00005-MSISDN  lt_zdsdmmdt00005-BOX1 ld_iccid
        into ld_temp separated by c_tab.
        transfer ld_temp to i_file.
      endloop.
      close dataset i_file.
    Best Regard,
    Akbar.

    Hi Naveen,
    thanks for your reply,
    i already tried and the result still the same. any idea?
    Best Regard,
    Akbar.

  • 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á

  • Downloading internal table in excel file on application server

    Hi,
        I am trying to download ITAB into excel file on my application server . I am using FM 'SAP_CONVERT_TO_XLS_FORMAT' for that .
        When I run the report I can see file getting generated on APP server but no ITAB data is saved in that excel.
        After debugging I found that error code  'SAVE_DOCUMENT_FAILED'  is retuned in above FM.
        Could any one please suggest how to go about this?
    Regards,
    Ganesh

    Hi ganesh,
    Please have a look into the below link
    [Link1|How to Upload Excel file to Application Server]
    [Link2|Error in Downloading the Text file on Application Server]
    Hope this will be Helpful
    Thanks
    Kalyan

  • How to upload excel file in application server??

    Hi,
    How to upload an excel file into internal table in background mode from application server?
    Thanks

    Hi vipin,
    check this it may help you...
    hope below links helps you
    Export the report list to Excel Sheet
    http://www.sapdevelopment.co.uk/file/file_updown.htm
    or below is a sample programme which helps you upload and download
    REPORT ytest5 LINE-SIZE 80
                    LINE-COUNT 65
                    NO STANDARD PAGE HEADING.
    TABLES: dd02l, dd03l.
    * selection screen
    SELECTION-SCREEN BEGIN OF BLOCK b00 WITH FRAME TITLE text-b00.
    SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
    PARAMETERS: tabname     LIKE dd02l-tabname OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b01.
    SELECTION-SCREEN BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
    PARAMETERS: path(30)    TYPE c DEFAULT 'C:SAPWorkdir'.
    SELECTION-SCREEN END OF BLOCK b03.
    SELECTION-SCREEN BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
    PARAMETERS: p_exp RADIOBUTTON GROUP radi,
                p_imp RADIOBUTTON GROUP radi,
                p_clear     AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK b04.
    SELECTION-SCREEN END OF BLOCK b00.
    * data
    DATA: q_return     LIKE syst-subrc,
          err_flag(1)  TYPE c,
          answer(1)    TYPE c,
          w_text1(62)  TYPE c,
          w_text2(40)  TYPE c,
          winfile(128) TYPE c,
          w_system(40) TYPE c,
          winsys(7)    TYPE c,
          zname(8)     TYPE c,
          w_line(80)   TYPE c.
    * internal tables
    DATA : BEGIN OF textpool_tab OCCURS 0.
            INCLUDE STRUCTURE textpool.
    DATA : END OF textpool_tab.
    * table for subroutine pool
    DATA : itab(80) OCCURS 0.
    * events
    INITIALIZATION.
      PERFORM check_system.
    AT SELECTION-SCREEN ON tabname.
      PERFORM check_table_exists.
    START-OF-SELECTION.
      PERFORM init_report_texts.
      PERFORM request_confirmation.
    END-OF-SELECTION.
      IF answer = 'J'.
        PERFORM execute_program_function.
      ENDIF.
    TOP-OF-PAGE.
      PERFORM process_top_of_page.
    * forms
    *       FORM CHECK_TABLE_EXISTS                                      *
    FORM check_table_exists.
      SELECT SINGLE * FROM dd02l
      INTO CORRESPONDING FIELDS OF dd02l
      WHERE tabname = tabname.
      CHECK syst-subrc NE 0.
      MESSAGE e402(mo) WITH tabname.
    ENDFORM.
    *       FORM INIT_REPORT_TEXTS                                        *
    FORM init_report_texts.
      READ TEXTPOOL syst-repid
      INTO textpool_tab LANGUAGE syst-langu.
      LOOP AT textpool_tab
      WHERE id EQ 'R' OR id EQ 'T'.
        REPLACE '&1............................'
        WITH tabname INTO textpool_tab-entry.
        MODIFY textpool_tab.
      ENDLOOP.
    ENDFORM.
    *       FORM REQUEST_CONFIRMATION                                     *
    FORM request_confirmation.
    * import selected, confirm action
      IF p_imp = 'X'.
    *   build message text for popup
        CONCATENATE 'Data for table'
                     tabname
                     'will be imported' INTO w_text1 SEPARATED BY space.
    *   check if delete existing selected, and change message text
        IF p_clear = ' '.
          w_text2 = 'and appended to the end of existing data'.
        ELSE.
          w_text2 = 'Existing Data will be deleted'.
        ENDIF.
        CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
             EXPORTING
                  defaultoption  = 'N'
                  textline1      = w_text1
                  textline2      = w_text2
                  titel          = 'Confirm Import of Data'
                  cancel_display = ' '
             IMPORTING
                  answer         = answer
             EXCEPTIONS
                  OTHERS         = 1.
      ELSE.
    *   export selected, set answer to yes so export can continue
        answer = 'J'.
      ENDIF.
    ENDFORM.
    *       FORM EXECUTE_PROGRAM_FUNCTION                                 *
    FORM execute_program_function.
      PERFORM build_file_name.
      CLEAR: q_return,err_flag.
      IF p_imp = 'X'.
        PERFORM check_file_exists.
        CHECK err_flag = ' '.
        PERFORM func_import.
      ELSE.
        PERFORM func_export.
      ENDIF.
    ENDFORM.
    *       FORM BUILD_FILE_NAME                                          *
    FORM build_file_name.
      MOVE path TO winfile.
      WRITE '' TO winfile+30.
      WRITE tabname TO winfile+31.
      WRITE '.TAB' TO winfile+61(4).
      CONDENSE winfile NO-GAPS.
    ENDFORM.
    *       FORM CHECK_FILE_EXISTS                                        *
    FORM check_file_exists.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                filename = winfile
                query    = 'FE'
           IMPORTING
                return   = q_return
           EXCEPTIONS
                OTHERS   = 1.
      IF syst-subrc NE 0 OR q_return NE 1.
        err_flag = 'X'.
      ENDIF.
    ENDFORM.
    *     FORM func_export                                              *
    FORM func_export.
      CLEAR itab. REFRESH itab.
      APPEND 'PROGRAM SUBPOOL.' TO itab.
      APPEND 'FORM DOWNLOAD.' TO itab.
      APPEND 'DATA: BEGIN OF IT_TAB OCCURS 0.' TO itab.
      CONCATENATE 'INCLUDE STRUCTURE'
                  tabname
                  '.' INTO w_line SEPARATED BY space.
      APPEND w_line TO itab.
      APPEND 'DATA: END OF IT_TAB.' TO itab.
      CONCATENATE 'SELECT * FROM'
                  tabname
                  'INTO TABLE IT_TAB.' INTO w_line  SEPARATED BY space.
      APPEND w_line TO itab.
      APPEND 'CALL FUNCTION ''WS_DOWNLOAD''' TO itab.
      APPEND 'EXPORTING' TO itab.
      CONCATENATE 'filename = ' ''''
                  winfile '''' INTO w_line SEPARATED BY space.
      APPEND w_line TO itab.
      APPEND 'filetype = ''DAT''' TO itab.
      APPEND 'TABLES' TO itab.
      APPEND 'DATA_TAB = IT_TAB.' TO itab.
      APPEND 'DESCRIBE TABLE IT_TAB LINES sy-index.' TO itab.
      APPEND 'FORMAT COLOR COL_NORMAL INTENSIFIED OFF.' TO itab.
      APPEND 'WRITE: /1 syst-vline,' TO itab.
      APPEND '''EXPORT'',' TO itab.
      APPEND '15 ''data line(s) have been exported'',' TO itab.
      APPEND '68 syst-index,' TO itab.
      APPEND '80 syst-vline.' TO itab.
      APPEND 'ULINE.' TO itab.
      APPEND 'ENDFORM.' TO itab.
      GENERATE SUBROUTINE POOL itab NAME zname.
      PERFORM download IN PROGRAM (zname).
    ENDFORM.
    *       FORM func_import                                              *
    FORM func_import.
      CLEAR itab. REFRESH itab.
      APPEND 'PROGRAM SUBPOOL.' TO itab.
      APPEND 'FORM UPLOAD.' TO itab.
      APPEND 'DATA: BEGIN OF IT_TAB OCCURS 0.' TO itab.
      CONCATENATE 'INCLUDE STRUCTURE'
                  tabname
                  '.' INTO w_line SEPARATED BY space.
      APPEND w_line TO itab.
      APPEND 'DATA: END OF IT_TAB.' TO itab.
      APPEND 'DATA: BEGIN OF IT_TAB2 OCCURS 0.' TO itab.
      CONCATENATE 'INCLUDE STRUCTURE'
                  tabname
                  '.' INTO w_line SEPARATED BY space.
      APPEND w_line TO itab.
      APPEND 'DATA: END OF IT_TAB2.' TO itab.
      APPEND 'CALL FUNCTION ''WS_UPLOAD''' TO itab.
      APPEND 'EXPORTING' TO itab.
      CONCATENATE 'filename = ' ''''
                  winfile '''' INTO w_line SEPARATED BY space.
      APPEND w_line TO itab.
      APPEND 'filetype = ''DAT''' TO itab.
      APPEND 'TABLES' TO itab.
      APPEND 'DATA_TAB = IT_TAB.' TO itab.
      IF p_clear = 'X'.
        CONCATENATE 'SELECT * FROM'
                    tabname
                    'INTO TABLE IT_TAB2.' INTO w_line SEPARATED BY space.
        APPEND w_line TO itab.
        APPEND 'LOOP AT IT_TAB2.' TO itab.
        CONCATENATE 'DELETE'
                    tabname
                    'FROM IT_TAB2.' INTO w_line SEPARATED BY space.
        APPEND w_line TO itab.
        APPEND 'ENDLOOP.' TO itab.
        APPEND 'COMMIT WORK.' TO itab.
      ENDIF.
      APPEND 'LOOP AT IT_TAB.' TO itab.
      CONCATENATE 'MODIFY'
                  tabname
                  'FROM IT_TAB.' INTO w_line SEPARATED BY space.
      APPEND w_line TO itab.
      APPEND 'ENDLOOP.' TO itab.
      APPEND 'DESCRIBE TABLE IT_TAB LINES sy-index.' TO itab.
      APPEND 'FORMAT COLOR COL_NORMAL INTENSIFIED OFF.' TO itab.
      APPEND 'WRITE: /1 syst-vline,' TO itab.
      APPEND '''IMPORT'',' TO itab.
      APPEND '15 ''data line(s) have been imported'',' TO itab.
      APPEND '68 syst-index,' TO itab.
      APPEND '80 syst-vline.' TO itab.
      APPEND 'ULINE.' TO itab.
      APPEND 'ENDFORM.' TO itab.
      GENERATE SUBROUTINE POOL itab NAME zname.
      PERFORM upload IN PROGRAM (zname).
    ENDFORM.
    *       Form  CHECK_SYSTEM
    *            Check users workstation is running
    *            WINDOWS 95, or WINDOWS NT.
    *            OS/2 uses 8.3 file names which are no good for
    *            this application as filenames created are 30 char
    *            same as table name.
    *            You could change the logic to only use the first 8 chars
    *            of the table name for the filename, but you could possibly
    *            get problems if users had exported already with a table
    *            with the same first 8 chars.
    *            As an alternate method you could request the user to input
    *            the full path including filename and remove the logic to
    *            build the path using the table name.
    FORM check_system.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query  = 'WS'
           IMPORTING
                return = winsys.
      IF winsys NE 'WN32_95'.
        WRITE: 'Windows NT or Windows 95/98 is required'.
        EXIT.
      ENDIF.
    ENDFORM.                               " CHECK_SYSTEM
    *       FORM PROCESS_TOP_OF_PAGE                                      *
    FORM process_top_of_page.
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
      ULINE.
      CONCATENATE syst-sysid
                  syst-saprl
                  syst-host INTO w_system SEPARATED BY space.
      WRITE : AT /1(syst-linsz) w_system CENTERED.
      WRITE : AT 1 syst-vline, syst-uname.
      syst-linsz = syst-linsz - 11.
      WRITE : AT syst-linsz syst-repid(008).
      syst-linsz = syst-linsz + 11.
      WRITE : AT syst-linsz syst-vline.
      LOOP AT textpool_tab WHERE id EQ 'R'.
        WRITE : AT /1(syst-linsz) textpool_tab-entry CENTERED.
      ENDLOOP.
      WRITE : AT 1 syst-vline, syst-datum.
      syst-linsz = syst-linsz - 11.
      WRITE : AT syst-linsz syst-tcode(004).
      syst-linsz = syst-linsz + 11.
      WRITE : AT syst-linsz syst-vline.
      LOOP AT textpool_tab WHERE id EQ 'T'.
        WRITE : AT /1(syst-linsz) textpool_tab-entry CENTERED.
      ENDLOOP.
      WRITE : AT 1 syst-vline, syst-uzeit.
      syst-linsz = syst-linsz - 11.
      WRITE : AT syst-linsz 'Page', syst-pagno.
      syst-linsz = syst-linsz + 11.
      WRITE : AT syst-linsz syst-vline.
      ULINE.
      FORMAT COLOR COL_HEADING INTENSIFIED OFF.
      LOOP AT textpool_tab WHERE id EQ 'H'.
        WRITE : AT /1(syst-linsz) textpool_tab-entry.
      ENDLOOP.
      ULINE.
    ENDFORM.
    if it helps you reward with points.
    regards,
    venu
    regards,
    venu.

  • 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á

  • Read Excel File on Application Server to Internal Table

    Hi Everybody!
    Can anyone tell me how I can Read in an Excel File from the Application Server?
    I'm familiar with the OPEN DATASET Statement and I already use it to read in text files.
    Important is, that it works in the Batch / can be used as a background job
    I already tried using
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    which did not work.
    Can anybody please help me`?
    I created the file I try to read out from the Application Server Folder with the Standard upload
    in ABAP Web Dynpro and Wrote it to the Server with the following code. Does anyone know
    if maybe already the writing is to the application server is wrong?
    try.
          convt = cl_abap_conv_in_ce=>create(
            input = lv_filedata
            encoding = 'UTF-8'
            replacement = '?'
            ignore_cerr = abap_true ).
          convt->read( importing data = s_cont ).
        catch cx_sy_conversion_codepage.
          wd_comp_controller->show_error( exporting
            text = 'There occurred an error during conversioning the code page.' type = 'E' ).
      endtry.
        open dataset XLSFILEPATH for output in binary mode.
        transfer s_cont TO XLSFILEPATH.
        close dataset XLSFILEPATH.
    Best Regards and Thanks,
    Steffen

    Hi Suhan,
    I tried the following, but the output in the table doesn't look good at all
    Can you please help?
    OUTPUT:
    ??#u0871#?################>###??##############################=#######????########???????????????????????????????????????????????????????????????????????????????????????????????????????
    ####################################################################################### ###!###"#######$###%###&###'###(###)###*###+###,###-###.###/###0###1###2###3###4###5###6###7#
    #?######Z##A#r#i#a#l###3########,#####0#\# #"#? "#;#\#-###,#####0#\# #"#? "###=########,#####0#\# #"#? "#;#[#R#e#d#]#\#-###,#####0#\# #"#? "###?########,#####0#.#0#0#\# #"#? "#;#\#-
    ###?? ##?########? ?#######?? ##?########? ?#######?? ##?#P######? ?#######?? ##?#P######? ?#######?? ##?# ######? ?#######?? #################A#?#?j}#(#}############################
    ##########?########}#?#}#############*##################_#? _#-########????#,#####0########????#? _#-#;########????#"#?#?#\########????#_#-#@#_
    #######????########}#(#}#############+##################_#? _#-}#(#}#############,##################_#? _#-}#(#}#############-##################_#? _#-}#(#}#############.###########
    ##########?########}#<#}#############6#############?}#?#_#? _#-########??#?#,#####0}#<#}#############7#############?e#?#_#? _#-########????#,#####0}#?#}#############8###############
    #######????########}#?#}#############9#############????#_#? _#-########????#,#####0########????#? _#-#;########????#"#?#?#\########????#_#-#@#_
    #######????########}#(#}#############:##################_#? _#-}#-#}#############;##################_#? _#-#####}#P#}#############<##################_#? _#-#############,#####0#####
    ##Check Cell?#z#?##############?
    #C#h#e#c#k# #C#e#l#l##########?##????########????#####?##????#######?##????#######?##????#######?##????##?###+?#??# #?##############?##C#o#m#m#a#####?###,?#??#(#?##############?##C#
    #5####Input?#p#?##############?##I#n#p#u#t##########?##?u0319?#####?##??v?#####?#####?#######?#####?#######?#####?#######?#####?##?###6####Linked Cell?#F#?##############?##L#i#n#k#e#d#
    ?##N#o#t#e##########?##????#####?##????#######?##????#######?##????#######?##????##?###9####Output?#r#?##############?##O#u#t#p#u#t##########?##????#####?##????#####?##????#######?#
    #;####Title?#1#?##############?##T#i#t#l#e##############I}?%####?#
    #<####Total?#H#?##############?##T#o#t#a#l################?########O???##########O???##?###=####Warning Text?#:#?##############?##W#a#r#n#i#n#g# #T#e#x#t##########?##?##??#X#?######
    ##Commission###Health Incentive ###Housing Norm###Hypo Tax###Hypo Tax- Special Wages###Paid Time Off(##Vision Insurance- Withheld from Employee###Working Spouse/DP surcharge)##TX St
    ###########?#?#?######### #########c###?3###N##?h##?t##nu############d#################????MbP?_#####*#####+#####?#####?###########%#####?#?###?#########?#####?#####&###ffffff??'###
    #I#######}########+######}#######$
    ######}#######m###############c###################?###################?###################?###################?###################?###################?###################?##########
    CODING:
    types: begin of st_excel_parse,
              clientno type string,
              fileid type string,
              paymtreportingid type string,
              name type string,
              employee_id  type string,
              home_country type string,
              host_country  type string,
              actstartdt  type string,
              actenddt type string,
              assignment_status type string,
              paymttypenm  type string,
              paymtcategorynm  type string,
              paymtdt  type string,
              transeffdt  type string,
              amount  type string,
              currency_code type string,
      end of st_excel_parse.
      data: ls_excel_parse type st_excel_parse,
            lt_excel_parse type table of st_excel_parse.
      data l_wa_raw_data type string.
      open dataset gv_str_filename for input in text mode encoding default.
      if sy-subrc = 0.
        do.
          read dataset gv_str_filename into l_wa_raw_data.
          if sy-subrc = 0.
            "Split the file record using <TAB> and store inside the work area
            split l_wa_raw_data at cl_abap_char_utilities=>horizontal_tab into :
              ls_excel_parse-clientno
              ls_excel_parse-fileid
              ls_excel_parse-paymtreportingid
              ls_excel_parse-name
              ls_excel_parse-employee_id
              ls_excel_parse-home_country
              ls_excel_parse-host_country
              ls_excel_parse-actstartdt
              ls_excel_parse-actenddt
              ls_excel_parse-assignment_status
              ls_excel_parse-paymttypenm
              ls_excel_parse-paymtcategorynm
              ls_excel_parse-paymtdt
              ls_excel_parse-transeffdt
              ls_excel_parse-amount
              ls_excel_parse-currency_code .
            append ls_excel_parse to lt_excel_parse.
          endif.
        enddo.
      endif.

  • Create excel file on application server

    Hi experts,
    Is it possiblel to create an excel file on the application server in a background process ?
    We have an windows nt application server.
    I tried with open dataset ..but i didn't work 100% good.
    has anybody any sample ?
    Thanks.

    I m using an csv file as tabdelimited .
    data: htab(1) type c.
    htab = cl_abap_char_utilities=>horizontal_tab.
    the file is downloaded as excel , but if i open the file i see the content of a row always in the first column.
    Types : begin of ty_test,
                    name1 type char10,
                    name2 type char10,
                end of ty_test.
    Data : it_test type table of ty_test,
              wa_test type ty_test,
              wa_row type string.
    data: htab(1) type c.
    htab = cl_abap_char_utilities=>horizontal_tab.
    wa_test-name1 = 'name1'.
    wa_test-name2 = 'name2'.
    append wa_test to it_test.
    clear wa_test.
    open dataset <filename> for output in text mode
              encoding default.
       loop at it_test into wa_test.
         conatenate wa_test-nam1 wa_test-name2  into wa_row  separated by htab.
         transfer wa_row to <filename>.
      endloop.
    close dataset.
    Edited by: Moo Yac on Jul 2, 2009 11:48 AM

Maybe you are looking for