<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Formatting a String into Readable Text in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444675#M1648933</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have searched for an FM or code snippet that will help me do this but no luck so far so hopefully you can help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the READ_TEXT FM to bring back in a table of 175 entries with a max of 132 length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to output this table onto a form which has a max length of 255 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example is probably best.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I receive:&lt;/P&gt;&lt;P&gt;STANDARD CONDITIONS FOR THE PURCHASE OF GOODS AND/OR SERVICES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 Definitions&lt;/P&gt;&lt;P&gt;u201CThe Companyu201D the company trading as XXXXX XXXXX XXX or any of its&lt;/P&gt;&lt;P&gt;subsidiary companies described as the purchaser in the Contract;&lt;/P&gt;&lt;P&gt;u201CContractu201D means any contract agreed by the parties for the supply of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And want to output:&lt;/P&gt;&lt;P&gt;STANDARD CONDITIONS FOR THE PURCHASE OF GOODS AND/OR SERVICES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 Definitions&lt;/P&gt;&lt;P&gt;u201CThe Companyu201D the company trading as XXXXX XXXXX XXX or any of its subsidiary companies described as the purchaser in the Contract;&lt;/P&gt;&lt;P&gt;u201CContractu201D means any contract agreed by the parties for the supply of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this makes sense? I want to use the maximum amount 255 characters possible to me without splitting words in half. Any advice greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jan 2012 17:54:15 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-01-16T17:54:15Z</dc:date>
    <item>
      <title>Formatting a String into Readable Text</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444675#M1648933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have searched for an FM or code snippet that will help me do this but no luck so far so hopefully you can help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the READ_TEXT FM to bring back in a table of 175 entries with a max of 132 length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to output this table onto a form which has a max length of 255 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example is probably best.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I receive:&lt;/P&gt;&lt;P&gt;STANDARD CONDITIONS FOR THE PURCHASE OF GOODS AND/OR SERVICES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 Definitions&lt;/P&gt;&lt;P&gt;u201CThe Companyu201D the company trading as XXXXX XXXXX XXX or any of its&lt;/P&gt;&lt;P&gt;subsidiary companies described as the purchaser in the Contract;&lt;/P&gt;&lt;P&gt;u201CContractu201D means any contract agreed by the parties for the supply of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And want to output:&lt;/P&gt;&lt;P&gt;STANDARD CONDITIONS FOR THE PURCHASE OF GOODS AND/OR SERVICES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 Definitions&lt;/P&gt;&lt;P&gt;u201CThe Companyu201D the company trading as XXXXX XXXXX XXX or any of its subsidiary companies described as the purchaser in the Contract;&lt;/P&gt;&lt;P&gt;u201CContractu201D means any contract agreed by the parties for the supply of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this makes sense? I want to use the maximum amount 255 characters possible to me without splitting words in half. Any advice greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2012 17:54:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444675#M1648933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-16T17:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a String into Readable Text</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444676#M1648934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try to use format_textlines or rkd_word_wrap..search sdn you will find many fm for your requirement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nabheet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2012 18:23:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444676#M1648934</guid>
      <dc:creator>nabheetscn</dc:creator>
      <dc:date>2012-01-16T18:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a String into Readable Text</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444677#M1648935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __jive_macro_name="thread" id="439306"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;this thread talks about the same thing with the opposite requirement, check it out&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check out the last 3-4 posts of this thread..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2012 18:36:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444677#M1648935</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-16T18:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a String into Readable Text</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444678#M1648936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please find below sample code which hopefully somone may find useful, &lt;STRONG&gt;but please note, I had to implement note 1407684 for this to work even though we are on version 701&lt;/STRONG&gt;. Many Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CONSTANTS: lc_readid TYPE thead-tdid VALUE 'ST',
           lc_readobj TYPE thead-tdobject VALUE 'TEXT'.

TYPES: BEGIN OF ty_formatted_text,
                  line(255),
       END OF ty_formatted_text.

DATA: lv_readname TYPE thead-tdname,
      lv_langutxt TYPE sy-langu,
      lt_line TYPE TABLE OF tline,
      ls_line TYPE tline,
      lt_line_ahead TYPE TABLE OF tline,
      ls_line_ahead TYPE tline,
      lv_tabix TYPE sy-tabix,
      ls_termsandcond_text TYPE soli,
      lt_termsandcond_text TYPE soli_tab,
      lv_textline(1024),
      lt_formatted_text TYPE TABLE OF ty_formatted_text,
      ls_formatted_text TYPE ty_formatted_text.

lv_langutxt = sy-langu.

CONCATENATE 'ZPOTERMSCONDITIONS_' 'P002' INTO lv_readname.

CLEAR: lt_line[], ls_line.
CALL FUNCTION 'READ_TEXT'
  EXPORTING
    id                      = lc_readid
    language                = lv_langutxt
    name                    = lv_readname
    object                  = lc_readobj
  TABLES
    lines                   = lt_line
  EXCEPTIONS
    id                      = 1
    language                = 2
    name                    = 3
    not_found               = 4
    object                  = 5
    reference_check         = 6
    wrong_access_to_archive = 7
    OTHERS                  = 8.

lt_line_ahead[] = lt_line[].

LOOP AT lt_line INTO ls_line.
  "Read Next Line to Check if its a new paragraph
  lv_tabix = sy-tabix + 1.
  CLEAR ls_line_ahead.
  READ TABLE lt_line_ahead INTO ls_line_ahead INDEX lv_tabix.

  "New Paragraph or end of text
  IF ls_line_ahead-tdformat = '*' OR sy-subrc = 4.
    IF lv_textline IS INITIAL. "Current line is the start of a paragraph
      ls_termsandcond_text-line = ls_line-tdline.
      APPEND ls_termsandcond_text TO lt_termsandcond_text.
    ELSE. "Some text had been built up
      CONCATENATE lv_textline ls_line-tdline INTO lv_textline SEPARATED BY space.
      REFRESH lt_formatted_text. CLEAR ls_formatted_text.
      CALL FUNCTION 'RKD_WORD_WRAP'
        EXPORTING
          textline            = lv_textline
          outputlen           = 255
        TABLES
          out_lines           = lt_formatted_text
        EXCEPTIONS
          outputlen_too_large = 1
          OTHERS              = 2.

      CLEAR lv_textline.
      IF sy-subrc &amp;lt;&amp;gt; 0.
        "I don't want to trigger an error
      ELSE.
        "Loop on the formatted table and populate my output table
        LOOP AT lt_formatted_text INTO ls_formatted_text.
          CLEAR ls_termsandcond_text.
          ls_termsandcond_text-line = ls_formatted_text-line.
          APPEND ls_termsandcond_text TO lt_termsandcond_text.
        ENDLOOP.
      ENDIF.
    ENDIF.
  ELSE. "The next line is not a new paragraph so build text string
    CONCATENATE lv_textline ls_line-tdline INTO lv_textline SEPARATED BY space.
  ENDIF.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 10:43:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/formatting-a-string-into-readable-text/m-p/8444678#M1648936</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-17T10:43:09Z</dc:date>
    </item>
  </channel>
</rss>

