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.

Similar Messages

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

  • 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

  • Device type file compatability with different SAP versions

    Hi All,
             I need to know whether there is any difference in Device type file (.PRI) for different SAP versions [ SAP 4.6b , 4.6c, 4.7, mySAP ERP 2005.,]
             Is there any change in .pri file required when upgrading/degrading SAP versions?
            Pls let me know abt this. very urgent..

    i tried the following code on a WAS 7.00 SP14 and it works as expected.
    create object cached_response type cl_http_response exporting
      add_c_msg = 1.
        cached_response->set_data( file_content ).
        cached_response->set_header_field( name  =
      if_http_header_fields=>content_type
                                           value = file_mime_type ).
        cached_response->set_status( code = 200 reason = 'OK' ).
        cached_response->server_cache_expire_rel( expires_rel = 180 ).
        call function 'GUID_CREATE'
          importing
            ev_guid_32 = guid.
        concatenate runtime->application_url '/' guid into display_url.
        cl_http_server=>server_cache_upload( url      = display_url
                                             response = cached_response ).
    call method runtime->server->response->redirect( url = display_url ).
    navigation->response_complete( ).

  • Is it possible to execute same eCATT  script in different SAP versions

    is it possible to execute same eCATT  script in different SAP versions?
    Regards,
    Sunil sankar B.
    [email protected]

    Yes. In the ecatt script you have the option under ATTRIBUTES --> VERISONING DATA you can restrict it to different software components and different releases.

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

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

  • 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

  • Reports excuting in different sap version

    Hi All,
    I am downloading Reports from 3.1G to SAP R/3 Enterprise version and executing. Many reports not giving me the output even data is available. Can anyone tell me what could be the main reasons, if anyone  already come across.

    Hi!
    So if your programs are correct, is your data still <i>exactly</i> the same? Maybe some user-exits had filled additional fields - which are now empty and your selects don't find anymore something.
    Also some standard tables are filled in a different way - or just simply some customizing has changed and document types / line types / ... are different now.
    Check, if your data is really same as in 3.1G system.
    Regards,
    Christian

  • File download via BSP using different SAP versions

    Hi Everyone,
    I have been using code based on Brian McKellar's excellent Blog (/people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents). The code works great in the following system:
    SAP_BASIS     620     0038     SAPKB62038     SAP Basis Component
    SAP_ABA     620     0038     SAPKA62038     Cross-Application Component
    However i am now trying the same code in our new 7.00 SAP system which is a
    SAP_ABA     700     0013     SAPKA70013     Cross-Application Component
    SAP_BASIS     700     0013     SAPKB70013     SAP Basis Component
    When I try it in our 7.00 system, the download does not work. It tells me that the document is incomplete or corrupted.
    Specifically the code that is being used is as follows:
    data: cached_response type ref to if_http_response,
           lv_xlen type i,
           lv_guid type guid_32.
    create object cached_response
           type cl_http_response exporting add_c_msg = 1.
    lv_xlen = xstrlen( lv_xstring ).
    cached_response->set_data( data   = lv_xstring
                        length = lv_xlen ).
    cached_response->set_header_field(
          name  = if_http_header_fields=>content_type
          value = lv_mtype_string ).
    cached_response->set_status( code = 200 reason = 'OK' ).
    cached_response->server_cache_expire_rel( expires_rel = 120 ).
    call function 'GUID_CREATE'
      importing
        ev_guid_32 = lv_guid.
    concatenate runtime->application_url '/' lv_guid '.'
                lv_doc_hdr-obj_type
                into lv_cached_url.
    cl_http_server=>server_cache_upload( url      = lv_cached_url
                                         response = cached_response ).
    call method runtime->server->response->redirect( url = lv_cached_url ).
    navigation->response_complete( ). " signal that response is complete
    So now I have a choice: I can log an OSS but I doubt SAP will help as this is 'custom code'. It is in our Z BSP.
    Can anyone suggest how I can even begin to debug this issue?
    Regards,
    Alon

    i tried the following code on a WAS 7.00 SP14 and it works as expected.
    create object cached_response type cl_http_response exporting
      add_c_msg = 1.
        cached_response->set_data( file_content ).
        cached_response->set_header_field( name  =
      if_http_header_fields=>content_type
                                           value = file_mime_type ).
        cached_response->set_status( code = 200 reason = 'OK' ).
        cached_response->server_cache_expire_rel( expires_rel = 180 ).
        call function 'GUID_CREATE'
          importing
            ev_guid_32 = guid.
        concatenate runtime->application_url '/' guid into display_url.
        cl_http_server=>server_cache_upload( url      = display_url
                                             response = cached_response ).
    call method runtime->server->response->redirect( url = display_url ).
    navigation->response_complete( ).

  • Open zip file with the OPEN DATASET statement.

    How?
    The zip file is a text file compressed.
    Thanks for answers.

    in application server no ZIP files exist...as such flat files exist which can be read using DATASET concept.

  • Unicode Open Dataset Question

    We are beginning to prepare for the Unicode enabling of our custom ABAP programs and I have a question about the new OPEN DATASET statement.  We have programs that write sequential files for use by the following:
    1) ABAP programs that execute on our own SAP system
    2) Non-SAP programs that execute in our data center
    3) Programs (which may or may not be SAP) that execute in the data centers of other completely independent companies.
    Conversely, we have programs that read files supplied by those systems. 
    After reading through a lot of information, I am reaching the conclusion that for our files that contain only character data, it would be safe for us to modify our OPEN DATASET statements simply to use u201COPEN DATASET IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORSu201D without attempting to be more explicit with some of the other options that are available. 
    Can any of you confirm that this is (or is not) a valid assumption?

    yes you can go ahead with that..for the text files and chardata files
    OPEN DATASET IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORSu201D

  • 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 in ECC6.0

    Hi Guys,
    We are upgrading from 4.6c to ECC 6.0 and a lot of our programs are giving unicode compliance error on the OPEN DATASET statement. Even though we are moving to a unicode system, the systems we talk to are not unicode compliant yet so we donot want to read/write files in unicode format yet. After a lot of research I am still consfused between the following 2 statements. Which one should we use?
    OPEN DATASET O_DSN FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE
    OR
    OPEN DATASET O_DSN FOR OUTPUT IN LEGACY TEXT MODE.
    Does anyone know if they are any different or both serve the same purpose?
    We basically want to retain the same functionality as was in 4.6c when it comes to read/write files...
    Please suggest
    Thanks,
    Sanket

    IN LEGACY BINARY MODE [CODE PAGE cp]
    Data is read or written in a form which is compatible to BINARY MODE in Releases <= 4.6. This addition is primarily used to convert a file into the code page format specified already when it is opened. At runtime, the system uses the format of the system code page of the application server. The system saves the file then again in the code page specified. This procedure is important if data is exchanged between systems using different code pages.
    IN LEGACY TEXT MODE [CODE PAGE cp]
    Data is read or written in a form which is compatible to BINARY MODE in Releases <= 4.6. This addition is primarily used to convert a file into the code page format specified already when it is opened. At runtime, the system uses the format of the system code page of the application server. The system saves the file then again in the code page specified. This procedure is important if data is exchanged between systems using different code pages.
    For more information, check the below link.
    [http://www.s001.org/ABAP-Hlp/abapopen_dataset.htm|http://www.s001.org/ABAP-Hlp/abapopen_dataset.htm]
    Hope this helps.
    Thanks,
    Balaji

Maybe you are looking for

  • Triangle Intercept Theorem -

    import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import javax.swing.JFrame; import javax.swing.JPanel; public class G {     CardLayout ca

  • Post 10.4.11 problems w/attachments & .mac account

    Two problems which have come up since updating to 10.4.11. Whether it's an OS issue or not I don't know. 1) When I attach a QT movie to an email, instead of the player showing up in the message body at its normal size it views as this tiny little thi

  • Cannot install or uninstall, or launch iTunes

    My father-in-law's computer has iTunes for Windows XP. At present, clicking the iTunes icon, or selecting iTunes from Start:Programs, launches an iTunes installer. The InstallShield process runs, and the software seemingly installs OK. However, when

  • Itunes ringtones and text tones not working??

    I downloaded a ring tone and a text tone, from the itunes store,and it was working great for about three weeks.  I lost charge on my phone yesterday and soon as I powered back up the default ringtones have seemed to take over even though my tones are

  • MacBook Pro 17" Santa Rosa and 64-bits strange issue...

    Hi all, my MacBoo Pro 17" Intel Core 2 Duo 2,4GHz under SL 10.6.5 seems to be able to boot in 64 bits, so I edited the com.Apple.boot.plist in order to do so. I rebooted fine but as I'm going to Informations System, it shows that the Kernel didn't bo