‎2012 Jan 16 5:54 PM
Folks,
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.
I am using the READ_TEXT FM to bring back in a table of 175 entries with a max of 132 length.
I want to output this table onto a form which has a max length of 255 characters.
An example is probably best.
I receive:
STANDARD CONDITIONS FOR THE PURCHASE OF GOODS AND/OR SERVICES
1 Definitions
u201CThe Companyu201D the company trading as XXXXX XXXXX XXX or any of its
subsidiary companies described as the purchaser in the Contract;
u201CContractu201D means any contract agreed by the parties for the supply of
And want to output:
STANDARD CONDITIONS FOR THE PURCHASE OF GOODS AND/OR SERVICES
1 Definitions
u201CThe Companyu201D the company trading as XXXXX XXXXX XXX or any of its subsidiary companies described as the purchaser in the Contract;
u201CContractu201D means any contract agreed by the parties for the supply of
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.
‎2012 Jan 16 6:23 PM
Try to use format_textlines or rkd_word_wrap..search sdn you will find many fm for your requirement
Nabheet
‎2012 Jan 16 6:23 PM
Try to use format_textlines or rkd_word_wrap..search sdn you will find many fm for your requirement
Nabheet
‎2012 Jan 17 10:43 AM
Thanks Guys,
Please find below sample code which hopefully somone may find useful, but please note, I had to implement note 1407684 for this to work even though we are on version 701. Many Thanks.
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 <> 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.
‎2012 Jan 16 6:36 PM
this thread talks about the same thing with the opposite requirement, check it out
check out the last 3-4 posts of this thread..