Application Development and Automation 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: 
Read only

SCMS_BINARY_TO_TEXT with trailing spaces

Hariom98
Discoverer
0 Likes
1,078

Hello team , 

My requirement is to use an enhancement to send DME file from SAP to FTP server.

I get the data in format   tab_x1   TYPE STANDARD TABLE OF x_linetype1.

When I try to download in desktop using below , I get correct out put and with proper trailing spaces and format.

CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      bin_filesize         filesize
      filename             filename_string
      filetype             'BIN'
      NO_AUTH_CHECK        'X'
    IMPORTING
      filelength           after_download_length
    CHANGING
      data_tab             tab_x
    EXCEPTIONS
      file_not_found       91
      file_write_error     92
      filesize_not_allowed 93
      invalid_type         95
      no_batch             96
      OTHERS               97.
  hlp_file_exit filename.  

My requirement is to share the same file to FTP . In order to do this , I have to convert the file data tab_x1 into readable format using FM 'SCMS_BINARY_TO_TEXT'

TYPESBEGIN OF ty_cont,
             line TYPE bapiascont,
           END OF ty_cont,

DATA : lt_cont type table of ty_cont

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
        EXPORTING
          input_length = lv_inlen
        TABLES
          binary_tab   = tab_x1
          text_tab     = lt_cont
        EXCEPTIONS
          failed       = 1
          OTHERS       2.

 

After which data is passed to FTP FM  FTP_R3_TO_SERVER 

CALL FUNCTION 'FTP_R3_TO_SERVER'
          EXPORTING
            handle         = lv_hdl
            fname          = lv_path
            character_mode = 'C'
          TABLES
            text           = lt_cont
          EXCEPTIONS
            tcpip_error    = 1
            command_error  = 2
            data_error     = 3
            OTHERS         4.
        IF sy-subrc <> 0.  

       ENDIF.

After this I get the file my folder . But my trailing spaces are not reflected. Can anyone please help me and suggest a how to keep the trailing spaces .

 

Hello team , 

My requirement is to use an enhancement to send DME file from SAP to FTP server.

I get the data in format   tab_x1   TYPE STANDARD TABLE OF x_linetype1.

When I try to download in desktop using below , I get correct out put and with proper trailing spaces and format.

CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      bin_filesize         filesize
      filename             filename_string
      filetype             'BIN'
      NO_AUTH_CHECK        'X'
    IMPORTING
      filelength           after_download_length
    CHANGING
      data_tab             tab_x
    EXCEPTIONS
      file_not_found       91
      file_write_error     92
      filesize_not_allowed 93
      invalid_type         95
      no_batch             96
      OTHERS               97.
  hlp_file_exit filename.  

My requirement is to share the same file to FTP . In order to do this , I have to convert the file data tab_x1 into readable format using FM 'SCMS_BINARY_TO_TEXT'

TYPESBEGIN OF ty_cont,
             line TYPE bapiascont,
           END OF ty_cont,

DATA : lt_cont type table of ty_cont

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
        EXPORTING
          input_length = lv_inlen
        TABLES
          binary_tab   = tab_x1
          text_tab     = lt_cont
        EXCEPTIONS
          failed       = 1
          OTHERS       2.

 

After which data is passed to FTP FM  FTP_R3_TO_SERVER 

CALL FUNCTION 'FTP_R3_TO_SERVER'
          EXPORTING
            handle         = lv_hdl
            fname          = lv_path
            character_mode = 'C'
          TABLES
            text           = lt_cont
          EXCEPTIONS
            tcpip_error    = 1
            command_error  = 2
            data_error     = 3
            OTHERS         4.
        IF sy-subrc <> 0.  

       ENDIF.

After this I get the file my folder . But my trailing spaces are not reflected. Can anyone please help me and suggest a how to keep the trailing spaces .

 

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,031

If you want to keep the trailing spaces, do the FTP in binary, not in character (CHARACTER_MODE = space).

Read only

0 Likes
1,004

Hello Rossi , 

Can you please share any code reference. If I pass character_mode  = space. 

I am not getting any data in the text file.

Regards, 

Hariom