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

File transfer to application server

Former Member
0 Likes
6,559

Hi everyone,

I have to transfer a file to application server and get the file from application server. After that if the file exist means i have to append the data to that file in the application server. Pls help me.

Thanks In Advance

Regards,

Ekadevi.S

Hi everyone,

I have to transfer a file to application server and get the file from application server. After that if the file exist means i have to append the data to that file in the application server. Pls help me.

Thanks In Advance

Regards,

Ekadevi.S

5 REPLIES 5
Read only

Former Member
0 Likes
2,629

Hi

*if you want to append to existing file .

open dataset p_file in text mode for appending.

transfer tab1 to p_file.

sy-subrc ne 0 . "if file does not exists .

  • if you want to create new or replace

open dataset p_file in text mode for input.

transfer tab1 to p_file.

P_file is file path on appl serever.

Regards

vinay

Edited by: vinay kolla on Jul 2, 2009 6:08 AM

Edited by: vinay kolla on Jul 2, 2009 6:16 AM

Read only

Former Member
0 Likes
2,629

hi

use tcode CG3Z for uploading

and CG3Y for downloading.

Enter the source file and target file information for the above tcodes

Read only

Former Member
0 Likes
2,629

Hi ,

Firstly you upload file to application server using Transaction code " CG3Z ,

after the in the program ,use following code.

-


open dataset P_File for input in text mode

do.

read dataset p_file into t_tab(internal table)

if sy-subrc <> 0.

exit.

endif.

enddo.

close dataset p_file.

Thanks

Shambhu

Read only

Former Member
0 Likes
2,629

Hi:

There is a function module - EPS_GET_DIRECTORY_LISTING - it gives the list of directory and its file. Just check whether your given file is there or not. If yes, then use open dataset p_file in text mode for appending

else OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

and then rest code would be same as

LOOP AT gt_message ASSIGNING <lfs_message> CASTING.

TRANSFER <lfs_message> TO lv_file.

CLEAR gs_message.

ENDLOOP.

*----Close the file in the application server

CLOSE DATASET lv_file.

Regards

Shashi

Read only

Former Member
0 Likes
2,629

Hi

If you want to transfer the file to App Server through a custom Program, then you need to use

V_FILENAME = Complete path with filename.

Open dataset V_FILENAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

if sy-subrc EQ 0.

loop at itab into watab.

move watab to V_String.

transfer V_String to V_FILENAME

endloop.

endif.

If you want to transfer the file to App Server manually then use the transaction.

CG3Z

If you want to get the file from App Server through a custom Program, then you need to use

Open dataset V_FILENAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.

if SY-SUBRC EQ 0.

DO.

Read dataset V_FILENAME INTO V_STRING.

if sy-subrc ne 0.

exit.

endif.

Move this V_string to Wa

append wa to itab

enddo.

endif.

If you want to Copy the file from App Server manually then use the transaction.

CG3Y

If you want to append the file , then first find out if the file is present in the asked location or not.

Call the FM to List all the Files in the directory - 'RZL_READ_DIR_LOCAL' and store the data in an internal table

Search this internal table to see if the file already exists.

if it is present use

OPEN dataset V_FILENAME in text mode for appending.

if sy-subrc EQ 0.

loop at itab into watab.

move watab to V_String.

transfer V_String to V_FILENAME

endloop.

endif.

Do not forget to CLOSE DATEST after opening it.

Cheers