Writing fixed length text files
This tip shows you how to write fixed length text files.
I hope my experience will save some time for some programmers who never experienced this scenario before.
When sending a fixed length text file with spaces at the end of the file;
Trailing blanks are truncated when writing in text mode.
To create fixed length records, use binary mode to write each record and append your own line break(CRLF-Hex ODOA).
File-type 'BIN' gives you the option of defining the file_size while using the ws_download function to download the file.
For an 80 character fixed length file, The internal table should be defined with the 2 extra one character type x fields.
data: begin of intab occurs 10, field1(01) type c, bkacct(03) type c, field3(02) type n, value '00', acount(10) type c , field5(01) type c value ' ', ttype(01) type c, indicator(01),( field8(01) type c, chect(10) type n , trwbtr(10), laufd(6) type c, znme1(20), filler(14) type c value ' '. cr(1) type x value '0D', lf(1) type x value '0A', end of intab. calling the function module with filetype bin with the specific file size. form download_filetab. * Check that data exists describe table intab lines sy-tfill. ws_size = sy-tfill * 82. call function 'WS_DOWNLOAD' exporting bin_filesize = ws_size filename = ws_file filetype = 'BIN' tables data_tab = intab exceptions file_open_error = 1 file_write_error = 2 invalid_filesize = 3 invalid_table_width = 4 invalid_type = 5 others = 6. Hope it helps!