2014 Apr 11 11:03 AM
The code that I've written passes data to TEMSE_SCHREIBEN and the file is then downloaded using transaction FDTA.
You can't pass a variable string to TEMSE_SCHREIBEN, it has to be CHAR(255). As a result we have trailing spaces after our data. This has become a huge problem as no-one has been able to come up with a solution. Originally I thought I could modify the buffer table itself to replace all hex 0020s with 0000. Unfortunately it seems that the trailing spaces are all stored as 0000 (Null) and that for some reason they're converted when downloaded. Currently the code I've been attempting to use does the following.
LOOP AT itab_string. | |
CALL FUNCTION 'SRET_TEXT_TO_BINARY' | |
EXPORTING | |
TEXT | = itab_string-file_data |
LAISO = '00' | |
IMPORTING | |
XBUFFER = c_string. |
REPLACE ALL OCCURRENCES OF c_space IN c_string WITH c_null IN BYTE MODE. |
CALL FUNCTION 'SRET_BINARY_TO_TEXT' |
EXPORTING |
XBUFFER = c_string |
LAISO = '00' |
IMPORTING |
TEXTBUFFER = itab_string-file_data. |
PERFORM temse_schreiben USING itab_string. |
ENDLOOP. |
This of course, is not working because the trailing hex is already 0000. Any ideas?
2014 Apr 29 10:31 AM
Well, I finally got it working properly after struggling with the damn thing forever.
The idea was to dynamically create the character field being passed to TEMSE_SCHREIBEN from the length of the string.
Here's the code snippet.
FIELD-SYMBOLS <cdata> TYPE ANY.
DATA: l_len TYPE NUM03,
r_cdata TYPE REF TO DATA.
LOOP AT itab_string.
lv_string = itab_string-file_data.
SHIFT lv_string RIGHT deleting TRAILING space.
SHIFT lv_string LEFT deleting LEADING space.
CONCATENATE lv_string lv_cr lv_lf INTO lv_string.
l_len = STRLEN( lv_string ).
CREATE DATA r_cdata TYPE c LENGTH l_len.
ASSIGN r_cdata->* TO <cdata>.
<cdata> = lv_string.
PERFORM temse_schreiben USING <cdata>.
ENDLOOP.
So glad that's finally over.
2014 Apr 29 10:31 AM
Well, I finally got it working properly after struggling with the damn thing forever.
The idea was to dynamically create the character field being passed to TEMSE_SCHREIBEN from the length of the string.
Here's the code snippet.
FIELD-SYMBOLS <cdata> TYPE ANY.
DATA: l_len TYPE NUM03,
r_cdata TYPE REF TO DATA.
LOOP AT itab_string.
lv_string = itab_string-file_data.
SHIFT lv_string RIGHT deleting TRAILING space.
SHIFT lv_string LEFT deleting LEADING space.
CONCATENATE lv_string lv_cr lv_lf INTO lv_string.
l_len = STRLEN( lv_string ).
CREATE DATA r_cdata TYPE c LENGTH l_len.
ASSIGN r_cdata->* TO <cdata>.
<cdata> = lv_string.
PERFORM temse_schreiben USING <cdata>.
ENDLOOP.
So glad that's finally over.