Create an Excel File Using OPEN DATASET Command

Hey, everyone.
How can I create an Excel file by using OPEN DATASET command ??
The file is created but the columns are no seperated like thay should.
I need to seperate the internal table's fields with a comma - How can I do it ?
Here's my code:
OPEN DATASET filename1 FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
   LOOP AT gt_vend_info into gwa_vend_info.
     TRANSFER gwa_vend_info TO filename1.
     IF SY-SUBRC <> 0.
       EXIT.
     ENDIF.
   ENDLOOP.
ENDIF.
Thanks in advance.

Hi Beki,
REPORT  ZTESTAA.
TYPE-POOLS:TRUXS.
DATA: BEGIN OF ITAB OCCURS 0,
      VBELN LIKE VBAP-VBELN,
      POSNR LIKE VBAP-POSNR,
      END OF ITAB.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
SELECT  VBELN
        POSNR
     UP TO 10 ROWS
     FROM VBAP
     INTO TABLE ITAB.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    I_FIELD_SEPERATOR    = ';'
  TABLES
    I_TAB_SAP_DATA       = ITAB
  CHANGING
    I_TAB_CONVERTED_DATA = ITAB1
  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.
OPEN DATASET filename1 FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT gt_vend_info into gwa_vend_info.
TRANSFER gwa_vend_info TO filename1.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
the above code give CSV format file, all fields will be separated by ';'
Regards
vijay

