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: 

store long string in a file in presentation server

Former Member
0 Kudos

hi experts,

I need some help, I need to store a very long string in a file on the presentation server, the string length

can reach 5000 chars and I need to write it in one line.

it is easy to write such string to a file in the application server, but to write it to a file in the presentation server,

I tried converting the string into an internal table and then called a function to store the itab but the problem

is that the string will not be in one line. I need to have it in one line !

<removed_by_moderator>

Thanks !

Edited by: Julius Bussche on Jan 22, 2009 11:54 PM

1 ACCEPTED SOLUTION

martin_voros
Active Contributor
0 Kudos

Hi,

why don't you use a table of strings?


DATA: gt_tab TYPE STANDARD TABLE OF string,
      g_string TYPE string.

START-OF-SELECTION.

  g_string = 'test'.
  APPEND g_string TO gt_tab.

  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      filename                = 'C:/test.txt'
    CHANGING
      data_tab                = gt_tab
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      not_supported_by_gui    = 22
      error_no_gui            = 23
      OTHERS                  = 24.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

3 REPLIES 3

martin_voros
Active Contributor
0 Kudos

Hi,

why don't you use a table of strings?


DATA: gt_tab TYPE STANDARD TABLE OF string,
      g_string TYPE string.

START-OF-SELECTION.

  g_string = 'test'.
  APPEND g_string TO gt_tab.

  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      filename                = 'C:/test.txt'
    CHANGING
      data_tab                = gt_tab
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      not_supported_by_gui    = 22
      error_no_gui            = 23
      OTHERS                  = 24.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

0 Kudos

Thanks Martin for the help, your solution worked.

Former Member
0 Kudos

Hi Misbah.

try this

data: v_txt5000(5000) TYPE c.

data: it_data LIKE v_txt5000 OCCURS 0.

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = "C:\text.txt"

filetype = 'DAT'

  • HAS_FIELD_SEPARATOR = 'X'

CHANGING

data_tab = it_data

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

not_supported_by_gui = 17

error_no_gui = 18

OTHERS = 19.

IF sy-subrc NE 0.

ENDIF.

Write the text file to server

file = "/server/path/".

OPEN DATASET file FOR OUTPUT IN TEXT MODE

ENCODING DEFAULT

WITH SMART LINEFEED.

LOOP AT it_data.

TRANSFER it_data TO file.

END LOOP.

CLOSE DATASET file.

Hope it helps.

Sayan.