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

create and upload

Former Member
0 Likes
876

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
810

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

5 REPLIES 5
Read only

Former Member
0 Likes
810

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

Read only

Former Member
0 Likes
811

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

Read only

Former Member
0 Likes
810

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.

Read only

Former Member
0 Likes
810

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.

Read only

Former Member
0 Likes
810

thank you for this very fast reply. I will check it an let you know if I have had success.

Regards

Alexander