Similar Messages

  • Problem in accessing application server file using open dataset

    Hi All,
    I am trying to access application server file using open dataset command, its working fine for normal path which imention. But when i am giving path of XI server file, its not working. How to access XI server file using open dataset. Please let me know.
    Thanks in advance.
    Regards,
    Vishal

    Hi Vishal,
    You need to verify if the location where you are trying to save the file is in the same server of SAP. In case that the location is in other server you need to map that directy into the same server of SAP.
    You need to point always to a location in the same server of SAP, in order that the open dataset could work.
    Regards,
    Eric

  • Export to PDF - Can a single report (rpt file) create multiple PDF files using the export command?

    Post Author: markeyjd2
    CA Forum: Exporting
    Greetings forum members,
    My question is, in its entirety: Can a single report (rpt file) create multiple PDF files using the export command, ideally one PDF file per DB record?
    In my case; I have a Crystal Report that reads data from a DB table containing ~ 500 records.  When I export the report to a PDF file, I get one PDF file, with ~ 500 pages.
    What I would like to do is export the report to ~ 500 individual PDF files; One file per DB record.  The file names would be based on the table's primary key.
    Is this possible?

    Post Author: Micha
    CA Forum: Exporting
    Hi,
    you need some lines of code, but its easy. Dependend on how to start the generation of your 500 PDFs, you can write an ASP page and start it via Web Browser, or a Windows Script and start it via scheduled job...
    Here's an abstract of the ASP code I use:
    First, you create a recordset (here: "rsc") which gives you the list of ID fields you want to export, then you create CrystalRuntime.Application object, then you loop through the recordset, open your report (here: "oRpt") and set login info. Then set the selectionformula, so that the report displays only the data of the current ID, e.g.:
      oRpt.RecordSelectionFormula = "(" & oRpt.RecordSelectionFormula & ") AND {myTab.myVal}=" & rsc("myVal")
    Then you export the report, move to the next record in recordset, and repeat the loop until recordset.EOF. Then you close recordset and connection.
    Micha

  • How to open a pdf file using OPEN DATASET

    Im trying to convert a pdf into binary format. So im trying to read the contents of the pdf into a XSTRING. Using the FM 'SCMS_XSTRING_TO_BINARY' i can convert the XSTRING to binary format.
    How to open a pdf file using OPEN DATASET and transfer its contents in a XSTRING variable.
    What i've tried is....
    DATA: f_name type string value 'C:\rep_output_pdf.pdf',
          x1 type xstring,
          LT_DATA TYPE STANDARD TABLE OF X255.
    OPEN DATASET f_name FOR input IN BINARY MODE.
    READ DATASET f_name INTO x1.
    CLOSE DATASET f_name.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          BUFFER     = x1
        TABLES
          BINARY_TAB = LT_DATA.
    Im getting a short dump .
    Short text: The file is not open.
    Plz help me out.

    Hello Rajesh,
    You are trying to do use OPEN DATASET with a local file. NOT POSSIBLE
    You have to have the file in the app server to use OPEN DATASET.
    BR,
    Suhas

  • Download file using open dataset

    Hi all,
    I download a .CSV file to sap server using open dataset. I have a column which stores a number with length upto 30 char. I get the output in this format '2.34234E+25' for '23423423423423400000000000' in that particular column.
    Please send your suggestions to solve this issue.
    Rajesh.

    Do you want to use the csv file in Excel or in another application.
    If you display the CSV file created by open dataset using Notepad, you will probably see the 30 digit number.  This is fine for many applications, but not Excel!
    Excel cannot store a 30 digit number internally.  Try entering a 30 digit number into an Excel cell and see what happens - it is converted to scientific format with only 14 decimal places.
    If you need to see the number in Excel, you need to have it displayed as Text and not a number.  There are a few options:
    1. Put a character at the start of the field
    2. Don't use CSV, but use OLE to start Excel and put the data in the cell with text format (complicated I know).
    3. Save as a file with a .txt extension, open in Excel, and in the Text import wizard (step 3)  specify that the column data format is Text
    Michael

  • Fetch excel file from app. server using open dataset...

    Hello Experts,
    Our functional consultant is asking me if it possible to get an excel file from the
    application server file using OPEN dataset and in background mode? If yes, Please tell me on how to do this.
    Thank you guys and take care!

    Hi Viraylab,
    to download this the procedure:
    you can use the FM 'EXCEL_OLE_STANDARD_DAT ' for this purpose.
    this FM 'EXCEL_OLE_STANDARD_DAT' can be used to start Excel with a new sheet and transfer data from an internal table to the sheet.
    Here are some of the parameters:
    file_name: Name and path of the Excel worksheet file e.g. ?C:TEMPZTEST?
    data_tab: Name of the internal table that should be uploaded to Exvcel
    fieldnames: Internal tabel with column headers
    How to build the field names table:
    data: begin of i_fieldnames occurs 20,
    field(60), end of i_fieldnames.
    i_fieldnames-field = ?This is column 1?. append i_fieldnames-field.
    i_fieldnames-field = ?This is column 2?. append i_fieldnames-field.
    to upload follow this:
    OPEN DATASET dsn FOR INPUT IN BINARY MODE.
    DO.
    READ DATASET dsn INTO itab-field.
    IF sy-subrc = 0.
    APPEND itab.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    [/code]Rob
    or Try this function module.
    FILE_READ_AND_CONVERT_SAP_DATA
    pass 'XLS' to I_FILEFORMAT..
    Dont forgot to Reward me points .....All the very best....
    Regards,
    Sreenivasa sarma K.

  • How can I create an Excel file?

    Hi,
    How can I create an Excel file using Forms 6i.
    What I'm doing is to create a file using TEXT_IO package an name it .XLS. If a read it double-clicking over the file, it opens Ok but If I open directly from Excel it opens the Convert dialog.
    I need to create an excel file as it was made from within Excel.
    Thank in advance,
    Benjamin

    When you are talking about subfiles, are you talking like Package contents of an application?
    Terminal application in Applications -> Utilities can give a command line grasp of all your files using the du command.
    Type
    man du
    when entering the terminal, followed by the enter key.
    Note, by default the terminal opens at the Home folder.   To navigate outside the Home folder enter "/Volumes/name of mounted drive/folder/subfolder" as your path.  If there are spaces in the name, putting quotes around the whole path can help.    If you end your du command with a > name.txt a text file with the name name.txt will be plugged into your Home directory.  That you can open with Excel and parse by /es thus giving you everything in Excel.

  • File transfer Open dataset CSV file Problem

    Hi Experts,
    I have an issue in transferring Korean characters to a .CSV file using open dataset.
    data : c_file(200) TYPE c value '
    INTERFACES\In\test8.CSV'.
    I have tried
    open dataset  c_file for output LEGACY TEXT MODE CODE PAGE '4103'.
    open dataset  c_file for output    in TEXT MODE ENCODING NON-UNICODE.
    open dataset  c_file for output    in TEXT MODE ENCODING Default.
    Nothing is working.
    But to download to the presentation server the below code is working. How can the same be achieved for uploading the file to application server.
    CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            filename                = 'D:/test123.xls'
            filetype                = 'ASC'
            write_field_separator   = 'X'
            dat_mode                = 'X'
            codepage                = '4103'
            write_bom               = 'X'
          CHANGING
            data_tab                = t_tab
          EXCEPTIONS
            file_write_error        = 1
            no_batch                = 2
            gui_refuse_filetransfer = 3
            invalid_type            = 4
            no_authority            = 5
            unknown_error           = 6
            header_not_allowed      = 7
            separator_not_allowed   = 8
            filesize_not_allowed    = 9
            header_too_long         = 10
            dp_error_create         = 11
            dp_error_send           = 12
            dp_error_write          = 13
            unknown_dp_error        = 14
            access_denied           = 15
            dp_out_of_memory        = 16
            disk_full               = 17
            dp_timeout              = 18
            file_not_found          = 19
            dataprovider_exception  = 20
            control_flush_error     = 21
            not_supported_by_gui    = 22
            error_no_gui            = 23
            OTHERS                  = 24.

    Hi,
    I would recommend to use OPEN DATASET ... ENCODING UTF-8 ...
    If your excel version is unable to open this format, you can convert from 4110 to 4103 with report RSCP_CONVERT_FILE.
    Please also have a look at
    File upload: Special character
    Best regards,
    Nils Buerckel

  • Create a Excel File in a Background Job

    Hi SAP Gurus,
    I am trying to create an Excel file using a background job but it is not possible.
    In foreground mode i get a file.
    Can someone give an explanation for that? Or someone have a workaround ??
                   Best Regards
                          João Fernandes

    João,
    If you have successfully demonstrated that SAP can write an output to an excel file, then it can do this in background as well as foreground.  The problem is probably not with the fact that it is 'Excel', but that it is trying to write a file in the background to a destination file location that is unknown to the system.
    Generally, without special setup, SAP software is unaware of most file locations that are outside of the SAP system itself.  When you log on through the SAP Gui, the SAP back end can "learn" about certain additional file locations through your PC setup and the SAPGUI session.  This 'knowledge' is lost as soon as you commit your program to a background process.
    Talk to your Basis person, and tell him what you wish to do.  This functionality is possible to do, but probably not in the way you are expecting.
    Best Regards,
    DB49

  • Generate Excel File using Java

    Hi,
    could any one tell me how can I create an Excel file using java. I can create the file using PrintWriter and other IO classes. But how do I insert the data in to different cells and rows.
    Any help would be greatly appreciated. Thanks in advance for your help,
    -MS

    Dear All,
    There are three ways for achiving excel operations using java including excel to xml etc.
    1. There is a very effective tool available for this operation is "jexcel". You can find it at http://www.andykhan.com/jexcelapi/index.html
    2. Jakarta site has provided a very good tool by name jakarta poifs. one can find at jakarta site.
    3. One can develop a very effective tool by combining these above tools togather.
    The operations that can be performed are read, write, convert etc for excel. The major attraction of Jexcel is excel to xml conversion.
    Regards,
    Nishant Kulkarni
    Software Engineer
    [email protected]

  • Does we need to Create a file Before using Open dataSet

    Hi Guys,
                Can  any body tell me whether we have to create a File before using Open dataset  for writing files in Application Server.
               Can anybody write a program for EKPO table to store it in application Server using OpendatasSet ?Is there any specific care we have to take for Executing   pgm in Background?
    I wrote the pgm for Foreground using GUI- Download.
    PGM.
          select * into table it_ekpo  from  ekpo .
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename ='c:\EKPO.xls'
    filetype = 'ASC'
    WRITE_FIELD_SEPARATOR = 'X'
    TABLES
    data_tab = it_ekpo
    *fieldnames = l_heading
    EXCEPTIONS
    file_write_error = 1
    no_batch = 2
    gui_refuse_filetransfer = 3 .
                       Plzzzzzzzzz Make the changes for existing Pgm.any help is awarded with points.Its Urgent.
    Thanks,
    Gopi.

    Hi Guys,
                 Thanks for ur immediate response.I am sending the code just confirm me whether is correct r not?
    DATA : wa_EKPO_file   TYPE file_table-filename.
    select * into table it_ekpo  from  ekpo .
      OPEN DATASET wa_EKPO_file FOR OUTPUT         "Write to appl. server
                                          IN TEXT MODE
                                          ENCODING DEFAULT.  "Open dataset Return code
    IF sy-subrc = 0.
    LOOP at IT_EKPO into WA_EKPO.
    TRANSFER wa_ekpo to wa_ekpo_file.
    ENDLOOP.
    ENDIF.
                                             I want write the data into SPREAD Sheet .Can u guys  tell me how to write into Spread Sheet using Open data Set.
    Thanks,
    Gopi.

  • Physical file location in SAP when OPEN DATASET command is used

    Hi,
    I have used below sample code from SAP help in my program. If you notice, I have not specified the file path however I am able to open and read this file whenever I want. Could anybody let me know where exactly is this file physically located. I have tried SP11( Temse objects) but no use.
    DATA: file   TYPE string VALUE `test.dat`,
          result TYPE string.
    OPEN DATASET file FOR OUTPUT IN TEXT MODE
                                 ENCODING DEFAULT.
    TRANSFER `1234567890` TO file.
    CLOSE DATASET file.
    OPEN DATASET file FOR UPDATE IN TEXT MODE
                                 ENCODING DEFAULT .
    TRANSFER `ABCD` TO file.
    CLOSE DATASET file.
    OPEN DATASET file FOR INPUT IN TEXT MODE
                                ENCODING DEFAULT .
    WHILE sy-subrc = 0.
      READ DATASET file INTO result.
      WRITE / result.
    ENDWHILE.
    CLOSE DATASET file.
    Regards
    Kasi

    Hi,,
    In the transaction AL11 go to the directory  DIR_TEMP... you can find your file there
    Regards,
    Siddarth

  • How can I create an csv/excel file using pl/sql and then sending that file

    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.

    968776 wrote:
    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
    Whay do you want database (pl/sql) code to do these things?
    Anyhow, you may be interested in :
    {message:id=9360007}
    {message:id=9984244}

  • How do I read a range of data from an open and "live" Excel file using LV7.0 Express

    I need to interface with software which continuously (once per second) writes a new array to a fixed location in an open Excel file. I would like to read this data into Labview from where I can do what I like with it. I am relatively new to LabView and have tried all "Read Data" examples that come with the product, Active examples seem very unclear. Anyone got any samples/suggestions to get me started?
    Attachments:
    Changing_Excel_file.xls ‏17 KB

    It is possible but might be a little bit complicated. Does your application opens the Excel file or Excel file was opened through Excel or another application already?
    In the first senario, once the excel is opened, start reading the data, do not close the report file (dispose the report) or close the excel file
    In the second senario, it is a little bit more complicated. You need to use low level Excel ActiveX functions. The procedure is:
    1. Open reference to Excel
    2. Activate the desired workbook if it is already opened
    or open a new file
    3. Activate the sheet containing the data
    4. Read the data
    5. Loop if necessary (step 2 if diff wb, step 3 if diff sht, 4 if same sheet)
    6. Close Excel reference (Very important, close the
    ref only, do not use Application.Exit to exit Excel).
    Hope this helps,
    -Joe

  • Create Tab-delimited text file with OPEN DATASET

    Hi everyone,
    My problem goes like this: the text file that I am writing using OPEN DATASET needs to be tab-delimited.  Originally the file was to be delimited using the pipe ( '|' ) character.
    I read in one of the threads that to put in tab delimiters you need to use something like this:
    DATA v_tab TYPE x value '09'.
    CONCATENATE  wa-field1 wa-field2
      INTO wa_output SEPARATED BY v_tab.
    I also encountered the same problem, the error that I can't concatenate the v_tab with the other fields.
    What, therefore, is the correct way to declare the fields to be used?
    Thanks.

    Try this. It worked for me:
    class cl_abap_char_utilities definition load.
    constants:
        tab  type c value cl_abap_char_utilities=>horizontal_tab.

