‎2008 May 15 9:21 AM
Hi all,
We do have couple of interfaces where SAP needs to put their files into FTP server so that XI can pick it up and vice versa.
As of now the files are been put into Application server of SAP and sent manually via email.
Let me know the possible ways for the same.
Your help is most appreciated!
‎2008 May 15 9:32 AM
If you are trying to write files from SAP using ABAP to an FTP server for XI to process, you are missing the point to XI.
You should be sending the data to XI via an ABAP proxy.
‎2008 May 15 9:32 AM
If you are trying to write files from SAP using ABAP to an FTP server for XI to process, you are missing the point to XI.
You should be sending the data to XI via an ABAP proxy.
‎2008 May 15 9:45 AM
Hi,
Sorry, it is already too late. As SAP is not sending via RFC, IDOC or Proxy, do let me know for any other alternative.
‎2008 May 15 9:35 AM
So what exactly is your question? An alternative to email, or how to do FTP in SAP?
1. For FTP have a look at all the sample programs etc. in package SFTP.
2. Alternative would be to connect to XI via RFC for sending files. Create a generic FM which can handle all transfers (table of type STRING for example).
‎2008 May 15 9:38 AM
Hi,
one Possiblilty is create a staging directory in the XI server then FTP the files to that server using the 2methods,
1- using this program to FTp files outside of SAP
DATA: hdl TYPE i,
compress TYPE c VALUE 'N',
ftp_command(200) TYPE c,
dest LIKE rfcdes-rfcdest VALUE 'SAPFTPA'.
data : key type i value 26101957,
dstlen type i .
TRANSLATE command TO LOWER CASE.
TRANSLATE transfer_type TO LOWER CASE.
TRANSLATE verify TO UPPER CASE.
CASE command.
WHEN 'put'.
WHEN 'get'.
WHEN 'append'.
WHEN OTHERS.
RAISE command_error.
ENDCASE.
CASE transfer_type.
WHEN 'ascii'.
WHEN 'binary'.
WHEN 'ebcdic'.
WHEN 'image'.
WHEN 'local m'.
WHEN 'tenex'.
WHEN ' '.
transfer_type = 'ascii'.
WHEN OTHERS.
RAISE type_error.
ENDCASE.
CASE verify.
WHEN 'Y' OR 'YES' OR ' '.
verify = 'X'.
WHEN OTHERS.
verify = ' '.
ENDCASE.
IF sourcefile = ' ' AND command = 'put'.
RAISE file_error.
ENDIF.
IF sourcefile = ' ' AND command = 'append'.
RAISE file_error.
ENDIF.
IF targetfile = ' ' AND command = 'get'.
RAISE file_error.
ENDIF.
CONCATENATE command sourcefile targetfile
INTO ftp_command
SEPARATED BY space.
**********
**********
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = user
password = pwd
host = host
rfc_destination = dest
IMPORTING
handle = hdl
EXCEPTIONS
not_connected = 8.
CASE sy-subrc.
WHEN 0.
WHEN OTHERS.
RAISE connection_error.
ENDCASE.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = hdl
command = transfer_type
TABLES
data = data
EXCEPTIONS
command_error = 1
tcpip_error = 2
data_error = 3.
CASE sy-subrc.
WHEN 0.
WHEN 1.
RAISE command_error.
WHEN 2.
RAISE tcpip_error.
WHEN 3.
RAISE data_error.
WHEN OTHERS.
RAISE other_error.
ENDCASE.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = hdl
command = ftp_command
compress = compress
verify = verify
TABLES
data = data
EXCEPTIONS
command_error = 1
tcpip_error = 2
data_error = 3.
CASE sy-subrc.
WHEN 0.
WHEN 1.
RAISE command_error.
WHEN 2.
RAISE tcpip_error.
WHEN 3.
RAISE data_error.
WHEN OTHERS.
RAISE other_error.
ENDCASE.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = hdl.
ENDFUNCTION.2- Oresle use a UNIX script for transfering the file to that XI server.
Reward if useful
Thanks,
Aditya
‎2008 May 15 10:18 AM
Hi,
What do u mean by staging directory in XI? Can you be more specific on this.
‎2008 May 15 9:41 AM
XI can do the file transfer for you. The main idea of having XI is to act as a mediator for transfering informations across different landscape or systems. Send your data to XI and then it can put it across to the desired destination. Ask your XI consultant for more information.
‎2008 May 15 10:31 AM
Hi,
The below program is to create file on FTP server by taking the data from internal table.
To see whether the file is created on the FTP server
use the function module FTP_SERVER_TO_R3.
Check the below code.
You write a same program with the function module FTP_SERVER_TO_R3 instead of
FTP_R3_TO_SERVER to check the existence of the file which is already created.
tables: t777a. "Building Addresses
Internal Table for Building table.
data: begin of it_t777a occurs 0,
build like t777a-build, "Building
stext like t777a-stext, "Object Name
cname like t777a-cname, "Address Supplement (c/o)
ort01 like t777a-ort01, "City
pstlz like t777a-pstlz, "Postal Code
regio like t777a-regio, "Region (State, Province, County)
end of it_t777a.
Internal Table for taking all fields of the above table in one line
separated by |(pipe).
data: begin of it_text occurs 0,
text(131),
end of it_text.
Constants: c_key type i value 26101957,
c_dest type rfcdes-rfcdest value 'SAPFTPA'.
data: g_dhdl type i, "Handle
g_dlen type i, "pass word length
g_dpwd(30). "For storing password
Selection Screen Starts
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
parameters: p_user(30) default 't777a' obligatory,
p_pwd(30) default 't777a' obligatory,
p_host(64) default 'XXX.XXX.XX.XXX' obligatory.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE TEXT-002.
parameters: p_file like rlgrap-filename default 't777a_feed.txt'.
SELECTION-SCREEN END OF BLOCK blk2.
Password not visible.
at Selection-screen output.
loop at screen.
if screen-name = 'P_PWD'.
screen-invisible = '1'.
modify screen.
endif.
endloop.
g_dpwd = p_pwd.
Start of selection
start-of-selection.
To fetch the data records from the table T777A.
select build stext cname ort01 pstlz regio
from t777a
into table it_t777a.
Sort the internal table by build.
if not it_t777a[] is initial.
sort it_t777a by build.
endif.
Concatenate all the fields of above internal table records in one line
separated by |(pipe).
loop at it_t777a.
concatenate it_t777a-build it_t777a-stext it_t777a-cname
it_t777a-ort01 it_t777a-pstlz it_t777a-regio
into it_text-text separated by '|'.
append it_text.
clear it_text.
endloop.
To get the length of the password.
g_dlen = strlen( g_dpwd ).
Below Function module is used to Encrypt the Password.
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = g_dpwd "Actual password
SOURCELEN = g_dlen
KEY = c_key
IMPORTING
DESTINATION = g_dpwd. "Encyrpted Password
*Connects to the FTP Server as specified by user.
Call function 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'Connecting to FTP Server'.
Below function module is used to connect the FTP Server.
It Accepts only Encrypted Passwords.
This Function module will provide a handle to perform different
operations on the FTP Server via FTP Commands.
call function 'FTP_CONNECT'
EXPORTING
user = p_user
password = g_dpwd
host = p_host
rfc_destination = c_dest
IMPORTING
handle = g_dhdl
EXCEPTIONS
NOT_CONNECTED.
if sy-subrc ne 0.
format color col_negative.
write:/ 'Error in Connection'.
else.
write:/ 'FTP Connection is opened '.
endif.
**Transferring the data from internal table to FTP Server.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = g_dhdl
FNAME = p_file
CHARACTER_MODE = 'X'
TABLES
TEXT = it_text
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
write:/ 'File has created on FTP Server'.
ENDIF.
Call function 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'File has created on FTP Server'.
To Disconnect the FTP Server.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
HANDLE = g_dhdl.
To Disconnect the Destination.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = c_dest
EXCEPTIONS
others = 1.
‎2008 May 15 10:36 AM
hi,
I am sure i could help you ,i ve the scripts to do the FTP and i could give you by tommorrow as i dont ve all those scripts in my system now , for tha u need to know the receiving system ip address.
Thanks
‎2008 May 15 12:15 PM
Hi ,
I think the best way is passing your data to XI using ABAP PROXY and than let the XI do the rest. However the optimized method which you're trying to find out is also up to your file format.