‎2007 May 22 8:44 AM
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 ..
‎2007 May 22 8:48 AM
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
‎2007 May 22 8:59 AM
no separators between fields ..
for (e.g.)
0012356east
i need to read as 001
123
56east ,, it fixed length file without any seperators ...
‎2007 May 22 8:49 AM
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
‎2007 May 22 8:49 AM
‎2007 May 22 9:03 AM
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
‎2007 May 22 10:19 AM
‎2007 May 23 1:41 PM
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
‎2008 Jan 03 10:26 AM
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.
‎2008 Jan 03 11:23 AM
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
‎2008 Jan 03 11:41 AM
Hi,
Check this link.
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3c7f358411d1829f0000e829fbfe/content.htm
Regards
Vadi