Maybe you are looking for

  • Safari will select text but won't copy

    I can't remember how long it's been going on, but I assume it started when I upgraded to Mountain Lion. I have Mavericks now. On most pages I go to I can highlight the text but I can't right-click it to copy it. I can, however, go to the Edit column

  • Why can't I do cumulative edits, like in iPhoto 6?

    I've just bought a new iMac (Core i5) running the latest iPhoto (9). It has some useful improvements over iPhoto 6 which was the previous version I used, but one thing has gone - I can't do cumulative edits any more. In v6, I could sharpen a soft pic

  • Fact table with datetime measure showing #value error while browsing the cube

    Hi All, I have a cube with a fact table having datetime measure. when I browse the cube, I am able to see the data for all measures except  for the measure with the datetime as datatype. Thanks in advance.

  • Realtek 8111D adapter can no longer connect at gigabit speed to WRT610N after firmware upgrade

    Ever since I flashed to the newest firmware,  the Realtek 8111D adapter on my Gigabyte X58 Motherboard can no longer connect at 1 gig to the router.   There is a connection detected in the OS but I wasn't able to get into the config at 192.168.1.1 or

  • Help required in ALV Tree Control

    Hi All, I am using OO ALV tree Control in my Project every thing is working fine. in treecontrol  'If we double click on Node I con it displays resultant screen'- its fine for us 'If we double click on Node Text it is displaying nothing means no Even