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

Reading file from Application server

Former Member
0 Likes
977

hi all ,

i need to read a file from application server ,, the file format is fixed one (i.e. no space between fields,,) how to read the file..

plz through some idea..

thanks in advance ..

10 REPLIES 10
Read only

Former Member
0 Likes
945

Hi

You can use the DATASET concept(OPEN DATASET, READ DATASET) to read the application server file.

But how to separate the fields from that file? there should be some separators(delimitors) used if it have number of fields in it.

Is it a text file without any fields.

The you can read it as it is

Reward points if useful

Regards

Anji

Read only

0 Likes
945

no separators between fields ..

for (e.g.)

0012356east

i need to read as 001

123

56east ,, it fixed length file without any seperators ...

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
945

Hi

Use the below code:

*-- read file, split lines into fields and put data into table

OPEN DATASET v_file_listings FOR INPUT IN TEXT MODE ENCODING NON-UNICODE. "Opening the files

IF sy-subrc EQ 0.

DO.

READ DATASET v_file_listings INTO single_line. "Reading the content of file into line

IF sy-subrc = 0.

IF sy-index > 1. "skip header-line

SPLIT "Split the content of line into work area

single_line

AT k_split

INTO

wa.

Append wa to Itab.

Regards,

Sreeram

Read only

oliver
Active Contributor
0 Likes
945

Hi Krishna,

you probably would to it using OPEN and READ DATASET.

Take a look at this thread:

Regards,

ok

Read only

Former Member
0 Likes
945

Hi Krishna,

If it is fixed length file, you have declare an internal table which is inline with your flatfile. Here atleast you have to know the exact lenght of the field.

this way you can solve the problem.

Thanks

eswar

Read only

Former Member
0 Likes
945

USE OPEN DATASET STATEMENT

Read only

oliver
Active Contributor
0 Likes
945

Hi Krishna,

you probably don't know that it's good practice to close a thread once it's answered. Please also consider giving points for helpful answers.

Thanks & best regards,

ok

Read only

Former Member
0 Likes
945
  • Check whether file exists

OPEN DATASET c_filepath FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

  • File c_filepath already exists then read that file

READ DATASET c_filepath.

else.

error message.

endif.

Read only

Former Member
0 Likes
945

Hi Krishna Prasad,

Try this fn.

CALL FUNCTION 'C13Z_FILE_DOWNLOAD_ASCII'

EXPORTING

i_file_front_end = client_path

i_file_appl = server_path

I_FILE_OVERWRITE = 'X'

EXCEPTIONS

FE_FILE_OPEN_ERROR = 1

FE_FILE_EXISTS = 2

FE_FILE_WRITE_ERROR = 3

AP_NO_AUTHORITY = 4

AP_FILE_OPEN_ERROR = 5

AP_FILE_EMPTY = 6

OTHERS = 7

reward if helpful.

-Maharshi

Read only

i048168
Product and Topic Expert
Product and Topic Expert