2008 Jun 26 2:31 PM
Hi Abapers,
I am wrote the syntax for open dataset like below.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
First I declare p_file as a Character type, at that time the sy-subrc value returns 8.
I changed p_file type as String ven though the sy-subrc value returns 8.
Means the p_file is not opened/created.
Please suggest me how to do this.
Thanks in Advance.
Thanks and Regards
AbinavaSiri..
Hi Abapers,
I am wrote the syntax for open dataset like below.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
First I declare p_file as a Character type, at that time the sy-subrc value returns 8.
I changed p_file type as String ven though the sy-subrc value returns 8.
Means the p_file is not opened/created.
Please suggest me how to do this.
Thanks in Advance.
Thanks and Regards
AbinavaSiri..
2008 Jun 26 2:33 PM
declare the file type as RLGRAP-FILENAME.
DATA: P_FILE TYPE RLGRAP-FILENAME.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
2008 Jun 26 2:34 PM
2008 Jun 26 2:35 PM
use l_upfile TYPE char50,
v_message(255) TYPE c,
and
OPEN DATASET l_upfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
MESSAGE v_message.
Reward point if helpful
2008 Jun 26 2:35 PM
hiiiii
just use like
DATA FNAME(60) VALUE 'myfile'.
OPEN DATASET FNAME FOR OUTPUT in text mode encoding default.
LOOP AT TAB INTO LIN.
TRANSFER LIN TO FNAME.
ENDLOOP.
CLOSE DATASET FNAME.declare & use like this..it should work.
regards
twinkal
2008 Jun 26 2:35 PM
Hi,
PARAMETERS: APPPATH LIKE RLGRAP-FILENAME
*open the file on the application server for reading data...
OPEN DATASET APPPATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SYST-SUBRC NE 0.
WRITE: / 'There was an error opening the file in input mode:',
SKIP 2.
WRITE: / 'Please check that the file and directory exists',
'on the application server:', SYST-HOST.
STOP.
ENDIF.In your case define:
P_FILE LIKE RLGRAP-FILENAMERegards
Adil
2008 Jun 26 2:42 PM
Hi Abdul,
Thanks for your reply.I have one doubt.
In the application server there is no P_FILE.
We have one file in presentation server, we transfer that file from here to application server.
Please help.
Thanks and Regards,
Siri.
2008 Jun 26 2:36 PM
parameters:
out_file like rlgrap-filename default
'<xxxxxxxxxxxxxxxxxxx/xxxx.txt>'
open dataset out_file for output in text mode
ENCODING DEFAULT.
rlgrap-filename is char field of size 128
I trust it works...
2008 Jun 26 2:37 PM
parameters:
out_file like rlgrap-filename default
'<xxxxxxxxxxxxxxxxxxx/xxxx.txt>'
open dataset out_file for output in text mode
ENCODING DEFAULT.
rlgrap-filename is char field of size 128
I trust it works...
2008 Jun 26 2:39 PM
Hi Sri,
There should be no problem with the p_file type if it is declared as string. It is works fine.
Just check whether yopu have mentioned the file path in that string.
i.e., p_file = './<filename>.
Hope this helps you.
Regards,
Chandra Sekhar
2008 Jun 26 2:48 PM
Hi,
use the syntax like this.
Data: p_file(120).
open dataset p_file for output / appending in binary / text mode.
(If the dataset p_file already exists then use appending other wise use for output).
loop at itab.
transfer itab to p_file.
(In binary mode it writes the length of the field to the dataset. In text mode it writes one line to the dataset).
endloop.
close dataset p_file.
Reward if helpful.
2008 Jun 26 2:54 PM
Hi lakshmi,
I did the same.But the problem is, After Open Dataset the sy-subrc value returns 8.
I dont know why this thing is happening.
Please help.
Thanks and Regards
Abinavasiri.
2008 Jun 26 3:02 PM
please ref the above my post.
declare the filetype as rlgrap-filename.
just check the sy-subrc ,
data: p_file type rlgrap-filename.
p_file = '/sap/tmp/testfile.txt'.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
break-point.
2008 Jun 26 3:00 PM
Hi,
Upload the file contents which is at presentation server to an internal table.
Then create a file at application server using OPEN DATASET . Then loop at that internal table and transfer the contents to that file .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = W_FNAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = T_BKPF.
Opening a file to write data
OPEN DATASET w_fname
FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
Transfering data to file using TRANSFER statement
LOOP AT t_line INTO fs_line.
TRANSFER fs_line TO w_fname.
ENDLOOP.
close dataset w_fname.
2008 Jun 26 3:05 PM
Hi abhinava siri,
Take declare
w_fname Type string.
It will not give any error.
2008 Jun 26 3:20 PM
NO need to write any program for this USE Tcode CG3Z ,
give the presentation file and the Application server file path, and upload the data.
2008 Jun 26 3:20 PM
Hi abinave,
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME
*open the file on the application server for reading data...
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SYST-SUBRC NE 0.
WRITE: / 'There was an error opening the file in input mode:',
ENDIF.
* read the file and populate the data to an internal table
READ DATASET P_FILE INTO <WA>
* close the file
CLOSE DATASET P_FILE.p_file is a parameter, here enter the file path which is at application server
Reward if usefull
Adil
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |