'Open Dataset' command - add ASCII code in a unicode system

Hi,
I use following comand in order to save a file on an application server. 
open dataset <path> for output in text mode encoding default.
Is it possible to convert file to ASCII code instead of the system setting unicode and to ignore conversion errors? If yes, please tell me how.
Thanks!

problem exporting text in hebrew
Similar kind of problem has been solved here.. check that link first
Use the class CL_ABAP_CONV_OUT_CE and use it to convert file from unicode to ascii.

Similar Messages

  • 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

  • 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 get the ASCII code instead of Unicode?

    If I use getNumericValue to return the Unicode of a character, I found out "a" = "A". Is there any way I can find out the different code for capital letter and small letter? I'm thinking about ASCII code, any suggestion for which method to return the ASCII code?

    That is not what getNumericValue does. (Try getNumericValue('*'), for example, and you will see it returns -1.) If you want to find the Unicode value of a character, simply cast the character to an int:char letter = 'A';
    int unicodeValue = (int)letter;If the character you chose was in the ASCII character set, you will automatically have its ASCII code, because ASCII is simply the first 128 characters in the Unicode character set.

  • Key Commands and  ASCII codes

    Hi
    Does anyone have a list or graphic of what characters ASCII numbers represent on the apple pro keyboard. There's a few key commands that I can't find.
    Also what key is this Ü and this ß.
    Thanks
    Marcel

    ß is option + s
    Ü is option + u, then U
    try: http://tlt.psu.edu/suggestions/international/accents/codemac.html

  • Weird Error with open dataset

    I am trying to read a .csv file using WS_upload. Please see the foll code:
    IF FILE1+0(1) <> '\'.
    CALL FUNCTION 'WS_UPLOAD'
         EXPORTING
             FILENAME = dataset
              FILENAME = FILE1
             FILETYPE = 'DAT'
              FILETYPE = 'ASC'
         TABLES
              DATA_TAB = rec.
    ENDIF.
    OPEN DATASET FILE1 IN TEXT MODE for INPUT.
    IF sy-subrc = 0.
      DO.
        READ DATASET FILE1 INTO rec2.
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
         WRITE / rec2.
          rec-INFO = rec2.
          APPEND REC.
        ENDIF.
      ENDDO.
    ENDIF.
    The system is behaving different when I run in foreground on our test server and it gives error while running on produciton server. The open dataset block does not execute on the test server but on production server it does. And it ahs suddenly started doing it with any CSV file.. including the ones which earlier it did not ahve any problem with. Because the open dataset block executes on the production server it adds around 10000 lines to the file... the file ofcourse contain all garbage values for eg gwrd.exe, instance.lst , car.exe, dll etc. I have no clue why this has started happening suddenly when it was not happeing 1 hour before.
    please help/
    thanks.

    Hi Pranav,
    For the first IF condition where you determine whether to use WS_UPLOAD or to call OPEN DATASET.
    What will happen if the first IF condition is satisfied? It will trigger the WS_UPLOAD logic and after that it will also try to trigger the OPEN DATASET logic rite?
    Did u check if the program is trying to trigger the OPEN DATASET also? Coz if its trying to call OPEN DATASET after trying to call WS_UPLOAD it might either end up in error or might try to read some junk.
    Try to use the MESSAGE option of OPEN DATASET command and see if there is any error message issued.
    Hope this helps
    Cheers
    VJ

  • Hi preventing parallel processing for a program treating open dataset

    Hi
    Has anyone come into a situation where he had to do an inbound interface
    (i.e using open dataset by scanning all the file in AL11)
    how do you treat program running in parallel in this situation.
    what i mean is that if the same program is doing an open dataset and treating the same file in al11.  Then inconsistencies may occur
    is there a way to lock a program that is running that is triggering an error message "

    Hi,
    I too faced a similar situation and this is what I implemented.
    Whenever your programs starts processing a particular AL11 File, Create a New Flag File in the Same Directory.
    Say if my file name is usr\bin\ABC.DAT, before OPEN DATASET command on this file, I would create a new file usr\bin\ABC.DAT.FLAG!!!.
    After the processing ABC.DAT is done, I delete the Flag File.
    In the mean time, If some other program, (or for that matter the same program) executes in a different session and tries to open the same file, we can check for the existence of the FLAG FILE.
    So the code is as follows.
    CHECK for the Existence of FLAG FILE.
    If FLAG FILE Exists, STOP. " another session is processing it.
    ELSE.
    CREATE FLAG FILE.
    OPEN DATASET, and rest others.
    CLOSE DATASET.
    ENDIF.
    Hope this helps.
    Thanks,
    Surya

  • Problem in the internal table of open dataset statement

    Hi abapers,
    I am using the open dataset command to download my file at application server into an internal table.
    But some colums of the internal table are string since i do not want to truncate any of the long text present in the file.
    The open dataset command does not allow the internal table to have string components.
    Is there any workaround by which i can download all the text components of the file without truncating them .
    Regards,
    Aditya

    try to use field symbols:-
    FORM download_file  .
      DATA: l_file TYPE  rlgrap-filename,
            l_line TYPE string.
      DATA: v_excel_string(1000) TYPE c,
              v_len TYPE i,
              v_zover TYPE i .
      FIELD-SYMBOLS: <f>     TYPE ANY .
      CLEAR wa_fin.
    *--- Seting File path
      CONCATENATE p_cfile v_file sy-datum INTO l_file.
    *--- Open data set
      OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        LOOP AT it_down INTO wa_down.
          CLEAR : v_excel_string, v_zover, v_len.
          DO.
            ASSIGN COMPONENT sy-index OF STRUCTURE wa_down TO <f>.
            IF sy-subrc <> 0.
              EXIT. "exits do loop and process next record in itab
            ENDIF.
            DESCRIBE FIELD <f> LENGTH v_len IN CHARACTER MODE.
            v_excel_string+v_zover(v_len) = <f> .
            v_zover = v_zover + v_len .
          ENDDO.
          TRANSFER v_excel_string TO l_file.
          CLEAR : v_excel_string,
                  wa_down       ,
                  v_zover       .
        ENDLOOP.
    *--- Close data set
        CLOSE DATASET l_file.
        IF sy-subrc = 0.
    *--- Success Message
         MESSAGE s000(000) WITH text-018.
        ENDIF.
      ELSE.
    *--- Error unable to open file.
        MESSAGE e000(000) WITH text-017.
      ENDIF.
    ENDFORM.                    " DOWNLOAD_FILE
    Thanks ,
    Ruchi Tiwari

  • OPEN DATASET hangs

    Hi,
             We have the SAP server and a File server connected by NFS mount. We have the ABAP program which is reading the files on the File server. Sometimes the NFS mount goes down and the ABAP program hangs on the open dataset command for more then 6 to 7 hrs and we need to cancel the program in SM66 or in some other transaction. Is there a function module or any other method to see if the NFS mount is available before the OPEN DATASET statement.
    Thanks For your help
    Ram

    You could create an external command in SM69 which checked the status of the NFS mount.  Execute the command with function SXPG_COMMAND_EXECUTE and read the output table to determine if the NFS moutn is functioning correctly.
    Regards,
    Steve.

  • Open dataset dump.

    hi guys,
    I am getting OPEN DATASET SHORTDUMP using below code.
    can somebody suggest me alteration of code..
    Dump says error in READ statement.
    DATA : BEGIN OF IT_EDIT OCCURS 0,
             CNO(5)         TYPE C,
             DATE(8)        TYPE C,
             VENDOR(10)     TYPE C,
             MATERIAL(18)   TYPE C,
             STARTDT(8)     TYPE C,
             ENDDT(8)       TYPE C,
             QUANTITY(13)   TYPE N,
           END OF IT_EDIT.
    OPEN DATASET P_INFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      DO.
        IF NOT SY-SUBRC IS INITIAL.
          EXIT.
        ELSE.
    <b>      READ DATASET P_OUFILE INTO IT_EDIT.</b>
          APPEND IT_EDIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET P_OUFILE.
    Regards
    Chandra.

    hi,
    pls chk this sample code.
    report zfiles_0001.
    Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
                d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
    data: itab type table of string.
    data: wa type string.
    start-of-selection.
    Read file
      open dataset d1 for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset d1 into wa.
          if sy-subrc <> 0.
            exit.
          endif.
          append wa to itab.
        enddo.
      endif.
      close dataset d1.
    Copy to new file
      open dataset d2 for output in text mode.
      loop at itab into wa.
        transfer wa to d2.
      endloop.
      close dataset d2.
    Delete the first
      delete dataset d1.
    regards
    anver
    if hlpful pls mark points

  • 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

  • Parsing Non English characters from OPEN DATASET

    Hi Team,
    I'm try to download the .txt file using the OPEN DATASET in the windows environment from application server, system language is set up for English.
    The problem is, in the .txt file some times I will be getting the non-English characters (Spanish). When I try to download the data into SAP it's not downloading properly eg: ñ when it downloaded into sap it took something like A+_.
    My goal is I need to download the Spanish characters properly into sap.
    Please advice how to solve this problem.
    Thanks,
    Selvaraj

    Hi Selvaraj!
    I haven't checked the situation for 4.5B, nor can I predict exact behavior, but you can give following statement a try:
    SET LOCALE LANGUAGE lg.
    This should even change content of sy-lange for whole role area (internal session), so change the value back afterwards.
    Regards,
    Christian

  • Open Dataset for XML not reading the XML file, Returning Code 8.

    Dear all,
    Im trying to open an XML file using Open Dataset, since i have to execute this report in background and GUI_upload doesnt work in background.
    The XML file is available in my C:\, say, C:\xmlfile.xml.
    But  the open dataset is not reading any value into the g_xml_line . it is returning sy-subrc = 8.
    Below is my code for that, can anybody help me out to resolve.
    DATA : lv_filename LIKE rlgrap-filename.
      CLEAR: lv_filename.
      lv_filename = p_input.
      OPEN DATASET lv_filename FOR INPUT IN BINARY MODE.
      IF sy-subrc ne 0.
        WRITE:/ 'invalid file'.
      else.
      DO.
        READ DATASET lv_filename INTO  g_xml_line.
        IF sy-subrc EQ 0.
          APPEND g_xml_line TO g_xml_table.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET lv_filename.
       ENDIF.
    TYPES: BEGIN OF t_xml_line,
            data(256) TYPE x,
          END OF t_xml_line.
    DATA: g_xml_table       TYPE TABLE OF t_xml_line,
          g_xml_line        TYPE t_xml_line,
          g_xml_table_size  TYPE i.
    GET REFERENCE OF gt_person INTO gs_result_xml-value.
      gs_result_xml-name = 'IPIX'.
      APPEND gs_result_xml TO gt_result_xml.
    Perform the XSLT stylesheet
      TRY.
          CALL TRANSFORMATION zaum_manh_sync_rpt
          SOURCE XML g_xml_table
          RESULT (gt_result_xml).
        CATCH cx_root INTO gs_rif_ex.
          gs_var_text = gs_rif_ex->get_text( ).
          MESSAGE gs_var_text TYPE 'E'.
      ENDTRY.
    Kindly suggest me a solution. Points assured
    regs,
    raja

    After saving the file , below is the code i wrote, but it gives a runtime error with message
    No roll storage space of length 3788808 available for internal storage.
    ***Coding****
    PARAMETERS: p_file TYPE pathintern LOWER CASE DEFAULT '/usr/sap/DEV/SYS/global/XMLABAP2.XML'.
    DATA : lv_filename LIKE rlgrap-filename.
      CLEAR: lv_filename.
      lv_filename = p_file.
      DATA: l_fname TYPE filename-fileintern. " File name
    *GET THE FILENAME FROM THE APPLICATION SERVER
      CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
        EXPORTING
          directory        = p_file
          filemask         = '*'
        IMPORTING
          serverfile       = l_fname
        EXCEPTIONS
          canceled_by_user = 1
          OTHERS           = 2.
      IF sy-subrc NE 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    */usr/sap/DEV/SYS/global/substanc
      lv_filename = l_fname.
      OPEN DATASET lv_filename FOR INPUT IN BINARY MODE.
      IF sy-subrc NE 0.
        WRITE:/ 'invalid file'.
      ELSE.
        DO.
          READ DATASET lv_filename INTO  g_xml_line.
       IF sy-subrc EQ 0.
          APPEND g_xml_line TO g_xml_table.
       ELSE.
         EXIT.
       ENDIF.
        ENDDO.
        CLOSE DATASET lv_filename.
      ENDIF.

  • How can we write the code for opening the command prompt and closing the

    how can we write the code in java for opening the command prompt and closing the cmd prompt from eclipse (cmd prompt should close when click on the turminate button in eclipse)

    rakeshsikha wrote:
    how can we write the code for opening the command prompt and closing theBy typing in Eclipse (which you seemingly have)?

  • Error opening dataset, return code:        8

    Hi,
    I'm passing the information from a txt to a transparente table. The problem is that it throws me the following message: Error opening dataset, return code:        8  .
    When I debug it the first row of information enters to the internal table but after it this erro comes.
    The code is the following:
    DATA: BEGIN OF record,
    data element: TABNAME
            tablename_001(030),
    data element: DESCR40
            des_002(040),
    data element: TYKLA
            tipo_003(015),
    data element: QUANTITY_I
            quan_004(011),
    data element: PRICE
            precio_005(021),
    data element: TOT01
            total_006(017),
          END OF record.
    End generated data section ***
    DATA:
    BEGIN OF i_tabla OCCURS 0,
    dest(40),
    type(15),
    quan(10),
    precio(15),
    tot(15),
    END OF i_tabla.
    PARAMETERS:
    p_user LIKE apqi-userid OBLIGATORY DEFAULT  sy-uname,
    p_fich LIKE rlgrap-filename OBLIGATORY
    DEFAULT: 'C:\Documents and Settings\lseri\My Documents\Book1.txt'.
    START-OF-SELECTION.
      CALL FUNCTION 'UPLOAD'
       EXPORTING
      CODEPAGE                      = ' '
         filename                      = p_fich
         filetype                      = 'DAT'
        TABLES
          data_tab                      = i_tabla
       EXCEPTIONS
         conversion_error              = 1
         invalid_table_width           = 2
         invalid_type                  = 3
         no_batch                      = 4
         unknown_error                 = 5
         gui_refuse_filetransfer       = 6
         OTHERS                        = 7
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      PERFORM open_dataset USING dataset.
      PERFORM open_group.
      LOOP AT i_tabla FROM 2.
    PERFORM bdc_dynpro      USING 'SAPLSETB' '0230'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'DATABROWSE-TABLENAME'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=ANLE'.
        PERFORM bdc_field       USING 'DATABROWSE-TABLENAME'
                                      record-tablename_001.
        PERFORM bdc_dynpro      USING '/1BCDWB/DBZSTOCK_TEST' '0101'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'ZSTOCK_TEST-TOTAL'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=SAVE'.
        PERFORM bdc_field       USING 'ZSTOCK_TEST-DES'
                                      record-des_002.
        PERFORM bdc_field       USING 'ZSTOCK_TEST-TIPO'
                                      record-tipo_003.
        PERFORM bdc_field       USING 'ZSTOCK_TEST-QUAN'
                                      record-quan_004.
        PERFORM bdc_field       USING 'ZSTOCK_TEST-PRECIO'
                                      record-precio_005.
        PERFORM bdc_field       USING 'ZSTOCK_TEST-TOTAL'
                                      record-total_006.
        PERFORM bdc_dynpro      USING '/1BCDWB/DBZSTOCK_TEST' '0101'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/EBACK'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'ZSTOCK_TEST-DES'.
        PERFORM bdc_dynpro      USING 'SAPLSETB' '0230'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/EBACK'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'DATABROWSE-TABLENAME'.
        PERFORM bdc_transaction USING 'SE16'.
      ENDLOOP.
      PERFORM close_group.
      PERFORM close_dataset USING dataset.
    Please help me!
    Thanks

      open dataset                                                       *
    FORM OPEN_DATASET USING P_DATASET.
      OPEN DATASET P_DATASET
                   FOR INPUT IN TEXT MODE
                   ENCODING DEFAULT.
      IF SY-SUBRC <> 0.
        WRITE: / TEXT-E00, SY-SUBRC.
        STOP.
      ENDIF.
    ENDFORM.
      create batchinput session                                          *
      (not for call transaction using...)                                *
    FORM OPEN_GROUP.
      IF SESSION = 'X'.
        SKIP.
        WRITE: /(20) 'Create group'(I01), GROUP.
        SKIP.
      open batchinput group
        CALL FUNCTION 'BDC_OPEN_GROUP'
             EXPORTING  CLIENT   = SY-MANDT
                        GROUP    = GROUP
                        USER     = USER
                        KEEP     = KEEP
                        HOLDDATE = HOLDDATE.
        WRITE: /(30) 'BDC_OPEN_GROUP'(I02),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ENDIF.
    ENDFORM.
    I'm using these performs because they appeared automatically when the recording became a program.

