‎2009 Aug 17 10:13 AM
HI
i want to read a file from application server using read dataset. for that i have written the code as
select * from zbdclog INTO CORRESPONDING FIELDS OF TABLE i_bdclog
where RICEFID = p_ricef
and username = p_user.
if sy-subrc = 0.
loop at i_bdclog into wg_bdclog.
fname = wg_bdclog-filepath.
OPEN DATASET fname FOR output IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
READ DATASET fname INTO wg_bdclog1-filepath.
append wg_bdclog1 to i_bdclog1.
ENDIF.
CLOSE DATASET fname.
endloop.
endif.
can anyone tell me where is the problem as the values of sy-subrc = 8, so its not getting inside the loop.
‎2009 Aug 17 10:18 AM
Hello Swarnali.
select * from zbdclog INTO CORRESPONDING FIELDS OF TABLE i_bdclog
where RICEFID = p_ricef
and username = p_user.
IF sy-subrc = 0.
* Do porcessing
ENDIF.If this sy-subrc is failing goto SE16 & check if there is any data in the table zbdclog for
RICEFID = p_ricef and username = p_userBR,
Suhas
‎2009 Aug 17 10:19 AM
HI,
Check the data base table for the entries
AS u want to read the data from application server u need to write like this
OPEN DATASET <DATASET NAME> for INPUT in text mode endoing default.
OUTPUT->To write into the application server
INPUT->To read from application server.
Regards,
Nagaraj
‎2009 Aug 17 10:20 AM
Hi,
Please check if there are any corresponding records available for your input that you have used in the select query i.e the ricefid and username.
And moreover, to read data from the application server, you use something like this
OPEN DATASET P_FNAME2 FOR INPUT IN BINARY MODE.
READ DATASET P_FNAME2 INTO WA_SALESDETAILS.
APPEND WA_SALESDETAILS TO T_SALESDETAILS.
CLEAR WA_SALESDETAILS.
CLOSE DATASET P_FNAME2.
Edited by: Nitwick on Aug 17, 2009 2:50 PM
‎2009 Aug 17 10:21 AM
Hi,
Check in table zbdclog whether any entries exist matching values of p_ricef and p_user.
Regards,
Ankur Parab
‎2009 Aug 17 10:26 AM
Hi,
I think there is a problem in ur select query... ur saying select * and putting those in CORRESPONDING FIELDS..... Check the declaration or ur internal table..
AND
Check the declaration of the field FNAME
DATA : FNAME TYPE STRING.
‎2009 Aug 17 10:21 AM
‎2009 Aug 17 10:22 AM
hi
i have checked, records are available, the second sy-subrc is failing, i,e. its not going to read dataset
Regards
Swarnali
‎2009 Aug 17 10:25 AM
Also check whether you have authorization for reading,writing etc
‎2009 Aug 17 10:26 AM
Hi,
Do you want to read data from the application server. Then you gotto use the syntax
OPEN DATASET P_FNAME FOR INPUT IN BINARY MODE.
OUTPUT is for writing data into application server. Your file wouldnt have been existing in the application server. So it is possibly returning a 8 for the sy-subrc.
‎2009 Aug 17 10:24 AM
HI,
Did u try to change ur code as i suggested
AS u want to read the data from application server u need to write like this
OPEN DATASET <DATASET NAME> for INPUT in text mode endoing default.
OUTPUT->To write into the application server
INPUT->To read from application server.
Regards,
Nagaraj
‎2009 Aug 17 10:24 AM
hi
even if i use FOR INPUT , still i am getting this error, please help
‎2009 Aug 17 10:27 AM
Hi,
After the select statement, check if i_bdclog -filepath has a valid application server file path.
‎2009 Aug 17 10:24 AM
Hi,
Change the open dataset statement and check
OPEN DATASET fname FOR output IN TEXT MODE ENCODING DEFAULT. "previous
to
OPEN DATASET fname FOR INPUT IN TEXT MODE ENCODING DEFAULT. "corrected
Regards,
Vik
‎2009 Aug 17 10:25 AM
hi
i used for input , still the sy-subrc value is 8 just before the read dataset
‎2009 Aug 17 10:29 AM
Hello,
Quick check if the filepath exists in AL11. If yes, then go to the next lines
Just before the OPEN DATASET statement you can call the auth. obj S_DATASET (or the FM: AUTHORITY_CHECK_DATASET).
I think you donot have the access to read/write files from the folder.
BR,
Suhas
Edited by: Suhas Saha on Aug 17, 2009 11:31 AM
‎2009 Aug 17 10:30 AM
Hi,
Check the mode in which you are trying to open the file. Please do a F1 on the modes. See if it works with BINARY MODE. As suggested, try to use ENCODING DEFAULT addition to the OPEN DATASET.
‎2009 Aug 17 10:26 AM
Use
OPEN DATASET fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
‎2009 Aug 17 10:29 AM
HI
i have used IN BINARY MODE as well as i checked whether it has a valid filepath, but still i m getting the sy-subrc = 8.
‎2009 Aug 17 10:31 AM
hi
before this i have used to create a file in application server and it worked fine so i think i have the authrosation, this is nt the problem, any other advice?
‎2009 Aug 17 10:36 AM
>
> hi
> before this i have used to create a file in application server and it worked fine so i think i have the authrosation, this is nt the problem, any other advice?
Hello,
Did you create the file in the same folder as the one you are trying to access?
If YES, please check if you have READ access to the file.
AUTHORITY-CHECK OBJECT 'S_DATASET'
ID 'PROGRAM' FIELD SY-REPID
ID 'ACTVT' FIELD '33' "33 -> Read Access
ID 'FILENAME' FIELD <your filepath>
CHECK sy-subrc IS INITIAL.
Please note that an F1 on OPEN DATASET FOR INPUT says if the file does not exist the sy-subrc is set to 8.
BR,
Suhas
‎2009 Aug 17 10:38 AM
Hi,
The F1 help says if the sy-subrc eq 8 then the operating system was not able to open the file.
Possibly,
The file does not exist in the application server. Please check if it does, in the application server. You may use the FM 'FILE_GET_NAME_USING_PATH' to get the file path or in the AL11 directory. Just a check if the file does exist on the application server.
You might possibly not have the necessary authorizations to read data from the file. There are no catchable exceptions if this is the case.
‎2009 Aug 17 11:06 AM
hi
i checked the authorisation , at tht point of time sy-subrc = 0 then it shows that it has authorisation , so that is not a problem, this file is a filepath from the table zbclog it has no relation with the filepath i had created before.
the issue is it will fetch the filepath from table zbdclog and read tht file from the application server, which is created through this custom table.
‎2009 Aug 17 11:24 AM
>
> hi
> i checked the authorisation , at tht point of time sy-subrc = 0 then it shows that it has authorisation , so that is not a problem, this file is a filepath from the table zbclog it has no relation with the filepath i had created before.
>
> the issue is it will fetch the filepath from table zbdclog and read tht file from the application server, which is created through this custom table.
Hello Swarnali,
This means that we can eliminate the authorisation as a potential issue.
If you read my previous post you can see that from SAP documentation if READ DATASET FOR INPUT has sy-subrc = 8 => that the file does not exist.
I think that this must be the issue.
BR,
Suhas
‎2009 Aug 17 10:42 AM
Hi,
Try as below
SELECT * FROM zbdclog INTO CORRESPONDING FIELDS OF TABLE i_bdclog
WHERE ricefid = p_ricef
AND username = p_user.
IF sy-subrc = 0.
LOOP AT i_bdclog INTO wg_bdclog.
fname = wg_bdclog-filepath.
OPEN DATASET fname FOR INPUT IN TEXT MODE ENCODING DEFAULT. " It must be INPUT not OUTPUT, to read file we use INPUT
IF sy-subrc NE 0. " To create file on App Server we use OUTPUT
EXIT.
ENDIF.
DO.
CLEAR wg_bdclog1.
READ DATASET fname INTO wg_bdclog1-filepath.
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND wg_bdclog1 to i_bdclog1.
ENDIF.
ENDDO.
CLOSE DATASET fname.
ENDLOOP.
ENDIF.Regards
Bala Krishna
Edited by: Bala Krishna on Aug 17, 2009 3:14 PM
‎2009 Aug 17 11:10 AM
Hi,
I think CLOSE DATASET needs to be given after the loop.
select * from zbdclog INTO CORRESPONDING FIELDS OF TABLE i_bdclog
where RICEFID = p_ricef
and username = p_user.
if sy-subrc = 0.
loop at i_bdclog into wg_bdclog.
fname = wg_bdclog-filepath.
OPEN DATASET fname FOR output IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
READ DATASET fname INTO wg_bdclog1-filepath.
append wg_bdclog1 to i_bdclog1.
ENDIF.
endloop.
endif.
CLOSE DATASET fname.
Rgds,
Sripal
‎2009 Aug 17 11:34 AM
Hi,
You can first validate the application server path if it exists or not,
data: l_file type tpfht-pffile.
clear l_file.
l_file = p_file. " In p_file the paaplicn server path entered by the user is captured
Then Call function PFL_CHECK_OS_FILE_EXISTENCE which will validate your
application server path.
It will return in its importing parameter one variable having value
'X' means the file exists or space that is it does not exists.
On its value 'X', then we can use OPEN DATASET statement that is,
OPEN DATASET L_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
Hope it helps
Regards
Mansi
‎2009 Aug 17 10:28 PM
Hi,
OPEN DATASET <path variable> IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
IF sy-subrc EQ 0.
Write the contents in to the Application Server
LOOP AT it_download.
TRANSFER < Internal table > TO <Path Variable>
ENDLOOP.
ENDIF.
CLOSE DATASET <Path Vairable>
‎2009 Aug 19 8:27 AM