‎2009 Sep 08 11:06 AM
Hello,
how can simply a file be uploaded to application server. Please note the file is not existing on local PC. It must be created
during application runtime and finally uploaded. How can this req be achieved ?
Please reply back.
Regards
Alexander
‎2009 Sep 08 11:16 AM
Hi,
I am not sure what you mean by " the file must be created during runtime and get uploaded in application server". If you are meaning a internal table as a file , then it can be used to create a file in the application server with the internal table data in the application server file.
data: dsn type string.
dsn = '\tmp\usr\abc.txt' " valid application server file path
OPEN DATASET dsn FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT ltab.
TRANSFER itab TO dsn.
ENDLOOP.
ENDIF.
Regards,
Vikranth
‎2009 Sep 08 11:10 AM
Hi Alexander,
If your requirement is getting data from any table and put in application server as a file, here is the code....
OPEN DATASET pa_fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
* Process Data
LOOP AT lt_data INTO lw_data.
* Write the data into the file
TRANSFER lw_data TO pa_fname.
ENDLOOP.
ELSE.
WRITE :/ 'Error while opening the file'.
ENDIF.
* Close the dataset
CLOSE DATASET pa_fname.Thanks
Babu
‎2009 Sep 08 11:16 AM
Hi,
I am not sure what you mean by " the file must be created during runtime and get uploaded in application server". If you are meaning a internal table as a file , then it can be used to create a file in the application server with the internal table data in the application server file.
data: dsn type string.
dsn = '\tmp\usr\abc.txt' " valid application server file path
OPEN DATASET dsn FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT ltab.
TRANSFER itab TO dsn.
ENDLOOP.
ENDIF.
Regards,
Vikranth
‎2009 Sep 08 11:18 AM
hmmmm well u have to write a program.....and fill an internal table (collect data from database).........then using above open dataset staments send it to application server.
‎2009 Sep 08 11:19 AM
Hi,
You can create a file on application server by using OPEN DATASET statement.
Example
Fetch data from required tables
select matnr spart form mara into table itab
where............
Create a file on application server
gv_file = path + file name
OPEN DATASET gv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
Transfer the records to the file
LOOP AT itab nto wa_itab
TRANSFER wa_itab TO gv_file.
ENDLOOP.
Close the file
CLOSE DATASET gv_file.
Hope this will help you.
‎2009 Sep 08 11:20 AM
thank you for this very fast reply. I will check it an let you know if I have had success.
Regards
Alexander