
A skunk sat on a stump. The skunk thunk the stump stunk and the stump thunk the skunk stunk.
the skunk
1. Ahead of the CONCATENATE LINES OF statement, insert the following set of lines (first and last lines, shown preceding and succeeding a comment line of all hyphens, already exist in the code as lines 216 and 217, respectively):
216 APPEND '<html><body><font face="Arial monospaced for ...
" -----------------------------------
" DEMO_REGEX_TOY enhancement #4
" Format result text using approximate window width
" specified by line_len:
constants : html_space type string value ' '
, html_special_character_start
type string value '&'
, html_special_character_end
type string value ';'
, html_format_start
type string value '<'
, html_format_end
type string value '>'
.
data : visible_text_length
type int4
, html_last_space_length
type int4
, cause_line_break
type flag
, html_string type string
, html_excess type string
, html_stack type standard table
of string
.
loop at result_it
into result_wa.
clear: html_string, visible_text_length.
while strlen( result_wa ) gt 00.
case result_wa+00(01).
when html_format_start.
while result_wa+00(01) ne html_format_end.
concatenate html_string
result_wa+00(01)
into html_string.
shift result_wa left by 01 places.
endwhile.
when html_special_character_start.
if strlen( result_wa ) ge 06.
if result_wa+00(06) eq html_space.
if visible_text_length gt line_len.
cause_line_break = abap_true.
endif.
endif.
endif.
while result_wa+00(01) ne
html_special_character_end.
concatenate html_string
result_wa+00(01)
into html_string.
shift result_wa left by 01 places.
endwhile.
add 01 to visible_text_length.
if cause_line_break eq abap_false.
html_last_space_length
= strlen( html_string ) + 01.
endif.
when others.
add 01 to visible_text_length.
endcase.
concatenate html_string
result_wa+00(01)
into html_string.
shift result_wa left by 01 places.
if cause_line_break eq abap_true.
clear html_excess.
if html_last_space_length gt 00.
html_excess =
substring( val = html_string
off = html_last_space_length ).
html_string =
substring( val = html_string
len = html_last_space_length ).
endif.
append html_string
to html_stack.
clear: html_string, html_last_space_length.
visible_text_length = strlen( html_string ).
cause_line_break = abap_false.
if strlen( html_excess ) gt 00.
concatenate html_excess
result_wa
into result_wa.
endif.
endif.
endwhile.
append html_string
to html_stack.
endloop.
" -----------------------------------
217 CONCATENATE LINES OF result_it INTO result_wa ...
2. Then change the CONCATENATE LINES OF statement from
CONCATENATE LINES OF result_it INTO result_wa …
to
CONCATENATE LINES OF html_stack INTO result_wa …
A skunk sat on a stump. The skunk thunk the stump stunk and the stump thunk the skunk stunk.
the skunk
A
skunk
sat
on
a
stump.
such that each word is followed by an explicit line break placing it on its own line as shown above.
Note: The dot character is the wildcard character applicable to regular expression patterns, indicating to match any character at that position in the text, providing the same functionality to regular expressions that the ‘+’ wildcard character provides with patterns specified for ranges and select-options statements in SAP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
2 |