on 05-12-2010 10:04 AM
Hi,
In my program i wriien like this. Here i am getting sy-subrc = 8 .please let me know why??
I am giving my file path like this : C\temp\batchfile.csv
TRANSLATE SOURCE_FILE TO LOWER CASE.
OPEN DATASET SOURCE_FILE FOR INPUT IN TEXT MODE.
IF SY-SUBRC NE 0. " File open error
Hi Suhas,
Here, you are opening the file from the C\temp\batchfile.csv, instead you have to read the file from the application server.
You wrote the code:
OPEN DATASET SOURCE_FILE FOR INPUT IN TEXT MODE.
which means that you are reading the file from the application server.
Effect
OPEN ... FOR INPUT opens the file in read mode.
If the file does not exist, OPEN ... FOR INPUT fails with Return Code SY-SUBRC = 8.
I think you want to write the file to the appication server so use the below syntax.
OPEN DATASET SOURCE_FILE FOR OUTPUT IN TEXT MODE.
Hope the answer of your question.
Regards,
Md Ziauddin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you uploading the file from desktop or application server? If you are uploading it from application server check the existence of the file. If you are uploading it from presentation server use FM GUI_UPLOAD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suhas,
You are saying that you are uploading the file from the application server and you are giving the path C\temp\batchfile.csv
which means the file is not present in the application server.
eg.
Please see example code below to read the file from the application server.
REPORT ZEX_DATATOFILE .
&----
*& ABAPLOVERS: Data Transfer
&----
Parameters to enter the path
PARAMETERS FILENAME(128) DEFAULT '/usr/tmp/testfile.dat' (file on application server)
LOWER CASE.
Table Declaration
TABLES VBAK.
Data Declaration
DATA D_MSG_TEXT(50).
Get data for file transfer
DATA INT_VBAK LIKE VBAK OCCURS 100
WITH HEADER LINE.
SELECT * FROM VBAK INTO TABLE INT_VBAK.
SORT INT_VBAK BY VBELN.
LOOP AT INT_VBAK.
WRITE: / INT_VBAK-VBELN,
INT_VBAK-KUNNR.
ENDLOOP.
Opening the File
OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE
MESSAGE D_MSG_TEXT.
IF SY-SUBRC NE 0.
WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.
EXIT.
ENDIF.
Transferring Data
LOOP AT INT_VBAK.
TRANSFER INT_VBAK-VBELN TO FILENAME.
ENDLOOP.
Closing the File
CLOSE DATASET FILENAME.
Regads,
Md Ziauddin.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.