on 07-07-2014 5:33 PM
Hello Experts,
My requirement is to print a text in Text Object in a smartform. I've created a text object using CREATE_TEXT. Here is how it looks like.
*<H>Ancillary Fees</>
*All rates and ancillary fees will be charged in accordance with
OCS published rates and fees in effect from time to time unless
otherwise specifically quoted in this Agreement. The below listing displays
only discounted surcharges and does not display a complete list of surcharges offered.
I read the above text using READ_TEXT function module and save it in an internal table which has TDFORMAT(char2) and TDLINE(char132) columns.
For reference here is the code.
***************************************************************************************************
* build 132 char lines of text:
loop at wa_text-text_lines assigning <tline>.
if <tline>-tdformat is initial.
split <tline>-tdline at space into table lt_words.
loop at lt_words into l_word.
l_max_len = strlen( l_line-tdline ) + strlen( l_word ) + 1.
if l_max_len <= 132.
concatenate l_line-tdline l_word into l_line-tdline
separated by space.
else.
append l_line to lt_lines.
clear l_line.
l_line-tdline = l_word.
endif.
endloop.
else.
* start new paragraph
if l_line is not initial.
append l_line to lt_lines.
endif.
l_line = <tline>.
l_line-tdformat = 'P6'. "paragraph format in the smart form
endif.
endloop.
if l_line is not initial.
append l_line to lt_lines.
endif.
wa_text-text_type = p_id.
wa_text-text_lines[] = lt_lines[].
append wa_text to p_txtab.
***************************************************************************************************
In the above internal table p_txtab-tdline I can see the text exactly as I've mentioned above. Yet when it prints in smartform two words of last line (a complete) becomes one word (acomplete).
Here is the text object setting which I use to display this text.
Can anybody see what is the issue here and how to rectify it, please?
Many thanks in advance.
Hi,
I'd think: "not cool" if I'd find this particular code in our system. Is there any reason the code creating texts can't save them in the "right format", with all the right paragraph formats, etc. so that the text does not need to be "reformated" before printing..? READ_TEXT already delivers the text in TLINE table format...
To the actual problem: could you show how the wa_text-text_lines[] of the problematic text look like in the debugger?
cheers
Janis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thank you. I'm not trying to be irritating... but are you 100% positive there is a space at the end of line 3..? Because:
unless-otherwise-specifically-quoted-in-this-Agreement.-The-below-
123456789012345678901234567890123456789012345678901234567890123456
listing-displays-only-discounted-surcharges-and-does-not-display-a
789012345678901234567890123456789012345678901234567890123456789012
is exactly 132 bytes long... and I can't see the logic adding the space after the last word of the line. What I can't figure out is, if that is the problem, how come "time unless" stays separated..?
Regardless, I'd try to code it as follows:
...
l_max_len = strlen( l_line-tdline ) + strlen( l_word ) + 2.
if l_max_len <= 132.
concatenate l_line-tdline l_word into l_line-tdline
separated by space.
else.
l_line-tdline = l_line-tdline && space.
append l_line to lt_lines.
clear l_line.
l_line-tdline = l_word.
endif.
....
Meaning, there must be enough place for the word and a space character before and after the word, in order to concatenate into same line. I'd also put the paragraph '=' in the lines that have no paragraph formats, but I think that that is not absolutely necessary.
cheers
Jānis
Edit in: no, adding the space explicitly in the "else" is just stupid, those aren't strings
Message was edited by: Jānis B
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.