cancel
Showing results for 
Search instead for 
Did you mean: 

Text object doesn't print correctly in Smartform

former_member295881
Contributor
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Private_Member_7726
Active Contributor
0 Kudos

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

former_member295881
Contributor
0 Kudos

Thanks for your input Janis, Here is how wa_text-text_lines looks like.

And here is how it displays in the smartform.

Any clue what is the issue here ?

Private_Member_7726
Active Contributor
0 Kudos

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

former_member295881
Contributor
0 Kudos

Many thanks Janis, I replace + 1 with + 2 as you've suggested and it resolved the issue and here is how it look.

Answers (0)