Mover archivos de ftp a ftp

Colapsar
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • vamp_01
    Senior Member
    • jun
    • 109

    #1

    Mover archivos de ftp a ftp

    Hola a todos, priemro que nada creo que es mi primer post...a que se debe esto, a que los problemas que he tenido....en este foro, ya tenia una solucion la cual en algunos casos fue directa y en otras me ha llevado mas tiempo en implementar, pero a la larga la ayuda ha sido casi entera desde aca.

    Bueno y al final aca estoy...preguntando.

    Miren necesito hacer lo siguiente, mover un archivo desde un ftp origen que va a estar situado en mi servidor y un ftp destino que va a estar fuera de mi servidor, sin manejo de datos del archivo, simplemente moverlo.
    a lo mejor es algo muy trivial, pero estoy hecho bolsa, con este desarrollo
    sin mas que decir y agradeciendo su ayuda de ante mano

  • bisonye
    Senior Member
    • ago
    • 635

    #2
    Hola,

    No lo he hecho nunca pero busca funciones *FTP* y en los foros ya que hay algo comentado.

    Saludos
    http://sapymas.blogspot.com/

    Comentario

    • DCErick
      Moderator
      • mar
      • 1090

      #3
      Te mando un ejemplo para trabajar con FTP espero y te sea de utilidad.
      Código:
      REPORT  zsd_deposito_bancarios.
      
      DATA: BEGIN OF outrec,
              matnr(15),
              maktx(30),
              ean11(18),
              bismt LIKE mara-bismt,
            END OF outrec.
      
      CONSTANTS: user(12) TYPE c VALUE 'user',
            pwd(20) TYPE c VALUE 'pwd'.
      
      DATA: hdl TYPE i,
            key TYPE i VALUE 26101957,
            dstlen TYPE i,
            upc(11) TYPE n.
      
      DATA: BEGIN OF result OCCURS 0,
            line(100) TYPE c,
            END OF result.
      
      DATA: BEGIN OF commands OCCURS 0,
            line(100) TYPE c,
            END OF commands.
      
      
      DATA: wrkfile LIKE rlgrap-filename VALUE '/sapmnt/data/outbound/'.
      
      *PARAMETERS :  p_cmd(200)  TYPE c.
      
      END-OF-SELECTION.
      
        PERFORM connect_ftp
                    CHANGING
                       hdl.
      
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ELSE.
      *Cerramos Conección FTP
      
      
          CALL FUNCTION 'FTP_COMMAND'
            EXPORTING
              handle        = hdl
              command       = 'ls' "'get 007000001247.txt \\1.168.1.33\Instaladores\007000001247.txt'
            TABLES
              data          = result
            EXCEPTIONS
              command_error = 1
              tcpip_error   = 2.
      
          IF sy-subrc = 0.
            PERFORM write_result.
      
      
          ELSE.
            PERFORM write_result.
            PERFORM disconnect_ftp.
          ENDIF.
        ENDIF.
      
      *&--------------------------------------------------------------------*
      *&      Form  Connect_FTP
      *&--------------------------------------------------------------------*
      *       text
      *---------------------------------------------------------------------*
      *      -->HDL        text
      *---------------------------------------------------------------------*
      FORM connect_ftp CHANGING hdl.
      ****Nos conentamos a sitio FTP.
        CALL 'AB_RFC_X_SCRAMBLE_STRING'
          ID 'SOURCE'      FIELD pwd    ID 'KEY'         FIELD key
          ID 'SCR'         FIELD 'X'    ID 'DESTINATION' FIELD pwd
          ID 'DSTLEN'      FIELD dstlen.
      
      
        CALL FUNCTION 'FTP_CONNECT'
          EXPORTING
            user                   = user
            password               = pwd
      *   ACCOUNT                =
            host                   = '1.168.0.252'
            rfc_destination        = 'SAPFTPA'
      *   GATEWAY_USER           =
      *   GATEWAY_PASSWORD       =
      *   GATEWAY_HOST           =
         IMPORTING
           handle                 = hdl
         EXCEPTIONS
           not_connected          = 1
           OTHERS                 = 2.
      
      ENDFORM.                    "Connect_FTP
      
      *&--------------------------------------------------------------------*
      *&      Form  WRITE_RESULT
      *&--------------------------------------------------------------------*
      *       text
      *---------------------------------------------------------------------*
      FORM write_result.
        LOOP AT result.
          WRITE : / result.
        ENDLOOP.
        PERFORM disconnect_ftp.
      ENDFORM.                    "WRITE_RESULT
      *&--------------------------------------------------------------------*
      *&      Form  DISCONNECT_FTP
      *&--------------------------------------------------------------------*
      *       text
      *---------------------------------------------------------------------*
      FORM disconnect_ftp.
      
        CALL FUNCTION 'FTP_DISCONNECT'
          EXPORTING
            handle = hdl.
      
      ENDFORM.                               " DISCONNECT_FTP
      -------------------
      ¿Dudas para descargar manuales? Ver este tema -> Cómo descargar manuales de la sección "Descargas" ?

      Comentario

      • vamp_01
        Senior Member
        • jun
        • 109

        #4
        me da el error que el usuario xxxxx no esta autorizado a la maquina xxx.xxx.xxx.xxx

        aca se cae

        CALL FUNCTION 'FTP_CONNECT'
        EXPORTING
        user = user
        password = pwd
        * ACCOUNT =
        host = '192.168.xxx.xxx'
        rfc_destination = 'SAPFTPA'
        * GATEWAY_USER =
        * GATEWAY_PASSWORD =
        * GATEWAY_HOST =
        IMPORTING
        handle = hdl
        EXCEPTIONS
        not_connected = 1
        OTHERS = 2.

        cuando me conecto con un cliente ftp, no tengo problemas con las credenciales que coloque
        ahora que significa esta linea dentro de la funcion

        rfc_destination = 'SAPFTPA'
        No kcho naaaaaaa

        Comentario

        Trabajando...