Skip to Content
0
Former Member
Dec 08, 2009 at 08:50 PM

question on cx_sy_file_open process

184 Views

hello

I am having a problem with opening a dataset. I hava program that is reading two files the first file works siccessfully.

OPEN DATASET w_outfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

LOOP AT t_upload_file INTO l_st_it_outfile.

TRANSFER l_st_it_outfile TO w_outfile.

CLEAR l_st_it_outfile.

ENDLOOP.

ENDIF.

CLOSE DATASET w_outfile.

when I process the second fule, I am getting the return code 8 on the open statement. I am thinking that the file did not close becaue the program is still running. I found the exception cx_sy_file_open and some program that had examples of how to code.

OPEN DATASET w_outfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

LOOP AT t_upload_file INTO l_st_it_outfile.

  • move work area to file

TRY.

TRANSFER l_st_it_outfile TO w_outfile.

CLEAR l_st_it_outfile.

CATCH cx_sy_file_io INTO l_obj_ref.

l_tr_err_flag = 'X'.

EXIT.

CATCH cx_sy_file_open INTO l_obj_ref.

l_tr_err_flag = 'X'.

EXIT.

ENDTRY.

CLEAR: l_st_it_outfile.

ENDLOOP.

REFRESH t_upload_file[].

ENDIF.

  • Close file in application server

TRY.

CLOSE DATASET w_outfile.

CATCH cx_sy_file_close INTO l_obj_ref.

l_cl_err_flag = 'X' .

ENDTRY.

I am still not able to open the file. I am still getting the return code 8 on the open statement. can someone explain to me how this is supposed to work? it looks like is still checks the return code and still will close the file without processing the second file.

thanks in advance