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.
Showing results for 
Search instead for 
Did you mean: 

How to insert blank spaces at end of a record

Former Member
0 Kudos

Hi All,

i need to write 10 records each of 80 char size. of these 10 records, each record might have different data and the last field will be a filler field which only has space.

for example:

DATA : BEGIN OF gs_mrecord ,

id(1) VALUE'M' ,

accno(12) ,

refid(2) VALUE 'RR' ,

sec_cd(4) VALUE '2437' ,

sub_typ(1) VALUE '6' ,

sub_dt(5) ,

sub_seq_no(1) ,

sec_cd1(4) VALUE '2437' ,

sub_dt1(6) ,

record_no(6) TYPE n ,

ext_ind(1) ,

plat_id(1) ,

filler_1(1) ,

clear_code(3) ,

ex_merc_no(16) ,

filler_4(4) , fill blank spaces

mech_bin_no(6) ,

filler(6) , " fill blank spaces

END OF gs_mrecord .

like this there are 10 types with 80 char size, however the last field is a filler, in which we need to fill only blank spaces.

when i wrtie this data to the application server file i can't see the spaces and when download(to .TXT file) also i can't see the spaces.

is there anyway that i can keep the spaces at the end of the record.

Please note, in the middle of the record, we can keep the spaces as there is some data after that.

Any hint would be of great help.




Active Contributor
0 Kudos

hi Srinivas Reddy

I guess you are doing this because the line is not braking up.... if you are doing for this concatenate

data: lv_feed type X value '/OD'.

at the end of each row.


if you want space always in that, in the deceleration.. say

filler(6) value ' '.


Hope this is helpful..

Former Member
0 Kudos


Try using the addition LENGTH with Transfer command.


> TRANSFER <wa> TO <dsn> LENGTH 80.



0 Kudos

Hi Eswar,

The LENGTH specification is not helping, i tried using NO END OF LINE, then the second line is getting started from 81st position, which i don't want. all records(each with 80 char length) should be started with new line.

Declaring the filler field with value ' ' specification also does not help as the blank spaces are being cut off.

in the SAP libary i read that if we open the file in TEXT mode, it cuts off the trailing spaces.

and if i use BINARY mode everything comes in single line.

in classical report the spaces are shown but in the application server file these are not shown.



0 Kudos

Hi Srinivas

Just a thought, try as below:

Declare a text variable of length 80 characters. Before transferring the record to Output file, move the work area to the text field and add a New Line character at 80th position. Now tranfer this text field to file with length specification.


DATA: l_cr(1) TYPE c VALUE cl_abap_char_utilities=>cr_lf,
      l_text(80) TYPE c.

IF sy-subrc EQ 0.
   LOOP AT <itab> INTO <wa>.
      MOVE <wa> TO l_text.
      l_text+80 = l_cr.
      TRANSFER l_text TO <dsn>.

Hope that helps, also check the codepage in which you download the file from Application server before Viewing. Maybe checking the file contents via AL11.

Hope it helps.



0 Kudos

Hi Eswar,

Many thanks for the inputs. However the issue was simple. when we download the application server file to local system(desktop) it converts the file to Windows format and deletes all the spaces.

so in my system SAP is on Unix and desktop is Windows, so when i was downloading the file from Unix, it was getting converted to DOS file format and the spaces were getting deleted.

If we view the file directly from the application server file without converting we can see the spaces.

And even LENGTH specificaiton will be over written when the file is getting converted.



0 Kudos


Can someone please tell me how were they able to insert spaces in the middle of two data fields?