MUNDOSAP

Regresar   MUNDOSAP > DESARROLLO > Programación ABAP IV
Nombre de Usuario
Contraseña
Home Descargas Registrar FAQ Miembros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




 
Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Viejo 19/01/07, 14:49:40
Avatar de DCErick
DCErick DCErick is offline
Moderator
 
Fecha de Ingreso: mar 2006
Localización: Monterrey
Mensajes: 1,090
Ftp

Hola alguien sabra que funciones existen para trabajar con FTP, lo que necesito es conectarme a un sitio FTP, subir un archivo que el BANCO me dejara ahi y luego borrarlo.

Pero no tengo idea de como hacerlo.....

__________________
-------------------
¿Dudas para descargar manuales? Ver este tema ->
Responder Con Cita
  #2  
Viejo 19/01/07, 19:53:20
andyoscky andyoscky is offline
Miembro Honorario
 
Fecha de Ingreso: mar 2006
Mensajes: 73
Ejemplo

estructura zx

MANDT MANDT CLNT 3 0 Mandante
SOURCE LOCALFILE CHAR 128 0 Fichero local para upload/download
DESTINATION LOCALFILE CHAR 128 0 Fichero local para upload/download
FILENAME LOCALFILE CHAR 128 0 Fichero local para upload/download
________________ ______________________________ __________ ______ ______ ____________________________________________________________


*"----------------------------------------------------------------------
*"*"Interfase local
*" IMPORTING
*" REFERENCE(HOST) TYPE C
*" REFERENCE(USERID) TYPE C
*" REFERENCE(PASSWORD) TYPE C
*" REFERENCE(USAGE) TYPE C
*" REFERENCE(RFC_DESTINATION) LIKE RFCDES-RFCDEST
*" TABLES
*" COMMANDS
*" RESULTS
*" FILES STRUCTURE Zx
*" EXCEPTIONS
*" INVALID_USAGE
*" NO_FILES_TO_TRANSFER
*" NO_FTP_COMMANDS_TO_EXECUTE
*" FTP_CONNECTION_FAILED
*" FTP_COMMAND_FAILURE
*"----------------------------------------------------------------------


*Function Z_x
*
*Purpose: This function module simplifies implementation of FTP
*functionality by reducing the setup required and number of calls
*involved within ABAP. This function can operate by passing a table of
*files with source and destination locations to be transferred or by
*passing a table of FTP commands to be executed.
*
*Parameter Description:
*
*HOST The host address of the FTP server. Usually specified as
*an IP address. (ex. 65.212.34.120)
*
*USERID The userid used to login to the FTP server
*
*PASSWORD The password used to login to the FTP server. Unlike the
*manual implementation of FTP this function accepts only
*plain text passwords.
*
*USAGE Determines the mode of operation for ZEASY_FTP. Valid
*values are ‘S’, ‘R’, or ‘A’.
*
*‘S’end – When using mode ‘S’ a table of filenames (FILES)
*with the corresponding source and destination locations are passed in.
*The function will send all files from their source locations to the
*destination locations on the FTP server.
*
*‘R’etrieve – When using mode ‘R’ a table of filenames (FILES) with the
*corresponding source and destination locations are passed in. The
*function will retrieve all files from the source locations on the FTP
*server and place them in the appropriate destination locations.
*
*‘A’dvanced – When using mode ‘A’ a table of commands (COMMANDS) is
*passed in. These commands are executed in sequential order.
*
*RFC_DESTINATION Determines which ‘local’ view to use during the
*transfer process. Valid values are ‘SAPFTP’ or
*‘SAPFTPA’. These destinations are configured in SM59 and already exist
*as defaults provided by SAP.
*
*‘SAPFTP’ – Use this value to transfer files between
*the GUI front-end machine and the FTP server.
*
*‘SAPFTPA’ – Use this value to transfer files between the SAP
*application server and the FTP server.
*
*
*
*
*
*
*
*Table Description:
*
*COMMANDS Table of FTP commands for processing. When using modes ‘S’ or
*‘R’ this table will be filled on successful execution of ZEASY_FTP
* with* the FTP commands used to perform the file transfer. When using
*mode ‘A’ this table must be filled by the calling program with valid
*FTP commands to be executed by ZEASY_FTP.
*
*RESULTS Table containing a log of the FTP session results.
*
*FILES Table containing the source location, destination location,
*and filename of each file to be transferred. When using
*modes ‘S’ or ‘R’ this table must be filled by the calling program.
*
*The structure of the FILES table consists of the following:
*SOURCE LIKE LOCALFILE (RLGRAP-FILENAME)
*DESTINATION LIKE LOCALFILE (RLGRAP-FILENAME)
*FILENAME LIKE LOCALFILE (RLGRAP-FILENAME)
*
*Exception Description:
*
*INVALID_USAGE The usage specified was not equal to a valid value
*consisting of ‘S’, ‘R’, or ‘A’.
*
*NO_FILES_TO_TRANSFER Mode ‘S’ or ‘R’ was specified for usage; however,
*the necessary table of FILES was not specified.
*
*NO_FTP_COMMANDS_TO_EXECUTE Mode ‘A’ was specified for usage;
*however, the necessary table of COMMANDS
*to be executed was not specified.
*
*FTP_CONNECTION_FAILED There was a problem establishing the FTP
*connection. Please verify the host
*address, userid, and password of the FTP
*server. Also verify that the correct
*RFC_DESTINATION was specified.
*
*FTP_COMMAND_FAILURE There was a problem executing the FTP
*commands. Please check commands for
*validity.





