Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

need Help

Former Member
0 Kudos

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.

9 REPLIES 9

Former Member
0 Kudos

What type of DUMP have you got ?

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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.

Pawan_Kesari
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

It looks as if the open dataset is getting a non-zero return code. Check this portion in debugging.

Rob

marcelo_ramos
Active Contributor
0 Kudos

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