Transfer a file from App Server to a FTP site.
Hi, Abapers.
I need your help. Probably, this topic has already been posted in a similar way, but we need an answer to solve our problem.
We have to sent a PDF file from a directory of our app server (AIX) to a FTP directory... which would the FM sequence we should use to goal it?
Best Regards.
Hi Santiago,
create fm to send file from APP server to FTP site.
if you want to Post file from desktop to Appl use Transaction - CG3Y
if you want to Post file from Appl to Desktop use Transaction - CG3Z
copy the code below....
* Author: Prabhudas Date: 02/21/2006 *
* Name: Z_FTP_FILE_TO_SERVER *
* Title: FTP File on R/3 Application Server to External Server *
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(DEST_HOST) TYPE C
*" REFERENCE(DEST_USER) TYPE C
*" REFERENCE(DEST_PASSWORD) TYPE C
*" REFERENCE(DEST_PATH) TYPE C
*" REFERENCE(SOURCE_PATH) TYPE C
*" REFERENCE(FILE) TYPE C
*" REFERENCE(BINARY) TYPE CHAR1 OPTIONAL
*" REFERENCE(REMOVE_FILE) TYPE CHAR1 OPTIONAL
*" TABLES
*" FTP_SESSION STRUCTURE ZMSG_TEXT OPTIONAL
*" EXCEPTIONS
*" CANNOT_CONNECT
*" SOURCE_PATH_UNKNOWN
*" DEST_PATH_UNKNOWN
*" TRANSFER_FAILED
*" COMMAND_FAILED
DATA: w_password TYPE zftppassword,
w_length TYPE i,
w_key TYPE i VALUE 26101957,
w_handle TYPE i,
w_command(500) TYPE c.
REFRESH ftp_session.
* Scramble password (new Unicode-compliant routine)
w_length = STRLEN( dest_password ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = dest_password
sourcelen = w_length
key = w_key
IMPORTING
destination = w_password.
* Connect to FTP destination (DEST_HOST)
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = dest_user
password = w_password
host = dest_host
rfc_destination = 'SAPFTPA'
IMPORTING
handle = w_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING cannot_connect.
ENDIF.
* Optionally, specify binary file transfer
IF binary = 'X'.
w_command = 'bin'.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING command_failed.
ENDIF.
ENDIF.
* Navigate to source directory
CONCATENATE 'lcd' source_path INTO w_command SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING source_path_unknown.
ENDIF.
* Navigate to destination directory
CONCATENATE 'cd' dest_path INTO w_command SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING dest_path_unknown.
ENDIF.
* Transfer file
CONCATENATE 'put' file INTO w_command SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING transfer_failed.
ENDIF.
* Disconnect from destination host
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = w_handle.
* Optionally, remove file from source directory
IF remove_file = 'X'.
CONCATENATE source_path '/' file INTO w_command.
CONCATENATE 'rm' w_command INTO w_command SEPARATED BY space.
OPEN DATASET '/dev/null' FOR OUTPUT FILTER w_command.
CLOSE DATASET '/dev/null'.
ENDIF.
Regards,
Prabhudas
Similar Messages
-
Download PDF file from APP server!
Hi!
Has anyone tried uplaoding and downloding a PDF table from app server as I tried from a normal method by Open dataset, Transfer but it wont work.
Please provide any inputs.
Thanks.Hi park,
1. Using open data set, transfer , close etc,
also it will work.
( it will download / upload any kind of file from app server)
2. Just make sure the
FULL PATHNAME and the FILENAME
are mentioned in EXACT CASE
(small/CAPITAL).
3. U can check thru transaction AL11, to see the file and path.
regards,
amit m. -
System exception while deleting the file from app server in background job
Hi All,
I have a issue while the deleting the file from application server.
I am using the statement DELETE DATASET in my program to delete the file from app server.
I am able to delete the file from the app server when i run the program from app server.
When i run the same report from background job i am getting the message called System exception.
Is there any secuirity which i need to get the issue.
Thank You,
TaraginiHi All,
I get all the authorization sto delete the file from application serever.
Thing is i am able to run the program sucessfully in foreground but not in the background .
It i snot giving any short dump also just JOB is cancelled with the exception 'Job cancelled after system exception ERROR_MESSAGE'.
Can anybody please give me suggestion
Thanks,
Taragini -
Problem in downloading file from app server using CG3Y in to .XLS fomat
hi All,
I have uploaded file in to application server through a program using open data set with the separater as "|" ( pipe ) . Now the user should be able to download the file from apps server to presenataion server in .XLS format using txn CG3Y. but when we download, the format appears wierd and the data is not consistent across columns in excel. i.e the data which is supposed to be in one column in the excel is in the other column. what precautaions should i take before moving data to apps server so that it will be downloaded in a good format.
Appreciate your help...
Regards,
Sreekanth.Separate each values with TAB space present in the application server .
Currently u r using | pipe character. Instead of that use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB as delimiter.
Each value will displayed in separate cells in excel sheet when u download it frm app.server
Regards,
Lakshman. -
I want to transfer all the files from source server with respective directory to designation server with respective directory (designation server - oracle reside server).
Is it possible to ftp from one server to another server(designation server - oracle reside server) through pl/sql. these two servers are independent & unix server.No ... The package mentioned in
http://www.oracle-base.com/dba/miscellaneous/ftp.pks
this works for across the server i.e. transfer the files from one server to other (it is basically ftp) ..
So it is NOT correct that this code transfer the file between two location & with in server.. -
Problem with READ DATASET when reading file from app server
Hi,
wondering if anyone can help, I'm using the following code to read from a file on app server, the file is of type .rtf
OPEN DATASET file_rtf FOR INPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
DO.
READ DATASET file_rtf INTO string.
IF SY-SUBRC = 0.
EXIT.
ENDIF.
ENDDO.
the open dataset part works sy-subrc = 0, but the read returns sy-subrc = 8 and no data is passed to string.
Any ideas as to what is causing this problem appreciated, <removed>
Thanks
Edited by: Thomas Zloch on Mar 17, 2010 3:57 PM - please don't offer p...Hi Adam,
The source code in the below link has details about how to read/write to application server.
[Application server file operartions|http://www.divulgesap.com/blog.php?p=NDk=]
Please let us know if you have any issues.
Regards,
Ravi -
Issue with uploading flat file from App Server
Hi,
Im loading a flat file to an ODS.
When I try to load in from my Local Workstation, it works fine.
All data is loaded green.
However, when I try to load the file after i copied it to my App Server, it cannot load.
The error is get is:
Error 2 while splitting CSV data: see long text
Message no. RSDS_ACCESS011
Diagnosis
Error 2 occurred while splitting the CSV data string.
1 = Could not find a closing escape character
2 = Invalid escape character
3 = Conversion error
4 = OTHERS
The thing is that it worked fine (exact same file no changes) when I loaded from my Desktop.
Appreciate any help or input.
Rgds,
Gary.Gary,
You can load it from the App server. Just check the file name whther you are giving it correctly and also check the readio button from App Server.
Go to AL11 (Tcode) and cross check whther your file is there. See in which directory your file is there. Mention the same path in the extraction tab in IP.
Thanks...
Shambhu -
How to fetch file from app. server without complete filename?
Hi,
In my report I have to read data from txt file on application server.
My file name on App. server conatain system id and date and time stam.
my file path :- /User/IDD/S10009112007101525
here,'User' is dirctory
'IDD' is folder in directory
'S100' is system id
'09112007' is date
'101525' is time in hour,miniute,second format.
From my program I can only pass directory , Folder name,System Id,Date only. I don't have time value in my program.
So please tell me how to fetch files without having time stamp value from app. server.
Plz send me exact code.It's urgent.
Message was edited by:
Manisha Kadam
Title was edited by:
Alvaro Tejada GalindoDo you want to return the file to the user on click of button or something?
Then, use web_show_document with http link which you are speaking about.
Else download the file to client using Webutil. -
Load Flat File from App Server
HI, all.
I want load flat file from appliation server. I created CSV file and loaded it on app. server with FM ARCHIVEFILE_CLIENT_TO_SERVER. After I created datasource and tried load data in the infocube. In this procedure I encountered with two problem
1. When I look file in AL11, I doesn't see cyrillic symbols, instead this symbols I see #.
2. When I try load data with data source, I get exception RS_EXCEPTION 000 "File don't open"
Anybody can help me resolve this problem?
wbr, Fanil.Hi, kodanda pani KV.
2. File is was closed.
1. Can me you clearly explain what you meen?
wbr, Fanil -
Move file from App server to same server on different path
Hi All,
I have to move a file from Application server to a folder in the same server....
pls tell me how can i do this....
its very urgent....
Thanks...............Hi
First you read the file in output mode using Open dataset and Read dataset statement with the initial application server path.
Then write this data back to another file path by opening the file in Input mode and using Transfer statement.
Example.
open dataset <file1> mode output encding default.
if sy-subrc = 0.
do.
read dataset <file1> into wa_itab.
if sy-subrc = 0.
append wa_itab to itab.
else.
exit.
endif.
enddo.
open dataset <file2> mode input encding default.
if sy-subrc = 0.
loop at itab into wa_itab.
transfer wa_itab to <file2>.
endloop.
endif.
~ Ranganath
PS : Reward points for all useful answers ! -
hi, i am running a background job in bw and for that created a file on the application server.now how do i delete that file.to create the file i just gave the name in the bw and the file got created.i am not able to find how to delete it.
or
rather than deleting the file how can we delete the data it is containing.please do let me knowhi,
but using DELETE DATASET u can remove file for app server.
If u want to delete the data alone then give the same name without data it will overwrite.
U can check it in AL11.
regards
md zubair sha
U can also use the function module - EPS_DELETE_FILE
Message was edited by:
md zubair sha -
Validate the file from app. server before uploading
Hi All,
I am trying to upload the data from application server into an internal table.
My requirement is I need to validate the data before I upload the data into internal table.(i.e I open the file from application server using FM Open_Dataset.Now before I upload the data into an internal table,I need to first validate each record in the file).I have some 7-8 lakhs of records in the file.
Any input for the above requirement would be of great help
Regards,
nsp.hi Nsp,
I guess validation of data will be only possible after uploading the data in to an internal table ...
Regards,
Santosh -
Reading uploaded file from app. server
Hi All,
I am trying to upload a .csv format file to app. server thru txn CG3Z....
When i try to open the file in my code thru open dataset and read dataset ...it is giving it in the form of
30002058,1000#50055501,2000#
Now i want it to be in
30002058,1000
50055501,2000
format...
pleas suggest..
thnx
RkHi Rahul,
have you tried reading it in BINary format?
Kind regards,
Alvaro -
Sent file from app. server vie mail
Hi all,
is there any standart program/function module that can be use to sent any file from application server via mail (as attachement), or i have to write it for myself? I have tried to search for it, but without success.
Thank you,
Ondrej SustacekHi Ondrej,
Once I had the same requirement. Please feel free to use my code. I placed it for you in Wiki:
[Sending Application Server file via emial as attachement|https://wiki.sdn.sap.com/wiki/x/UwVqBg]
Small description how it works is included with the code.
Regards
Marcn -
Convertion pdf file from App. server to Pre.server
Hi,
I have file pdf file in application server. i want to convert this PDF file into presention server.
plese send simple progrme.
Thank&
Regards,
MadhuAlso try
FYI
REPORT ztrans01 .
*Parameters(files)
PARAMETERS: ux_dir TYPE epsf-epsdirnam OBLIGATORY
DEFAULT '/usr/sap/trans',
filename TYPE epsf-epsfilnam OBLIGATORY DEFAULT 'test1',
pc_dir TYPE rlgrap-filename OBLIGATORY
DEFAULT 'c:\tmp'.
*DATA(Strings)
DATA itab TYPE TABLE OF string.
DATA wa TYPE string.
DATA file TYPE string.
DATA size TYPE epsf-epsfilsiz.
DATA ux_file TYPE epsf-epspath.
DATA mode TYPE epsf-epstxtmod.
*start-of-selection
START-OF-SELECTION.
*1) transfer
CONCATENATE ux_dir '/' filename INTO ux_file.
OPEN DATASET ux_file FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
MESSAGE i502(me) WITH ux_file.
ENDIF.
DO.
READ DATASET ux_file INTO wa.
IF sy-subrc <> 0. EXIT . ENDIF.
APPEND wa TO itab.
ENDDO.
CLOSE DATASET ux_file.
*2)download
CONCATENATE pc_dir '\' filename INTO file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = file
TABLES
data_tab = itab.
OR
*& Form f1104_download_to_lofile
Download to data from internal table to Logical File/application server
FORM f1104_download_to_lofile.
Open the file in application server
OPEN DATASET v_filepht FOR OUTPUT IN TEXT MODE.
IF sy-subrc <> 0.
MESSAGE s185 WITH v_filepht.
LEAVE LIST-PROCESSING.
ENDIF.
LOOP AT i_logfile INTO w_logfile.
TRANSFER w_logfile TO v_filepht.
CLEAR w_logfile.
ENDLOOP.
IF sy-subrc = 0.
WRITE:/ text-055, v_filepht, text-056.
ELSE.
WRITE:/ text-057, v_filepht.
ENDIF.
Closing the file
CLOSE DATASET v_filepht.
and also check link
http://sap.ittoolbox.com/code/archives.asp?d=2285&a=s
Hope thisll give you idea!!
<b>P.S award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
Maybe you are looking for
-
I am able to open both home shares on our computers and can see the library I want to take tv shows from, but can't figure out how to actually move the tv show from his library to mine.
-
Duplicate Invoice Check for Transaction MIR7
Hi Experts, My client requirment is . Currenty system checks the BUKRS,LIFNR,WAERS,XBLNR,WRBTR,BLDAT for duplicate invoice this is a standard SAP functionality for T.code MIR7. Logic needs to be changed Duplicate Check in SAP for Vendor invoices to o
-
Hi All, Can anyone send me the End User Training Doc to my id [email protected] its little urgent to me i will appreciate in SDn way thanks in adv
-
Mavericks Startup Drive read only
I can't find details on this anywhere. I waited a while to upgrade because Lion apparently did not play well with Adobe CS5. Mavericks, on the other hand, is supposed to. (I may upgrade to CS6 soon, but I like "owning"" my software and being able to
-
HT4113 I restriction settings is turned on and I forgot the password iPhone 5
Restriction studies is turned on and I forgot my password on my iPhone 5