Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

File wrong converted after FTP transfer

Former Member
0 Kudos
106

Hello,

We got a strange problem when transfering a txt file.

The file looks like this before transfering it with a program that uses FTP commands:

410-00000 | ABBOCATH-T N°18 | 9057.000 | ST | 16.35 | 1301

410-00005 | ABBOCATH-T N°18 ABC | 56068.000 | ST | 28.41 | 1301

....

Once the file is transfered, it looks like this in the FTP folder:

410-00000 | ABBOCATH-T N°18 | 9057.000 | ST | 16.35 | 1301 □ 410-00005 | ABBOCATH-T N°18 ABC | 56068.000 | ST | 28.41 | 1301...

The problem is that breaklines are not recognized in this file, they have been changed by this strange character □ after 1301 (it's not exactly that character, but it looks like a square).

I was not able to copy the exact txt file, because that character was converted to a breakline, so I supose that this character means a breakline that is not recognized after transfer.

The code we're using is this:


*----------------------------------------------------------------------*
***INCLUDE LZHR_RFC_MOVFILEF01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  INICIALIZAR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM inicializar .

  DATA zvalor1 LIKE zgetdconst-valor1.

*  SELECT SINGLE valor1 INTO gv_filename
*           FROM zgetdconst  WHERE modulo  EQ 'HR'            AND
*                                  proyec  EQ 'SISSALUD'      AND
*                                  aplica  EQ 'FTP'           AND
*                                  campo   EQ 'FILENAME'      AND
*                                  correl  EQ '0001'.
* Construir
*Begin RVP17102008 
*  Concatenate 'STOCK_' sy-datum+6(2) sy-datum+4(2) sy-datum(4) '.TXT'
*  into gv_filename.
  CONCATENATE 'STOCK' sy-datum(4) sy-datum+4(2) sy-datum+6(2)  '.TXT'
  INTO gv_filename.
*End   RVP17102008
  IF sy-subrc NE 0.
  ENDIF.


  SELECT SINGLE valor1 INTO gv_user
           FROM zgetdconst  WHERE modulo  EQ 'HR'            AND
                                  proyec  EQ 'SISA'      AND
                                  aplica  EQ 'FTP'           AND
                                  campo   EQ 'USER'          AND
                                  correl  EQ '0001'.
  IF sy-subrc NE 0.
  ENDIF.


  SELECT SINGLE valor1 INTO gv_pwd
           FROM zgetdconst  WHERE modulo  EQ 'HR'            AND
                                  proyec  EQ 'SISA'      AND
                                  aplica  EQ 'FTP'           AND
                                  campo   EQ 'CLAVE'         AND
                                  correl  EQ '0001'.
  IF sy-subrc NE 0.
  ENDIF.


  SELECT SINGLE valor1 INTO gv_host
           FROM zgetdconst  WHERE modulo  EQ 'HR'            AND
                                  proyec  EQ 'SISA'      AND
                                  aplica  EQ 'FTP'           AND
                                  campo   EQ 'SERVER'        AND
                                  correl  EQ '0001'.
  IF sy-subrc NE 0.
  ENDIF.

  SELECT SINGLE valor1 INTO zvalor1
           FROM zgetdconst  WHERE modulo  EQ 'HR'            AND
                                  proyec  EQ 'SISA'      AND
                                  aplica  EQ 'FTP'           AND
                                  campo   EQ 'RFC_DEST'      AND
                                  correl  EQ '0001'.
  IF sy-subrc EQ 0.
    gv_rfc_dest = zvalor1.
  ELSE.
  ENDIF.

  SELECT SINGLE valor1 INTO gv_path
           FROM zgetdconst  WHERE modulo  EQ 'HR'            AND
                                  proyec  EQ 'SISA'      AND
                                  aplica  EQ 'FTP'           AND
                                  campo   EQ 'PATH'          AND
                                  correl  EQ '0001'.
  IF sy-subrc NE 0.
  ENDIF.
ENDFORM.                    " INICIALIZAR
*&---------------------------------------------------------------------*
*&      Form  PROCESAR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM procesar .
  DATA: BEGIN OF tbl_ftp_return OCCURS 0,
          line(100) TYPE c,
        END OF tbl_ftp_return.

  DATA: zstrlen        TYPE i,
        zhandle        TYPE i,
        zftp_cmd(100)  TYPE c,
        zftp_err(100)  TYPE c.


*  ztext = gv_host. CONDENSE ztext.
*  CONCATENATE text-i14 ztext text-i11 INTO ztext SEPARATED BY space.
*  PERFORM sapgui_progress_indicator USING ztext.

  SET EXTENDED CHECK OFF.
  zstrlen = STRLEN( gv_pwd ).

  TRANSLATE gv_user TO LOWER CASE.
  TRANSLATE gv_pwd TO LOWER CASE.


  CALL FUNCTION 'HTTP_SCRAMBLE'
    EXPORTING
      SOURCE      = gv_pwd
      sourcelen   = zstrlen
      key         = gc_http_key
    IMPORTING
      destination = gv_pwd.
  .

* Open FTP
  CALL FUNCTION 'FTP_CONNECT'
    EXPORTING
      user            = gv_user
      password        = gv_pwd
      host            = gv_host
      rfc_destination = gv_rfc_dest
    IMPORTING
      handle          = zhandle
    EXCEPTIONS
      not_connected   = 1
      OTHERS          = 2.
  IF sy-subrc NE 0.
*    MESSAGE i117 DISPLAY LIKE 'E' WITH reg_ftp_data-host .
    EXIT.
  ENDIF.


*  ztext = v_filename. CONDENSE ztext.
*  CONCATENATE text-i12 ztext text-i13 INTO ztext SEPARATED BY space.
*  PERFORM sapgui_progress_indicator USING ztext.

  TRANSLATE gv_path TO LOWER CASE.

*  CONCATENATE gv_path gv_filename
*        INTO gv_filename.


  CONCATENATE 'cd' gv_path
          INTO gv_path SEPARATED BY space.


  CALL FUNCTION 'FTP_COMMAND'
    EXPORTING
      handle        = zhandle
      command       = gv_path
      compress      = 'N'
    TABLES
      data          = tbl_ftp_return
    EXCEPTIONS
      command_error = 1
      tcpip_error   = 2.

  CONCATENATE 'put' gv_filename
        INTO zftp_cmd SEPARATED BY space.


  CALL FUNCTION 'FTP_COMMAND'
    EXPORTING
      handle        = zhandle
      command       = zftp_cmd
      compress      = 'N'
    TABLES
      data          = tbl_ftp_return
    EXCEPTIONS
      command_error = 1
      tcpip_error   = 2.


  READ TABLE tbl_ftp_return INDEX 2.
  TRANSLATE tbl_ftp_return TO UPPER CASE.

  IF NOT tbl_ftp_return CS 'COMMAND SUCCESSFUL'.
    LOOP AT tbl_ftp_return.
      CONCATENATE zftp_err tbl_ftp_return-line
               INTO zftp_err SEPARATED BY space.
    ENDLOOP.
*    MESSAGE e116 DISPLAY LIKE 'E' WITH zftp_err.
*    p_ret = 4.
  ENDIF.

*  ztext = v_host. CONDENSE ztext.
*  CONCATENATE text-i07 ztext text-i11 INTO ztext SEPARATED BY space.
*  PERFORM sapgui_progress_indicator USING ztext.

  CALL FUNCTION 'FTP_DISCONNECT'
    EXPORTING
      handle = zhandle.

  CALL FUNCTION 'RFC_CONNECTION_CLOSE'
    EXPORTING
      destination = gv_rfc_dest
    EXCEPTIONS
      OTHERS      = 1.
  IF sy-subrc NE 0.
*    MESSAGE i118 DISPLAY LIKE 'E' WITH reg_ftp_data-rfc_dest.
    EXIT.
  ENDIF.

ENDFORM.                    " PROCESAR

Could you please help us to get the exact txt file after transfering it?

Thanks in advance.

2 REPLIES 2

Former Member
0 Kudos
42

Hi Demis,

Its a guess in my point of view i would have tried with REPLACE keyword.

Cheers!!

Balu

0 Kudos
42

Hi Balu, thanks for your answer, but I didn't understand at all.

You recommend using REPLACE instead of...??

Thanks!

Demis