**********************************************************************
loop at ti_salida.
concatenate ti_salida-sociedad ';'
ti_salida-nombre ';'
ti_salida-rut ';'
ti_salida-cuenta ';'
ti_salida-cod_cliente ';'
ti_salida-clase_doc ';'
ti_salida-num_doc ';'
ti_salida-cme ';'
ti_salida-referencia ';'
ti_salida-factura ';'
ti_salida-fec_doc ';'
ti_salida-venc_neto ';'
ti_salida-demora ';'
ti_salida-sector ';'
ti_salida-importe_ml ';'
ti_salida-moneda_loc ';'
ti_salida-importe2 ';'
ti_salida-moneda2 ';'
ti_salida-asignacion ';'
ti_salida-non_banco ';'
ti_salida-url
into lv_data .
append lv_data to lt_data .
endloop.
IF sy-subrc NE 0.
FORMAT COLOR COL_NEGATIVE.
MOVE host TO lv_aux_msg.
WRITE:/ 'No fue posible conectarse al host ', host.
ELSE.
FORMAT COLOR COL_POSITIVE.
MOVE hdl TO lv_aux_msg.
WRITE:/ 'Conexin Exitosa. Sesin ', lv_aux_msg.
* Mod IM
* Seteo modo pasivo
REFRESH result.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = hdl
command = 'set passive on'
TABLES
data = result
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3.
IF sy-subrc EQ 0.
ENDIF.
IF sy-subrc EQ 0.
ENDIF.
IF sy-subrc NE 0.
FORMAT COLOR COL_NEGATIVE.
MOVE cmd TO lv_aux_msg.
WRITE: / 'Error al ejecutar comando ', lv_aux_msg .
ELSE.
FORMAT COLOR COL_POSITIVE.
MOVE cmd TO lv_aux_msg.
WRITE: / 'Comando exitoso ', lv_aux_msg.
REFRESH result.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = hdl
command = cmd
verify = 'X'
IMPORTING
filesize = filesize
filedate = filedate
filetime = filetime
TABLES
data = result
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3.
ENDIF.
IF sy-subrc NE 0.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'Error en la transferencia del archivo'.
ELSE.
FORMAT COLOR COL_POSITIVE.
MOVE docid TO lv_aux_msg.
WRITE: / 'Transferencia realizada con xito'.
WRITE: / 'Se genero el archivo ', lv_aux_msg.
ENDIF.
IF sy-subrc NE 0.
WRITE:/ 'No fue posible desconectar del FTP Server'.
ELSE.
WRITE:/ 'Desconectado de FTP Server'.
ENDIF.
ENDIF."Conectando FTP.