Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OPEN DATASET P_FILE FOR INPUT IN BINARY MODE

Former Member
0 Likes
3,322

hiiii

i have a question for this piece of code:

OPEN DATASET P_FILE FOR INPUT IN BINARY MODE

the value in P_FILE = /usr/sap/tmp/file

i get sy-subrc 8

when i put value

the value in P_FILE = /usr/sap/tmp/file.dat the sy-subrc = 0.

is this an error in code or when we do the text we must put the .dat extension

because the unit test sript said to run the test without the .dat extension

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,134

Hi,

You must enter the file name with extension, else it wont work.

Remember , its case sensitive.

Hi,

You must enter the file name with extension, else it wont work.

Remember , its case sensitive.

10 REPLIES 10
Read only

Sm1tje
Active Contributor
0 Likes
2,134

use full name, includin extension (all case sensitive).

Read only

Former Member
0 Likes
2,135

Hi,

You must enter the file name with extension, else it wont work.

Remember , its case sensitive.

Read only

Former Member
0 Likes
2,134

Hi,

You will need to add extension, because Open dataset...in binary mode will read data as a stream..

Regards,

Mohaiyuddin

Read only

Former Member
0 Likes
2,134

Hi,

without the extension you can not open the file.Because file is in binary mode you have to give .dat.

if you open in tecxt mode give .txt.

Pls reward if useful....

Read only

0 Likes
2,134

what if i remove the IN BINARY MODE in code, will it accept without the .dat enven though in unix the full name is file.dat

OPEN DATASET P_FILE FOR INPUT IN BINARY MODE

Read only

0 Likes
2,134

Hi Newbie,

When u pass the file path it is necessary to have an extension,

So u will hav to provide the file path which has an extension like .dat, .txt etc.... so that it knows wat is the file type ...

Secondly u use binary mode to read the info byte wise...this is defualt mode for open data set....

Suppose ur requirement is to read data i.e the entire string then u need to use the TExt mode...It will read the entire string till it encounters space or a delimter...

Thanx,

navin.

Read only

0 Likes
2,134

i know that in the selection screen i can add the ".dat" myself but because i have receive a template from the funtional to execute the programm without the .dat

what should i do for the programm to accept only "/path/file" instead of "/path/file.dat"

Read only

0 Likes
2,134

Hi newbie...

See...jst incase u receive only the path and that will be stored in some variable right...So before you giv that file name widut

the extension.....u can concatenate a variable l_ext which holds .dat to the variable which holds the file path...So ur final variable l_file path contains = "/path/file.dat"

Thanx,

Navin.

Read only

Former Member
0 Likes
2,134

haii,

the problem is in open dataset file name is case sensitive

so while defining parameter for file name add LOWER CASE.

parameter : P_FILE(30) type c LOWER CASE .

thanks and regards

sarath p

Read only

Former Member
0 Likes
2,134

Hi newbie,

Of course you can add the extension yourself if you want. Just check the string in P_FILE and add the ".dat" if it is not there.

Gr.

Richard