Issue with concatenate. No blanks at the end. RESPECTING BLANKS not working fully.

Hello everyone,
i tried finding out the answer to this problem, but nothing helped. 
I wrote a program that is creating a .TXT file, and saving it to my local pc. 
The important part is that every row in the file MUST HAVE EXACTLY 60 characters. 
In every row there is 4 different data. 

This is the sample code from the program:

 

CONCATENATE ls_ed_broj-data1(4)
ls_ed_broj-data2(4)
ls_ed_broj-data3(25) space space
ls_ed_broj-data4(25) INTO ls_tab RESPECTING BLANKS.
APPEND ls_tab TO lt_tab.
ENDLOOP.
IF lt_tab[] IS NOT INITIAL.

p_file_o = ‘C:testinvTEST_file.txt’.

CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
FILENAME = p_file_o
TABLES
DATA_TAB = lt_tab
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ENDIF.

 

 

data1 and data2 should have 4 characters.
data3 and data 4 should have 25 characters. 

However it is not fixed how many of those characters are blanks.
The problem is that for some reason BLANKS from data4 are not written in the file. 

This is the example of what is being written in the file: 
NS      5005965911                 106000071120
NS      5005965922                 106000072220
NS      5005965933                 106000073320
NS      5005965944                 106000075520

And this is the example of what should be written in the file:

NS      5005965911                 106000071120             
NS      5005965922                 106000072220             
NS      5005965933                 106000073320             
NS      5005965944                 106000075520             

 

I am not sure if here (in the post) will be visible but there should be blanks at the end of every row until the row has 60 characters. Those blanks should be the remaining characters of data4 ( in this case 12 number and 13 blanks – that ration may vary ).
The blanks are respected for data1 data2 and data3, but for some reason they are not for data4. I guess that has to be something about concatenate function and the fact thats the last data.

Can someone help me resolve this issue.

Scroll to Top