2009 Apr 28 8:15 AM
Hi team
my requirement is that upload the CSV file into the application server (AL11) and through program read this file .while reading this file it gives sy-subrc eq 4 . please suggest what can i do for reading the file.
What i am doing right now in the code as follows.
OPEN DATASET p_file FOR INPUT IN BINARY MODE.
DO .
READ DATASET p_file INTO st_string.
IF sy-subrc EQ 0 .
SPLIT st_string AT ',' INTO
gs_agent_file_input-zcntrl_grp
gs_agent_file_input-zlease_typ_sg
gs_agent_file_input-zne_user IN CHARACTER MODE.
APPEND gs_agent_file_input TO gt_agent_file_input.
CLEAR gs_agent_file_input.
ENDIF.
But currently i am getting sy-subrc 4. Please suggest me how can i read this file.
Thanks in Advance.
Puneet.
2009 May 04 12:44 PM
Hi guys
i am working on something similar where firstly i need to read data from internal table then encode it and after that need to download that to presentation server.
st_string type string is not supported with read dataset.. u better use st_string(5000), where 5000 is the expected number of characters...
I hope this will help u out.
See this example code
DATA: BEGIN OF ITAB OCCURS 0,
LINE(5000),
END OF ITAB1.
DATA: file_path(50) TYPE C.
file_path = ' '. "FILE PATH GOES HERE
OPEN DATASET file_path FOR INPUT IN BINARY MODE.
DO.
READ DATASET file_path INTO ITAB.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
APPEND ITAB.
ENDDO.
CLOSE DATASET file_path.
2009 Apr 28 8:19 AM
2009 Apr 28 8:27 AM
Hi,
firstly check in the application server if that file has any data in it...
Regards,
Siddarth
2009 Apr 28 8:30 AM
Hi,
That file is having data in the application server.
Have you checked that?
Regards,
Jyothi CH.
2009 Apr 28 8:36 AM
Hi
yes, i have checked the file, file contains comma seperated file like
110000,1000,01,01
110001,1000,01,01
110002,1000,01,01
i have taken st_sting type string.
please suggest me what can i do.
thanks
puneet.
2009 Apr 28 9:16 AM
2009 Apr 28 9:46 AM
Hi Team,
till now problem is not resolved . please do the needful information for resolving this problem.
Thanks in Advance.
Puneet.
2009 Apr 28 9:50 AM
2009 Apr 28 9:56 AM
Hi Puneet,
Check the below piece of lines
*Read the file from the Application Server
DATA : w_filename(1024) TYPE c,
OPEN DATASET w_filename FOR INPUT IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
* Error while opening the file for output.
MESSAGE e999(zfi_ap_gl) WITH text-005.
ELSE.
DO.
* reading the data into the internal table.
READ DATASET w_filename INTO wa_file.
IF sy-subrc EQ 0.
PERFORM fill_data.
ELSE.
EXIT.
ENDIF.
CLEAR : wa_file.
ENDDO.
CLOSE DATASET w_filename.
ENDIF.
ENDIF.
ENDFORM. " READ_DATAThis is an example.
Hope that will be helpful for you.
Thanks,
Babu Kilari
2009 Apr 28 10:05 AM
Puneeth,
When I pressed F1 on Read Dataset, I got the following information for Sy-Subrc
System Fields
sy-subrc Meaning
0 Data was read without reaching end of file.
4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.
So, the problem is not with the declaration. Problem is only with the reading of the file.
1.Make sure that the file is not corrupted.
2.Make sure that the file content is available
3.As open dataset is working fine,I dont think there is no need to check the path. But, anyways make sure that it is given correct.
Try to debug the code and check all the above values and see what is actually hapening.
Thanks,
Babu Kilari
2009 Apr 28 9:50 AM
Its Strange..... Check whether correct Path is passed in p_file Variable. Chk the subrc value after Open Dataset....Careful with '/' and '\' coz if the appl server is on Linux then use the first one or else use the second one. Also do have a check whether the length of p_file is long enough to hold the Path...
Edited by: shafivullah mohammad on Apr 28, 2009 2:21 PM
2010 Apr 30 9:08 AM
2009 Apr 28 9:58 AM
Hi,
Trythis.
Local variable Declaration
DATA l_msg(60) TYPE c.
OPEN DATASET p_file FOR INPUT IN BINARY MODE
MESSAGE l_msg.
Then check the l_msg in debugging, it will give the nature of problem.
2009 Apr 29 7:38 AM
Even i am facing the same situation if u get any solution can u tell me also
2009 Apr 29 7:41 AM
Vedhavathi,
Again, I would like to ask same questions. Have you debugged the code? Do you have the data in the file? Are you able to see the contents of the file in AL11?
Thanks,
Babu Kilari
2009 May 04 12:44 PM
Hi guys
i am working on something similar where firstly i need to read data from internal table then encode it and after that need to download that to presentation server.
st_string type string is not supported with read dataset.. u better use st_string(5000), where 5000 is the expected number of characters...
I hope this will help u out.
See this example code
DATA: BEGIN OF ITAB OCCURS 0,
LINE(5000),
END OF ITAB1.
DATA: file_path(50) TYPE C.
file_path = ' '. "FILE PATH GOES HERE
OPEN DATASET file_path FOR INPUT IN BINARY MODE.
DO.
READ DATASET file_path INTO ITAB.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
APPEND ITAB.
ENDDO.
CLOSE DATASET file_path.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |