05-24-2006 9:34 AM
Hello.
There's something in a program i am currently writing.
I'm trying to write in 2 files with a format like this :
line1.....
line2.....
In the first file, everything is ok but in the second file, with exactly the same instructions, instead og getting my file like i need it, i've something like that :
line1...... line2....
Here is the code i'm using to write in the file :
DATA : t_ent_estim like STANDARD TABLE OF ZVOIENT WITH HEADER LINE.
LOOP AT t_ent_estim.
TRANSFER t_ent_estim TO p_fici.
ENDLOOP.
PERFORM close_file(zvoiform) USING p_fici w_result.
The only difference is that in one case i use an internal table and in the other i use a structure i created myself :
DATA : BEGIN OF tbl_csv_trans OCCURS 0,
s_csvdata(400),
END OF tbl_csv_trans.
Anybody can explain to me why with the internal table, the instruction transfer does not write in a new line each occurence of my table ?
Thanks for the help.
05-24-2006 9:43 AM
Hi,
are you using the Open data set in text mode both the places.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
if not change it and see..
where is your open dataset in your coding.
Regards
vijay
05-24-2006 9:41 AM
Hi Helder,
I have also used a structure, and it works fine for me.
Check whether you have opened the file in text mode.
data : BEGIN OF i_final_file OCCURS 0,
record(300) TYPE c,
END OF i_final_file,
Open the file for output **********************
OPEN DATASET wa_c_filename FOR OUTPUT IN TEXT MODE.
IF sy-subrc NE 0.
MESSAGE a999 WITH 'The file could not be created'.
ENDIF.
Write line items to file ************************
LOOP AT i_final_file.
TRANSFER i_final_file TO wa_c_filename.
ENDLOOP.
Close the file ******************************
CLOSE DATASET wa_c_filename.
Regards,
Susmitha
Reward points if helpful
05-24-2006 9:41 AM
Hi,
1.When you use first case it will automatically adjust according to the entered data length .
2.In the second case , the data will be fit according to the length of the field structure.
<i>Hope This Info Helps YOU.</i>
Regards,
Lakshmi
05-24-2006 9:43 AM
Hi,
are you using the Open data set in text mode both the places.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
if not change it and see..
where is your open dataset in your coding.
Regards
vijay
05-24-2006 9:50 AM
Thanks Vijay.
What a silly error i did :-X
I use a form to open the DATASET in text mode, and i forgot to call it just before writing in the file...