‎2007 Aug 01 4:05 PM
Hi all,
Below code giving the shot dump at transfer command. How can i rectify that.
FORM upload_data .
data lw_filename type string.
data: lw_line(1024).
move p_ofile to lw_filename.
*---Open file for output
open dataset lw_filename for output in text mode encoding default.
*---Error opening file
if sy-subrc ne 0.
it_return-type = 'E'.
concatenate 'Error opening file'(002) lw_filename
into it_return-message.
append it_return.
clear it_return.
endif.
loop at it_material_data.
concatenate
cl_abap_char_utilities=>horizontal_tab
it_material_data-matnr
cl_abap_char_utilities=>horizontal_tab
it_material_data-maktx
cl_abap_char_utilities=>horizontal_tab
it_material_data-ersda
cl_abap_char_utilities=>horizontal_tab
it_material_data-prod_family
cl_abap_char_utilities=>horizontal_tab
it_material_data-prod_line
cl_abap_char_utilities=>horizontal_tab
it_material_data-prod_model
into lw_line.
transfer lw_line to lw_filename.
endloop.
close dataset lw_filename.
ENDFORM. " upload_data
you will get reward points.
regards,
Ajay reddy.
‎2007 Aug 01 4:06 PM
‎2007 Aug 01 4:11 PM
Hi M,
An exception occurred. This exception is dealt with in more detail below
. The exception, which is assigned to the class 'CX_SY_FILE_OPEN_MODE', was
neither
caught nor passed along using a RAISING clause, in the procedure "UPLOAD_DATA"
"(FORM)"
.
Since the caller of the procedure could not have expected this exception
to occur, the running program was terminated.
The reason for the exception is:
The system tried to access the file
"/feeds/KRD_810/interface/out/Visualparts/interface_XXXX_20070801.txt" but
found that this file was
not opened. For this reason, it could not access the file.
regards,
Ajay reddy
‎2007 Aug 01 4:20 PM
HI,
It clearly indicates that the file is not open and your trying to pass data into that file..
Dump suggest u the possible cause do the changes i suggested you in my reply
thanks
Mahesh
‎2007 Aug 01 4:13 PM
Hi Ajay,
Use exit statement if sy-subrc is not 0. Check if you have proper authorization for access to application server.
Refer to the following link for file handling:
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d35358411d1829f0000e829fbfe/frameset.htm
Also, try using character type for filename.
data : lw_filename(<length>).
Regards,
Srilatha.
‎2007 Aug 01 4:15 PM
put an exit statement inside IF
* Error opening file
IF sy-subrc NE 0.
it_return-type = 'E'.
CONCATENATE 'Error opening file'(002) lw_filename
INTO it_return-message.
APPEND it_return.
CLEAR it_return.
EXIT.
ENDIF.
‎2007 Aug 01 4:17 PM
Yes, you detect an error, but if you don't EXIT after the error, you will try to fil your inexisting file... And DUMP.
Message was edited by:
Mathieu ILHE
‎2007 Aug 01 4:18 PM
HI,
What Does the dump say ...
1) put the else case for the sy-subrc check and do the transfer logic there.. with your code even though ur file is not open you r trying to transfer the data and that could cause the bump
FORM upload_data .
data lw_filename type string.
data: lw_line(1024).
move p_ofile to lw_filename.
*---Open file for output
open dataset lw_filename for output in text mode encoding default.
*---Error opening file
<b>if sy-subrc ne 0.</b>
it_return-type = 'E'.
concatenate 'Error opening file'(002) lw_filename
into it_return-message.
append it_return.
clear it_return.
<b>else.</b>
loop at it_material_data.
concatenate
cl_abap_char_utilities=>horizontal_tab
it_material_data-matnr
cl_abap_char_utilities=>horizontal_tab
it_material_data-maktx
cl_abap_char_utilities=>horizontal_tab
it_material_data-ersda
cl_abap_char_utilities=>horizontal_tab
it_material_data-prod_family
cl_abap_char_utilities=>horizontal_tab
it_material_data-prod_line
cl_abap_char_utilities=>horizontal_tab
it_material_data-prod_model
into lw_line.
transfer lw_line to lw_filename.
endloop.
close dataset lw_filename.
<b>endif.</b>
ENDFORM. " upload_data
2) Try in Binary MOde to open the fie
Thanks
Mahesh
‎2007 Aug 01 4:18 PM
It looks as if the open dataset is getting a non-zero return code. Check this portion in debugging.
Rob
‎2007 Aug 01 4:30 PM
Hi,
This exceptions occurs whenever you try to transfer a data without open the file or an error was generated when you opening this file.
Look at the sy-subrc after OPEN DATASET, in your code you are trying to transfer the data without having exactly gotten success with OPEN DATASET.
In you code you placed:
if sy-subrc ne 0.
it_return-type = 'E'.
concatenate 'Error opening file'(002) lw_filename
into it_return-message.
append it_return.
clear it_return.
endif.
loop at it_material_data.
....
transfer lw_line to lw_filename.
endloop.
close dataset lw_filename.
ENDFORM. " upload_data
I think you placed here a peace of this routine, that is, itsn't complete. Anyway....
if sy-subrc ne 0.
it_return-type = 'E'.
concatenate 'Error opening file'(002) lw_filename
into it_return-message.
append it_return.
clear it_return.
endif.
else. "<------- you miss
loop at it_material_data.
....
transfer lw_line to lw_filename.
endloop.
close dataset lw_filename.
endif. "<------- you miss
ENDFORM. " upload_data
Regards.
Marcelo Ramos