‎2006 Nov 03 7:16 AM
Hi All,
I want to create a file in application server, can anyone help me on this,I've created the path using AL11 transaction, now how do i create a file and give write access to it,I want something like this:
/usr/sap/trans_r0/interfaces/out/FI/outbound_doc.txt.
Useful answers will definetly be rewarded.
Thanks in advance
‎2006 Nov 03 7:19 AM
Use the open dataset transfer and close dataset statements as mentioned below
Open Dataset
catch system-exceptions DATASET_CANT_OPEN = 8.
open dataset UNIX_FILE for output in text mode encoding default.
endcatch.
Write to Dataset
loop at IT_STR into IS_STR.
catch system-exceptions DATASET_NOT_OPEN = 0 .
transfer IS_STR-STR to UNIX_FILE.
endcatch.
endloop.
if SY-SUBRC eq 0.
message S138(ZSM) with 'Data Downloaded to Unix File'.
endif.
Close Dataset
close dataset UNIX_FILE.
Regards
- Gopi
‎2006 Nov 03 7:19 AM
Hello Sandeep,
You have to give the permission to the "FI" directory in "/usr/sap/trans_r0/interfaces/out/" .
Regards,
Naimesh
‎2006 Nov 03 7:27 AM
Naimesh,
How do I do that..am not finding any tab to set the permission
‎2006 Nov 03 7:38 AM
Hi Sandeep,
Try this ,
Data: p_file(90) value '/usr/sap/trans_r0/interfaces/out/FI/outbound_doc.txt'.
open dataset p_file for output in text mode encoding default.
loop at i_tab.
transfer i_tab to p_file. " length 500.
endloop.
Regards,
Sreekanth
‎2006 Nov 03 7:41 AM
Let me explain this a bit more, I just want to create the file manually, there is a program which will write it into the file created.
‎2006 Nov 03 7:45 AM
Hello Sandeep
You can also use the static method
CALL METHOD cl_abap_file_utilities=>create_file_with_bom
EXPORTING
file_name = '/usr/sap/trans_r0/interfaces/out/FI/outbound_doc.txt'.The method will delete an already existing file and create a new one containing a byte-order mark (BOM).
For reading file that might contain a BOM you can use the following coding:
IF cl_abap_file_utilities=>check_for_bom( filename ) =
cl_abap_file_utilities=>bom_utf8.
OPEN DATASET filename IN TEXT MODE ENCODING UTF-8 FOR INPUT AT POSITION 3.
ELSE ...
ENDIF.Regards
Uwe