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: 

How to add 40 SPACES as suffix to last field in the downloaded text file?

Former Member
0 Kudos

Hi Experts,

I need to add a 40 spaces end of each record in a downloaded text file.

But i'm not able to achieve these spaces end of each record.

Thanks.

Regards

Balaji

6 REPLIES 6

piyush_mathur
Active Participant
0 Kudos

DATA : A(1).

DO 40 TIMES.

CONCATENATE A SPACE INTO A.

ENDDO.

Now Concatenate A in your last record.

Thanks

Piyush

former_member212653
Active Contributor
0 Kudos

try this:


data  v_space type string,
  data:
"Local variable for a single SPACE
    l_v_char type string.
  clear v_space.

" Calling this metode a space is assigned to L_V_CHAR
  call method cl_abap_char_utilities=>get_simple_spaces_for_cur_cp
    receiving
      s_str = l_v_char.

" Populating the variable for spaces
  do 40 times.
    concatenate l_v_char+0(1) v_space into v_space.
  enddo.
" now v_space will have 40 spaces

Edited by: Sourav Bhaduri on Oct 4, 2008 5:10 PM

0 Kudos

Hi,

I have the same problem. But i dont have below below class in the 4.6c. Can you please advice how can we do in 4.6c. I tried with concatenate but it didn't work out. please advice.

Thanks in advance

0 Kudos

Check out this code...hope this will work on 4.6C


PARAMETERS: p_file TYPE rlgrap-filename
      default 'C:\Documents and Settings\Sourav\Desktop\test63.txt'.

DATA: BEGIN OF s_data,
        data TYPE char10,
        dummy(40) TYPE c,
        cr_lf(2) TYPE x VALUE '09',
      END OF s_data.

DATA: t_data LIKE TABLE OF s_data.

s_data-data = 'Test'.APPEND s_data TO t_data.
s_data-data = 'Test2'.APPEND s_data TO t_data.
s_data-data = 'Test3'.APPEND s_data TO t_data.
s_data-data = 'Test4'.APPEND s_data TO t_data.

* Download.
DATA: v_file TYPE string.
v_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename                = v_file
  TABLES
    data_tab                = t_data
  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
    OTHERS                  = 22.

Edited by: Sourav Bhaduri on Oct 5, 2008 3:51 PM

Former Member
0 Kudos

Thanks for the reply sourav. But your code prints the value 0900. I dont want this value at the end of the line, i required blank spaces at the end of line while sending to the file on application server.

Regards

syed samdani

Former Member
0 Kudos

Hi All

We solved the the problem by

Declaring a varaible of type X with a value of '/OD' and concatenate at the end of each line.

Thanks for your support.

Balaji R