Regarding Transfer statement in OPEN DATASET

Hi All,
I am calling call transformation statement twice in my program and creating 2 xml files.
One as lv_xml_string
Second one as lv_xml_string1.
When i transferred the first xml file using open dataset to the application server its coming fine.
When i am trying to send the second one it is appending to the first one.
I want output 2 files not as single one.
Can anyone suggest me what to do?
Thanks

Thanks for the reply.
I did that but i cannot see the first file. It is writing the second file.
I need 2 xml files in the output
Any other advice please?

Similar Messages

  • File transfer Problem with open dataset

    I am transfering file in ECC6.0 unicode system to nonsap.In al11 transaction the file has the '#' symbol in the text field.But while downloading to local system to upload other legasy it is taking as Tab.so the file is corrupting.I have tried with field symbols also it is not working.Can any one help on this..
    Thanks in advance,
    Bhagya

    Hi Bhagya,
    in Unicode systems, AL11 expects files to contain data encoded in UTF-8 - hence if the file contains UTF-8, the transaction will work. In case of Non-Unicode, special characters will be displayed as '#'.
    One workaround could be  to convert the data to UTF-8 e.g. with tools described in 747615.
    Best regards,
    Nils Bürckel
    Solution Management
    Globalization Services
    SAP AG

  • In OPEN DATASET Statement Filenames are platform-specific How to specify MS

    In OPEN DATASET Statement
    Filenames are platform-specific. You must therefore use file- and pathnames that conform to the rules of the operating system under which your R/3 System is running. However, you can also use logical filenames to ensure that your programs are not operating system-specific. For further information, refer to Using Platform-Independent Filenames.
    DATA FNAME(60).
    FNAME = '/tmp/myfile'.
    OPEN DATASET 'myfile'.
    OPEN DATASET FNAME.
    This example works as long as your R/3 System is running under UNIX. The program opens the file "myfile" in the directory in which the R/3 System is running, and also opens the file "myfile" in directory "/tmp".
    FNAME = '[TMP]myfile.BIN'
    OPEN DATASET 'myfile.BIN'.
    question]]  How to specify an MS-file & how to go about?

    Hi,
    Just get the input file name from the application server through selection screen and keep it in parameter(p_inpfile).
    Then pass the parameter to OPEN DATASET statement.
    OPEN DATASET p_inpfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        WRITE :/ text-004.                                   "'No such input file' COLOR 3.
        EXIT.
      ELSE.
        DO.
          CLEAR : wa_string,wa_0001.
    *Reading the file from application server and moving to work area*
          READ DATASET p_inpfile INTO wa_string.
          IF sy-subrc NE 0.
            EXIT.
          ELSE.
            CLEAR wa_0001.
    *Spliting fields in the file-
            REPLACE ALL OCCURRENCES OF '#' IN wa_string WITH ' '.
            SPLIT wa_string AT c_htab INTO wa_0001-pernr
                                           wa_0001-werks       "Personnel Area
                                           wa_0001-persk       "Employee Sub-Group
                                           wa_0001-vdsk1       "Org. Key
                                           wa_0001-abkrs       "Payroll area
                                           wa_0001-ansvh.      "Work contract
            wa_0001-begda = p_efdate.
            wa_0001-endda = '99991231'.
            APPEND wa_0001 TO int_0001.
          ENDIF.
        ENDDO.
        CLOSE DATASET p_inpfile.
    Use like this and pass all those values to internal table.
    Thanks,
    Sakthi C
    *Rewards if useful*

  • Unable to create a file in Application Server using OPEN DATASET stattement.

    I am unable to create a file in Application Server using the following statement.
    OPEN DATASET filename FOR OUTPUT
    IN TEXT MODE ENCODING DEFAULT
    MESSAGE msg.
    The message I'm getting is "Permission Denied". I have checked authorisation using SU53 which says "The last authorization check was successful". Please help.

    You can use following code to capture the error.
    TRY.
          OPEN DATASET filename FOR OUTPUT IN BINARY MODE MESSAGE V_MSG.
          CATCH CX_ROOT
          INTO EXCEPTION.
          CALL METHOD O_EXCEPTION ->IF_MESSAGE~GET_TEXT
            RECEIVING
            RESULT = V_MSG.
          MESSAGE v_msg
          TYPE 'E'.
    ENDTRY.
    You can capture error in v_msg.
    Following are the exceptions for the same:
    Exceptions
    Catchable Exceptions
    CX_SY_FILE_OPEN
    Cause: The file is already open.
    Runtime Error: DATASET_REOPEN
      CX_SY_CODEPAGE_CONVERTER_INIT   
    Cause: The desired conversion is not supported. (Due to specification of invalid code page or of language not supported in the conversion, with SET LOCALE LANGUAGE.)
    Runtime Error: CONVT_CODEPAGE_INIT
    CX_SY_CONVERSION_CODEPAGE
    Cause: Internal error in the conversion.
    Runtime Error: CONVT_CODEPAGE
    CX_SY_FILE_AUTHORITY
    Cause: No authorization for access to file
    Runtime Error: OPEN_DATASET_NO_AUTHORITY
    Cause: Authorization for access to this file is missing in OPEN DATASET with addition FILTER.
    Runtime Error: OPEN_PIPE_NO_AUTHORITY
      CX_SY_PIPES_NOT_SUPPORTED   
    Cause: The operating system does not support pipes.
    Runtime Error: DATASET_NO_PIPE
    CX_SY_TOO_MANY_FILES
    Cause: Maximum number of open files exceeded.
    Runtime Error: DATASET_TOO_MANY_FILES   Non-Catchable Exceptions   
    Cause: An attempt was made to open a pipe that is already open.
    Runtime Error: DATASET_PIPE_POSITION
    Hope that will help you.
    Please reward if useful.

  • Dump on OPEN DATASET ; TRANSFER stmt

    p_name is the file name parameter
    FORM APPL_TRAN.
      file = p_name.
      OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        CLEAR wa_final.
    Loop through the internal table which has the ECC data and transfer it to the file.
        LOOP AT it_final  into wa_final.
          TRANSFER wa_final to file.
          CLEAR wa_final.
        ENDLOOP.
    *Close the file.
        CLOSE DATASET file.
      ENDIF.
    ENDFORM.                    "APPL_TRAN
    I'm getting a short dump when the stmt TRANSFER is executed.
    The Error Analysis is as follows:
    For the statement
       "TRANSFER f TO ..."
    only character-type data objects are supported at the argument position
    "f".
    In this case. the operand "f" has the non-character-type "TY_ECC2". The
    current program is a Unicode program. In the Unicode context, the type
    'X' or structures containing not only character-type components are
    regarded as non-character-type.
    Can someone please help me in this regard.
    Thanks,
    FS

    hi,
    ur internal table it_final declaration is like this
    data : begin of it_final occurs 0,
              matnr(18),
              werks(4),
             end of it_final.
    in this situation ur statement
    OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    works then u wont get any dump in transfer statement.
    so u replace
    OPEN DATASET file FOR OUTPUT IN BINARY MODE .
    it works.
    regards
    siva

  • OPEN DATASET and TRANSFER

    Hi all,
    I open Dataset in Text Mode with default encoding and trying to transfer data from an internal table to TEXT file in application server.
    But my internal table has 1 numeric field, so while transfering i am getting error stating: "cannot write Non-chracter field".
    So, is there any way to write Non-character fields also using same OPEN Dataset and TRANSFER Statements.
    Help will be rewarded.
    Sachin

    Hi  Saching..
    As per UNICODE We cannot transfer Numeric fields to file .
    So We must convert the Record to Character format.
    This is the Modified code. Changes are in BOLD.
    TABLES: ZSACHIN_STUDENT.
    PARAMETERS:
    OUTFILE(20) DEFAULT 'sachin_test.txt'
    LOWER CASE.
    TYPES: BEGIN OF st_student,
    ID TYPE ZSACHIN_STUDENT-ID,
    NAME TYPE ZSACHIN_STUDENT-NAME,
    ADDRESS TYPE ZSACHIN_STUDENT-ADDRESS,
    STATE TYPE ZSACHIN_STUDENT-STATE,
    CITY TYPE ZSACHIN_STUDENT-CITY,
    STATUS TYPE ZSACHIN_STUDENT-STATUS,
    END OF st_student.
    DATA : it_student TYPE STANDARD TABLE OF st_student,
    it_student_wa TYPE st_student.
    <b>DATA: V_RECORD(200) TYPE C.</b>
    OPEN DATASET OUTFILE FOR OUTPUT IN TEXT MODE encoding default.
    IF sy-subrc <> 0.
    message e001(z_error).
    endif.
    SELECT * FROM ZSACHIN_STUDENT INTO
    CORRESPONDING FIELDS OF TABLE it_student.
    <b>LOOP AT it_student INTO it_student_wa.
    <b>CONCATENATE IT_student_wa-name
                             IT_student_wa-address
                             IT_student_wa-state
                             IT_student_wa-city
                             IT_student_wa-status
                             INTO V_RECORD
       SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    TRANSFER V_RECORD TO OUTFILE.</b>
    ENDLOOP.</b>
    CLOSE DATASET OUTFILE.
    Here SEPARATED BY is for generating  TAB delimiter .
    <b>Reward if Helpful</b>

  • 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

  • Error with OPEN DATASET Statement

    Hi All,
    I have a an executable program which downloads data into applcation server using OPEN DATASET statement.
      Following is my code:
    OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc      NE 0
         MESSAGE e111 WITH text-003.
         ENDIF.
    Text 003 is 'Error Opening File'.
    sy-subrc becomes non-zero if file cannot be opened for writing.
    Daily I am running this program in a background job. I am getting this error on and off. Some times I am able to create the file in application server and  sometimes this error comes up by cancelling the job. The message shown for the cancelled job along with text-003 is 'Job cancelled after system exception ERROR_MESSAGE'. This has no dump analysis.
    Even When I run this program online I am facing the same issue.
    Some users never faced this issue while others have this problem. I think it is not an authorization problem as I am able to create flat file in application server most of the times.
    Can you please suggest what could have went wrong?
    And kindly propse me a solution.
    Thanks & Regards,
    Paddu.

    Hi Paddu,
    I am not sure exactly but i would go as far as saying that the reason you may be having that error is because your server has a limited amount of space and that your program is not working due to that limitation.
    Is that file that you have created being picked up by another application. If so then i would advise you to check the limitation of the server size.
    Also, is your file name different all the time? if u r trying to write an already existing file name it will give u an error.
    Edited by: Kevin Ck on Mar 9, 2009 10:19 AM

  • 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

  • Data transfer error open dataset files

    hi,
    When i try to create a excel or text in my application server using open dataset.
    i.e
    l_filename type rlgrap-filename  value '/tmp/down.txt'.
    I got a short dump during the run time
    i got the output and put into an internal table.
    the following code has been used.
    form user_command using r_ucomm like sy-ucomm
    rs_selfield  type slis_selfield.
    if r_ucomm = 'confirm' .
    OPEN DATASET l_fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT it_out INTO wa_out.
      IF sy-subrc = 0.
        TRANSFER wa_out TO l_filename.
      ENDIF.
    ENDLOOP.
    endform.
    during the execution i hv a button alv grid outpu. when i click the button the file should be transferred.
    but NO authorization to open the file "/tmp/down.txt".
    and the error is pointed in the opendataset line.
    Please tell me where i am wrong . and  help me in resoving this.

    Try this..instead of moving field by field into the file 1st convert all he fields to a character stream..and then move that steam to file. Ex:
    loop at internal table into l_h_tbl_file.
    concatenate l_h_tbl_file-f1 l_h_tbl_file-f2 l_h_tbl_file-f3
    l_h_tbl_file-f4 l_h_tbl_file-f5 into g_string.
    TRANSFER g_string TO fu_wk_get_file.
    endloop.

  • Open dataset statement in different SAP versions

    Hi ,
    I have to write a program which is for extracting data from application server. I have to run this program on different sap versions like, 4.6b, 4.6c, 4.7, 5.0 . I am using 'OPEN DATASET' statement in my program. But the problem is, in versions below 4.6c, this statement is written as "OPEN DATASET filename FOR READING IN TEXT MODE".
    And in versions above 4.7 it is written as "OPEN DATASET filename FOR READING IN TEXT MODE DEFAULT ENCODING".
    So when this statement will be executed in versions below 4.6c, it will give syntax errors.
    Can you let me know how to solve this problem.
    Thanks.

    Hi,
    differ btw. syst-SAPRL
    -> if you get syntax-error create a subroutine-pool
    with abap command generate subroutine...
    A.

  • In OPEN DATASET statement to open a file

    In OPEN DATASET statement
    To open a file, the user under which the R/3 System is running must have the requisite authorizations at operating system level.
    How to do this ? what knowledge apart from ABAP do I need ?
    what is its requirement in prograqmming domain?

    Hi,
    You can consult Basis people to get this authorization for OS folders for your login ID.
    From programming point of view, you need to put OPEN DATASET keyword inside try...catch block to avoid the short dump due to authorization issue as below.
    try.
    open dataset <....>
    catch CX_SY_FILE_AUTHORITY into wa_error.
    w_text = wa_error->IF_MESSAGE~GET_TEXT.
    write:/ w_text.
    endtry.
    hope that helps

  • Question re ENCODING cp option of OPEN DATASET statement

    I'm working on a 6.0 system with 4.6 data that I've downloaded from the 4.6 system and uploaded to the 6.0 system.
    The 4.6 data has "umlauts" in it (like when "o's" have two dots above them in Scandinavian names), and  when my READ DATASET executes on the 6.0 server, my try block is catching  a CX_SY_CONVERSION_CODEPAGE error.
    I'm assuming that to solve this, I will need to specify the codepage of the 4.6 server in the ENCODING codepage option of the OPEN DATASET statement that's exceuting on the 6.0 server.
    Will this solve the problem?  If not, what do I try next ?
    Also, how can I determine the system codpage of my current ABAP "text environment"?  I know all the possibilities are in table TCP0P, but how do I know which one is "active" ???
    Thanks guys.

    Hi,
    Refer this OPEN DATASET in ECC6.0 solves your problem and also check the abap documentation for system codepage and text environment.
    For unicode systems,system code page is UTF-16.
    Thanks.
    Ramya.

  • OPEN dataset statement

    Hi folks,
    I have a file stored on the network shared drive. Can I read the file using open dataset statement. This file is not stored on the application server.
    I have read that the open dataset statement works for only with the files stored in the application server.
    thanks
    sankar

    Hi
    Go thru this code, it will help you,.
    See the use of open dataset statement here.
    Pls reward if help.
    Refer this:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
    ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
    *& Report  ZUPLOADTAB                                                  *                     &----
    *& Example of Uploading tab delimited file                             *
    REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/'..
    DATA: ld_file LIKE rlgrap-filename.
    *Internal tabe to store upload data
    TYPES: BEGIN OF t_record,
        name1 like pa0002-VORNA,
        name2 like pa0002-name2,
        age   type i,
        END OF t_record.
    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
          wa_record TYPE t_record.
    *Text version of data table
    TYPES: begin of t_uploadtxt,
      name1(10) type c,
      name2(15) type c,
      age(5)  type c,
    end of t_uploadtxt.
    DATA: wa_uploadtxt TYPE t_uploadtxt.
    *String value to data in initially.
    DATA: wa_string(255) type c.
    constants: con_tab TYPE x VALUE '09'.
    *If you have Unicode check active in program attributes then you will
    *need to declare constants as follows:
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    *START-OF-SELECTION
    START-OF-SELECTION.
    ld_file = p_infile.
    OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    ELSE.
      DO.
        CLEAR: wa_string, wa_uploadtxt.
        READ DATASET ld_file INTO wa_string.
        IF sy-subrc NE 0.
          EXIT.
        ELSE.
          SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                          wa_uploadtxt-name2
                                          wa_uploadtxt-age.
          MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
          APPEND wa_upload TO it_record.
        ENDIF.
      ENDDO.
      CLOSE DATASET ld_file.
    ENDIF.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *!! Text data is now contained within the internal table IT_RECORD
    Display report data for illustration purposes
      loop at it_record into wa_record.
        write:/     sy-vline,
               (10) wa_record-name1, sy-vline,
               (10) wa_record-name2, sy-vline,
               (10) wa_record-age, sy-vline.
      endloop.

  • Runtime Error in OPEN DATASET

    Dear All,
    I am trying to upload a text file in application server. But I am getting the run time error which says-
    " For the statement
        "TRANSFER f TO ..."
    only character-type data objects are supported at the argument position
    "f".
    In this case. the operand "f" has the non-character-type "u". The
    current program is a Unicode program. In the Unicode context, the type
    'X' or structures containing not only character-type components are
    regarded as non-character-type."
    If I remove the quantity fields then the error does not happen. But I have to take quantity fields also. Plz tell me what to do. My code is,
    DATA FILENAME like rlgrap-filename VALUE 'MIGO_VALUE.txt'.
    TABLES VBAK.
    DATA D_MSG_TEXT(50).
    DATA : BEGIN OF it_mseg OCCURS 0,
           mblnr TYPE mseg-mblnr,
           mjahr TYPE mseg-mjahr,
           matnr TYPE mseg-matnr,
    *       erfmg TYPE mseg-erfmg,
           werks TYPE mseg-werks,
           lgort TYPE mseg-lgort,
           END OF it_mseg.
    DATA wa LIKE it_mseg.
    SELECT mblnr mjahr matnr werks lgort FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_mseg WHERE bwart = '101'.
    SORT it_mseg BY mblnr.
    OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
                          MESSAGE D_MSG_TEXT.
    if sy-subrc eq 0.
    message 'File created succesfully in SAP System'(002) type 'S'.
    endif.
    IF SY-SUBRC NE 0.
      WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.
      EXIT.
    ENDIF.
    * Transferring Data
    LOOP AT it_mseg INTO wa.
    TRANSFER wa to filename.
    ENDLOOP.
    * Closing the File
    CLOSE DATASET FILENAME.
    Thanks,
    Tripod.

    Thanks Sri for your help. I tried to apply the logic, but the  error i am getting here is -
    "IT_MSEG-ERFMG" must be a character-like data object (data type C, N,D, T, or STRING) STRING).
    Same case here, if I remove ERFMG field, i do not get such error.
    data ld_string type string.
    LOOP AT it_mseg INTO wa.
      CONCATENATE it_mseg-mblnr it_mseg-mjahr it_mseg-matnr it_mseg-erfmg it_mseg-werks it_mseg-lgort INTO ld_string.
         endloop.
    With regards,
    Tripod.

Maybe you are looking for