Application Development 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: 

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

Former Member
0 Kudos
492

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?

3 REPLIES 3

Former Member
0 Kudos
227

please If someone can

Former Member
0 Kudos
227

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*

Former Member
0 Kudos
227

Hi,

you can define a logical filename in the transaction FILE

Here you can define platfrom specific the logical path and the logical filename.

In your program you can call the FM FILE_GET_NAME with the logical filename in the parameter

logical_filename. The FM returns the physical filename for your operating system in the parameter

file_name.

Use this physical filename for your OPEN DATASET.

Kindly Regards,

Stefan