Application Development and Automation 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: 
Read only

Creating file on application server

Former Member
0 Likes
732

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

6 REPLIES 6
Read only

gopi_narendra
Active Contributor
0 Likes
672

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

Read only

naimesh_patel
Active Contributor
0 Likes
672

Hello Sandeep,

You have to give the permission to the "FI" directory in "/usr/sap/trans_r0/interfaces/out/" .

Regards,

Naimesh

Read only

0 Likes
672

Naimesh,

How do I do that..am not finding any tab to set the permission

Read only

Former Member
0 Likes
672

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

Read only

0 Likes
672

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.

Read only

uwe_schieferstein
Active Contributor
0 Likes
672

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