Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform cuts spaces at the end of text from internal table

stepniake73
Explorer

Hi,

I have very long text, so i`m sending it into smartform in pieces in internal table.
In one case, at the end of the one part of text i have the space.
I do not know why, in smartform i do not see this space. I checked the data in itab, there is a space, i`m sure (i used

write: wa_opinie2-txt5 color 5, /.

and i see space on green background).

Ofcourse I used string as type of the text field.

Please, help! 🙂

17 REPLIES 17

Sandra_Rossi
Active Contributor
0 Kudos

How do you print this internal table, and what does it contain?

Sandra_Rossi
Active Contributor
0 Kudos

"print": I mean "print in the Smart Form".

raymond_giuseppi
Active Contributor

How did you print the text in Smartforms, did you use : LOOP, TEMPLATE or TABLE + TEXT (element or dynamic) nodes.

Also elaborate on 'I do not see this space.' are two texts concatenated?

stepniake73
Explorer
0 Kudos

I`m using loop.

Look pls at my other comment, there are also pics.

Sandra_Rossi
Active Contributor
0 Kudos

Please use the COMMENT button for comments, questions, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Sandra_Rossi
Active Contributor
0 Kudos

Could you provide an example: input value + screenshot of result

stepniake73
Explorer
0 Kudos

I don not know why, but i have a problem with attachements here, so...

Link to description of problem and information about my smartform

Sandra_Rossi
Active Contributor
0 Kudos

If I understand well, you mean that you complain about missing space between the variables, let's say txt1 ends with "hello" and txt2 begins with "world", you want to see "hello world", so why not adding a space between txt1 and txt2?

&wa_opinie2-txt1& &wa_opinie2-txt2& &wa_opinie2-txt3& &wa_opinie2-txt4& &wa_opinie2-txt5& &wa_opinie2-txt6&

stepniake73
Explorer
0 Kudos

No...

For example:

wa_opinie2-txt1 = 'this is txt with space at the end '.

wa_opinie2-txt2 = 'and this is next part of lo'.

wa_opinie2-txt3 = 'ng text'.

In smartform:

&wa_opinie2-txt1&&wa_opinie2-txt2&&wa_opinie2-txt3&

Effect:

this is txt with space at the endand this is next part of long text

As You can see, there is no space between "end" and "and" (lol...). And this is my problem.

I can not use:

&wa_opinie2-txt1& &wa_opinie2-txt2& &wa_opinie2-txt3&

because it will give me:

this is txt with space at the end and this is next part of lo ng text

I hope that there is clear now 😉

Sandra_Rossi
Active Contributor
0 Kudos

But, in your example, how do you decide that there is a space at the end of TXT1, but there is no space at the end of TXT2? Do you want to implement a "natural language understanding" system, or a split based on "dictionary words" (of a given human language) or is there another rule?

former_member598787
Participant
0 Kudos

Hello Emil,

You can try following Solution

  • you can try concatenating from txt1 to txt6 in a separate variable usingx:

concatenate txt1 txt2 .. txt6 into lv_string respecting blanks.

  • Then display the same in your smartform. Additionally , when displaying lv_string you can have a separate paragraph type for the string to handle spaces. ( you can find reference for that in the forum questions itself.

Hopefully, this works for you.

Regards,

Juby

stepniake73
Explorer
0 Kudos

Content of the txt1 and txt2 it is a typical text from database. I need to cut it into txt1, txt2 etc..., because smartform will not give me possibility to print it as a one, long text from itba/WA.

All i need, is write exacly what i have in txt1 and txt2. I do not decide about spaces at the end of txt1. When i cut long text into pieces 250 char long, sometimes there is a space at the end. And i need this space, because without it text does not have a sense during the assembly.

Sandra_Rossi
Active Contributor
0 Kudos

So, you say that TXT1, TXT2, etc. come from the database table, and are all CHAR 250, and a text spans over all these columns as a continuous text, so if there's a very long text up to TXT6, I guess that TXT1 to TXT5 all occupy 250 characters, with the 250th character being either a space character or a non-space character. Am I right?

Sandra_Rossi
Active Contributor
0 Kudos

(and if I am right, your example with very short TXT1 and TXT2 values don't reflect a real case)

stepniake73
Explorer
0 Kudos

Sandra: You are right, but in my pdf You can see example with text longer than 250 characters (look at example with disappeared space after „wynosi”).

roberto_forti
Contributor
0 Kudos

Hi Dear, I recommend implementing below ABAP code example.

Best Regards!

Roberto FORTI Santos

DATA: lt_pdf type standard table of tline,
      <lfs_w_pdf> type tline,
      lv_buffer   type string,
      lt_mess_att type standard table of solisti1,
      <lfs_attac> type solisti1,
      ls_doc_data type sodocchgi1,
      lv_cnt      type i.

     "Transfer the 132-long strings to 255-long strings
      loop at <lfs_t_pdf>[] assigning <lfs_w_pdf>.
        translate <lfs_w_pdf> using ' ~'.
        concatenate lv_buffer <lfs_w_pdf> into lv_buffer.
      endloop.
      translate lv_buffer using '~ '.

      do.
        append initial line to lt_mess_att[] assigning <lfs_attac>.
        if ( <lfs_attac> is assigned ).
          <lfs_attac> = lv_buffer.
          shift lv_buffer left by 255 places.
          if ( lv_buffer is initial ).
            exit.
          endif.
        endif.
      enddo.

      "Fill the document data and get size of attachment
      if ( <lfs_attac> is assigned ).
        ls_doc_data-doc_size = ( lv_cnt - 1 ) * 255 + strlen( <lfs_attac> ).
      endif.

"...

Sandra_Rossi
Active Contributor
0 Kudos

I guess the simplest way to solve is to define in the Smart Form a text of type "Dynamic text", i.e. filled with an internal table of type TSFTEXT or TLINE_TAB (same), which is a text in SAP "ITF" format, and use the function module CONVERT_STREAM_TO_ITF_TEXT to initialize it from a long text.

Here is an example with input and expected result.

Note that the STREAM_LINES parameter is an internal table which can be initialized with one line, and that you may fill with:

DATA(stream_line) = ||.
CONCATENATE txt1 txt2 ... txt6 INTO stream_line RESPECTING BLANKS.
DATA(stream_lines) = VALUE string_table( ( stream_line) ).
...

(RESPECTING BLANKS so that to not lose the trailing spaces).