*----------------------------------------------------------------------*

*DOCUMENTATION/NOTES
* Date: 05/2003
*
* USAGE = 'S'end, 'R'etrieve, 'A'dvanced
* RFC_DESTINATION = 'SAPFTP', 'SAPFTPA' - defined in SM59
*
* Be aware that FTP userid's, passwords, and commands are case
* sensitive! For easiest use please make sure that the FTP account has
* been created with a lowercase userid and password and TRANSLATE
* the userid and password parameters to lower case before calling this
* function.
*
* Cannot test ZEASY_FTP, FTP_CONNECT, or other functions that use
* FTP_CONNECT from function tester (auto converts test data to upper
* case)!
*
* Parameters on selection screens are auto converted to upper case
* during AT SELECTION-SCREEN.
*
* Structure of ZEASYFTP_FILES (FILES table)
* SOURCE LIKE LOCALFILE
* DESTINATION LIKE LOCALFILE
* FILENAME LIKE LOCALFILE
*
*---------------------------------------------------------------------*

data: l_key type i value 26101957.
data: l_length type i.
data: l_lines type i.
data: l_ftp_handle type i.
data: l_cd_src(3) type c.
data: l_cd_dest(3) type c.
data: l_transfer_command(3) type c.

*----------------------------------------------------------------------*

*ENSURE PROPER EXECUTION *
*----------------------------------------------------------------------*

if usage ne 'S' and usage ne 'R' and usage ne 'A'.
raise invalid_usage.
endif.

case usage.
when 'A'.
describe table commands lines l_lines.
if l_lines = 0.
raise no_ftp_commands_to_execute.
endif.
when 'S' or 'R'.
clear: commands. refresh: commands.

describe table files lines l_lines.
if l_lines = 0.
raise no_files_to_transfer.
endif.

* build commands
if usage = 'S'.
l_cd_src = 'lcd'.
l_cd_dest = 'cd'.
l_transfer_command = 'put'.
elseif usage = 'R'.
l_cd_src = 'cd'.
l_cd_dest = 'lcd'.
l_transfer_command = 'get'.
endif.

sort files by source destination.

loop at files.
at new source.
if not files-source is initial.
concatenate l_cd_src files-source into commands
separated by space.
append commands.
endif.
endat.

at new destination.
if not files-destination is initial.
concatenate l_cd_dest files-destination into commands
separated by space.
append commands.
endif.
endat.

if not files-filename is initial.
concatenate l_transfer_command files-filename into commands
separated by space.
append commands.
endif.
endloop.
endcase.

*----------------------------------------------------------------------*

*ENCRYPT PASSWORD *
*----------------------------------------------------------------------*

l_length = strlen( password ).

call 'AB_RFC_X_SCRAMBLE_STRING'
id 'SOURCE' field password id 'KEY' field l_key
id 'SCR' field 'X' id 'DESTINATION' field password
id 'DSTLEN' field l_length.

*----------------------------------------------------------------------*

*ESTABLISH FTP CONNECTION *
*----------------------------------------------------------------------*

call function 'FTP_CONNECT'
exporting
user = userid
password = password
host = host
rfc_destination = rfc_destination
importing
handle = l_ftp_handle
exceptions
not_connected = 1
others = 2.

if sy-subrc <> 0.
raise ftp_connection_failed.
endif.

*----------------------------------------------------------------------*

*PROCESS FTP COMMANDS *
*----------------------------------------------------------------------*

call function 'FTP_COMMAND_LIST'
exporting
handle = l_ftp_handle
tables
data = results
commands = commands
exceptions
tcpip_error = 1
command_error = 2
data_error = 3
others = 4.

if sy-subrc <> 0.
raise ftp_command_failure.
endif.

*----------------------------------------------------------------------*

*CLOSE FTP CONNECTION *
*----------------------------------------------------------------------*

call function 'FTP_DISCONNECT'
exporting
handle = l_ftp_handle.


endfunction.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Reglas de Mensajes
no puedes crear nuevos temas
no puedes responder temas
no puedes adjuntar archivos
no puedes editar tus mensajes

El código vB está On
Las caritas están On
Código [IMG] está On
Código HTML está Off
Saltar a Foro


Husos Horarios son GMT. La hora en este momento es 07:25:44.


www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web