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*
Similar Messages
-
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. -
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. -
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
sankarHi
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 -
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 -
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,
Adityatry 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 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.
-
half my apps have suddenly stopped working and have become unmovable, these unresponsive ones are also in places overlapped by the working apps? Do I need to reset? Or maybe sync?
Go for the reset. Hold down the Sleep and the Home buttons until the Apple logo displays on the screen. This will not have any effect on your data.
-
Hi all,
The abstract of my problem is as follows.
I have to use both the AT POSITION and FILTER Optinns in Open dataset statement.
e.g Open dataset <dsn> in <Mode>
AT POSITION <pos>
FILTER <command>
But when i execute this, i get a syntax error at this line stating that i can only use filter and at poition at one place even though i put then one after the other.
Is there any way i can use both the additions?
If yes,How? and If no.. are there any alternatives?
Thanks in advance..
SravanHi sravan,
1. As mentioned, use two statement.
One shot statement cannot work.
2. try this code(just copy paste)
it will do what u want.
Try with commenting / uncommenting the line
of SET DATASET
and u will know the difference.
[mention proper filename in the code]
3. REPORT abc.
DATA : fname(100) TYPE c.
DATA : lin(100) TYPE c.
fname = '/tmp/arv'.
OPEN DATASET fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
comment/uncomment
*SET DATASET fname POSITION 10.
READ DATASET fname INTO lin.
WRITE lin.
regards,
amit m.
Message was edited by: Amit Mittal -
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 -
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,
SanketIN 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 -
Open dataset fails...says "error opening input file"
Hi,
I am trying to open a file in my BDC program and get the following error "error opening input file". Its a text file with continuous data. No delimiters and hence character count will be used to parse the data.
I am using the following statement to open it..
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
but sy-subrc is set to 8 !!
what could be the problem ??
thanksThis is pretty confusing !!I would explain to you my exact issue !!
I have a program in which there is no GUI_UPLOAD call but just a direct open dataset statement !!
This program runs fine for my collegue who has the file in a server (not the application server). She gives the full path name as
servername\foldername\filename.
I tried doing the same but as I did not have access to that server, it failed. So I received that file from her and stored it in my local system. So on program execution, i gave the path as c:\filename and I got the error message "Error opening the file"
Find below some code extracts..
PARAMETERS : p_sname TYPE d0100_mapn ,
p_file(136) TYPE c ,
FORM open_file .
*open file in textmode
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
Read the file data and tranfer to workarea to internal table
READ DATASET p_file INTO x_legacy_rec.
Please help in debugging this issue !!
thanks -
OPEN DATASET FOR OUTPUT IN LEGACY TEXT MODE not working!
Hi All,
I need your expertise to help me with my problem.
The program passed through the code OPEN DATASET ... FOR OUTPUT IN LEGACY TEXT MODE. Then it gave an error message "Error Accessing File /home/sap/sample.txt".
I would like to know what are the causes of this error. Please explain to me further why the program gives an error message specified above because I'm not familiar in OPEN DATASET.
Please reply asap since the issue need to be resolved immediately.
Thanks in advance,
CarinaHi Carmey,
The Problem will u need toi get Open Dataset Authorisation from ur Basis Team from the Specified Path.
Regards,
Morris Bond.
Reward Points if Helpful. -
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
RamYou 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.
Maybe you are looking for
-
HP officejet Pro 8500A software driver for Mac OS v 10.10.2
Dear, could you please provide me the HP officejet Pro 8500A (A910a) software driver for MacBook pro (OS X Yosemite v10.10.2) while is it not available on the website. regards, This question was solved. View Solution.
-
We are planning to apply the 10.2.0.5 patchset to our 10.2.0.4 Data Warehouse database (10.2.0.4 ORACLE_HOME) that contains the 10.2.0.1 OWB Design and Runtime Repository (owbowner and owbrt_sys) schemas. The 10.2.0.1 OWB_HOME is a separte installati
-
Execute_query after LOV
Dear Experts, i want to use execute_query after selecting value from lov so that the record appear in edit mode and i can get the functionality of editing record. what should i do?
-
The following code gave me an error: Exception in thread "main" . Anyone, please help me. import java util.Scanner; // program uses class Scanner public class Comparision // main method begins execution of Java application public static voi
-
A question about Oracle FIN project
Supposing there is a Oracle ebs project. there are some accounting information in non-financial modules. My question is that who will be in charge of setting up this information? the FIN consltant or anyone else? pls give me the reason. thank you. pe