Maybe you are looking for

  • Carriage Return in Input Parameter

    Hello, My report is passed an address string in a parameter like: name addressline1 city state zip. I want to display this like: name addressline1 city state zip In that past, when I have name, address1, and citystatezip in separate fields I use a fo

  • Corrupted date and string in oracle 8.1.6 (WL 8.1)

    i got problem inserting some date and varchar2 column in Oracle 8.1.6, using WL 8.1 (Oracle's Driver (Thin) Versions: 8.1.7,9.0.1,9.2.0) the date and varchar column are corrupted!

  • How to compare field symbols

    Dear experts, I have a piece of code like this.. ASSIGN (lv_field)  TO <f1>.       IF NOT <f1> IS INITIAL.         CONCATENATE 'IS_BUS000_EEW' '-' lv_fieldname INTO lv_field.         ASSIGN (lv_field)  TO <f1>.         CONCATENATE 'LS_BUT000-' lv_fie

  • HT1535 Removing music from iPad

    I Share an iTunes account with my husband and somehow his purchased music has ended up on my iPad.  I cannot get rid of it.  I have deleted it, but it still resides on the iPad.  I have turned of the "show all music" button, I have turned off the "au

  • Setup of axis in 3D graph

    Hi, I just have a (simple) question, I need to set up the right graph (the black one) as the right one (the white one). I want it to show three independent axis (x,y,z), going out from the center (0,0,0), just like in the white graph, but I really ca