2009 Sep 08 1:36 PM
Hi all,
I'm having some problems with a simple requirements: I have to write a report that IN BACKGROUND read a file from a network shared directory folder, do some processing and write some output in a file in the same network folder. I see that I have to use DATASET operation .. this is is my code:
DATA dset_in(256) TYPE c VALUE '\\strg_machine_name\folder\input_file'.
DATA dset_out(256) TYPE c VALUE '\\strg_machine_name\folder\output_file'.
DATA record(80) TYPE c.
" input
OPEN DATASET dset_in FOR INPUT IN TEXT MODE ENCODING DEFAULT .
DO.
READ DATASET dset INTO RECORD.
IF sy-subrc NE 0.
EXIT.
ELSE.
" do some processing filling it_table
ENDIF.
ENDDO.
" output
OPEN DATASET dset_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .
LOOP AT it_table INTO record.
TRANSFER record TO dset_out.
ENDLOOP.
I cannot understand where is my mistake. Also, can I try a piece of code like this from GUI debugging with se38? or it just work in background mode? (I tried both).
Thanks to anyone can help me
Gabriele
2009 Sep 08 1:41 PM
Hi,
Try this.
DATA dset_in(256) TYPE c VALUE '
strg_machine_name\folder\input_file'.
DATA dset_out(256) TYPE c VALUE '
strg_machine_name\folder\output_file'.
DATA record(80) TYPE c.
" input
OPEN DATASET dset_in FOR INPUT IN TEXT MODE ENCODING DEFAULT .
DO.
READ DATASET dset INTO RECORD.
IF sy-subrc NE 0.
EXIT.
ELSE.
" do some processing filling it_table
ENDIF.
ENDDO.
Close DataSET.
" output
OPEN DATASET dset_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .
DO.
READ DATASET dset INTO RECORD.
IF sy-subrc NE 0.
EXIT.
ELSE.
" do some processing filling it_table
ENDIF.
ENDDO.
Close DataSET.
LOOP AT it_table INTO record.
TRANSFER record TO dset_out.
ENDLOOP.
Regards,
Vijay
2009 Sep 08 1:41 PM
Hi,
Try this.
DATA dset_in(256) TYPE c VALUE '
strg_machine_name\folder\input_file'.
DATA dset_out(256) TYPE c VALUE '
strg_machine_name\folder\output_file'.
DATA record(80) TYPE c.
" input
OPEN DATASET dset_in FOR INPUT IN TEXT MODE ENCODING DEFAULT .
DO.
READ DATASET dset INTO RECORD.
IF sy-subrc NE 0.
EXIT.
ELSE.
" do some processing filling it_table
ENDIF.
ENDDO.
Close DataSET.
" output
OPEN DATASET dset_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .
DO.
READ DATASET dset INTO RECORD.
IF sy-subrc NE 0.
EXIT.
ELSE.
" do some processing filling it_table
ENDIF.
ENDDO.
Close DataSET.
LOOP AT it_table INTO record.
TRANSFER record TO dset_out.
ENDLOOP.
Regards,
Vijay
2009 Sep 08 2:07 PM
I tried but alway getting sy-subrc = 8
runtime error with this message:
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_FILE_OPEN_MODE', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
When accessing the file "
machine\directory_shared\test.txt", the system recognized
that this file is
not open. Therefore, the file cannot be accessed.
2009 Sep 08 2:12 PM
Hi Gabriele again,
When you are fetching file from parameter.
you should use FM GUI_UPLOAD to take data into internal table and then use READ DATASET.
I think then only you will able to run it successfully.
Thanks and Regards,
Vijay
2009 Sep 08 2:15 PM
2009 Sep 08 3:13 PM
Hi
I checked the link and it works for path in application server.. but still cannot open network shared file: file are put on other machine with sharing folder, and I want to open that file .. better close this and open new post.