“…neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit…”
¹

Campfire

We have come to the last part of the series. In this last chapter:

Story 5: Displaying an Unordered List

Now that we learned how to display sentences that start on new lines in the previous chapter, let’s use this for a scenario like displaying text with a bulleted list.

If you click Yes, the following steps will be performed:

  • Check incompleteness
  • Verify the data
  • Update the document
  • Log the errors

📄 ABAP code:

*--------------------------------------------------------------------*
* Anatomy of a Function Module: POPUP_TO_CONFIRM - Part 4
*
* Story 5: Displaying an Unordered List
*--------------------------------------------------------------------*

REPORT sy-repid.

CONSTANTS: newline VALUE cl_abap_char_utilities=>newline,
           maxlen  TYPE i VALUE 57.

DATA: question  TYPE string,
      answer(1).

question &&=:
  |If you click Yes, the following steps will be performed:| , newline,
  |• Check incompleteness|                                   , newline,
  |• Verify the data|                                        , newline,
  |• Update the document|                                    , newline,
  |• Log the errors|                                         , newline.

SPLIT question AT newline INTO TABLE DATA(segments).
CLEAR question.

LOOP AT segments ASSIGNING FIELD-SYMBOL(<segment>).
  DO COND #( WHEN strlen( <segment> ) EQ maxlen THEN 1 ELSE ( maxlen - strlen( <segment> ) ) ) TIMES.
    <segment> &&= | |.
  ENDDO.
  question &&= <segment>.
ENDLOOP.

question &&= newline.

CALL FUNCTION 'POPUP_TO_CONFIRM'
  EXPORTING
    text_question       = question
    userdefined_f1_help = '_' 
  IMPORTING
    answer              = answer
  EXCEPTIONS
    OTHERS              = 2.

🖥️ Output:

System 1: line-height: 1.75em

System 2: line-height: 34px

I activated the Info button to widen the popup in this example. If sentences fit 48 chars then you don’t need to.

⚠️ The only side effect of displaying the Info button by setting the parameter USER_DEFINED_F1_HELP with a value that doesn’t exist is that the following message is displayed when the user clicks that button.

No user-defined documentation available

↑ Top

Story 6: Displaying Longer Text Using a Document Object

I mentioned the document object ARBFND_DETAILED_LONGTEXT in the first part of this series. Now it’s time to use it.

⚠️ Please note that the document object may not be available on all systems.

First, let’s take a look at whether this object exists and what it contains. To do this, please follow the steps below.

  1. Launch transaction SE61.
  2. Choose Dialog Text in the Document Class field.
  3. Enter ARBFND_DETAILED_LONGTEXT in the Dialog Text input field.
  4. Click Display

Transaction SE61

Document content

As you can see the document object contains 70 placeholders. Every placeholder can contain 75 chars. We can populate these placeholders by populating the PARAMETER parameter.

Let’s try to display the text below:

Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? ¹

I will split the text into 75-char segments, then populate the parameter table. Finally, I will call the function with the DIAGNOSE_OBJECT parameter and the PARAMETER table.

ℹ️ We do not need to use the TEXT_QUESTION parameter in this story as we will display the long text using the above parameters. Actually, we shouldn’t because there is nothing to send with it.

📄 ABAP code:

*--------------------------------------------------------------------*
* Anatomy of a Function Module: POPUP_TO_CONFIRM - Part 4
*
* Story 6: Displaying Longer Text Using a Document Object
*--------------------------------------------------------------------*

REPORT sy-repid.

*--------------------------------------------------------------------*
* DATA
*--------------------------------------------------------------------*
CONSTANTS: number_of_placeholders   TYPE i VALUE 70,
           width_of_parameter_value TYPE i VALUE 75.

DATA: text   TYPE string,
      values TYPE TABLE OF spo_val,
      params TYPE TABLE OF spar,
      answer TYPE char1.

*--------------------------------------------------------------------*
* Build a long text.
*--------------------------------------------------------------------*
  text &&=:
    `Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium`,
    ` doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventor`,
    `e veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo en`,
    `im ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed `,
    `quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt,`,
    ` neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consect`,
    `etur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut l`,
    `abore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam`,
    `, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut a`,
    `liquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qu`,
    `i in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, `,
    `qui dolorem eum fugiat, quo voluptas nulla pariatur?`.

*--------------------------------------------------------------------*
* Split the text and fill the VALUES internal table.
*--------------------------------------------------------------------*
DATA(textlen) = strlen( text ).
DATA(to_be_copied) = 0.
DATA(copied) = 0. "75, 150, 225, ...

WHILE copied LT textlen.
  to_be_copied = COND #( WHEN copied + width_of_parameter_value LT textlen
                         THEN width_of_parameter_value
                         ELSE textlen - copied ).
  APPEND CONV spo_val( text+copied(to_be_copied) ) TO values.
  copied += to_be_copied.
ENDWHILE.

*--------------------------------------------------------------------*
* Fill the PARAMS internal table.
*--------------------------------------------------------------------*
DATA(number_of_used_placeholders) = lines( values ).
DATA(index_of_unused_placeholder) = 0.

* Move values to placeholders and add them to the PARAMS internal table.
* ARBFND_DETAILED_LONGTEXT has 70 placeholders (&VAR0000001&..&VAR0000070&).
LOOP AT values ASSIGNING FIELD-SYMBOL(<value>).
  APPEND VALUE spar( param = 'VAR' && CONV numc7( sy-tabix )
                     value = <value> ) TO params.
ENDLOOP.

* Set unused parameters (placeholders) to empty.
index_of_unused_placeholder = number_of_used_placeholders.
DO ( number_of_placeholders - number_of_used_placeholders ) TIMES.
  index_of_unused_placeholder += 1.
  APPEND VALUE spar( param = 'VAR' && CONV numc7( index_of_unused_placeholder )
                     value = space ) TO params.
ENDDO.

*--------------------------------------------------------------------*
* Call the function with the DIAGNOSE_OBJECT and the PARAMETER.
* Set the TEXT_QUESTION to space as we don't need it.
*--------------------------------------------------------------------*
CALL FUNCTION 'POPUP_TO_CONFIRM'
  EXPORTING
    diagnose_object     = 'ARBFND_DETAILED_LONGTEXT'
    text_question       = space
   "userdefined_f1_help = '.'
  IMPORTING
    answer              = answer
  TABLES
    parameter           = params
  EXCEPTIONS
    OTHERS              = 2.

🖥️ Output:

Without%20using%20USERDEFINED_F1_HELP

Without using USERDEFINED_F1_HELP parameter

Using%20USERDEFINED_F1_HELP

Using USERDEFINED_F1_HELP parameter

📄 Text displayed in the popup:

Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantiumdoloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sedquia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt,neque porro quisquam est, q etur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum,qui dolorem eum fugiat, qu

When we compare the text with the original version, we see the following changes:

Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?

⚠️ There are 2 problems with the output:

Problem Solution
When a segment’s last character is not a space, the last word of the segment and the first word of the next segment stick together because there are no spaces between the placeholders either. 🤦

E.g. accusantiumdoloremque

A custom document object can be created and a space inserted between placeholders to solve this problem.

Or we can try to transfer the first word that causes that “why we stick together” to the next placeholder.

After the function replaces the placeholders with values, there is another step that splits all the text into segments to populate the HTML tables later. (For more information on logic, please see the first chapter).

In this step, only 400 characters are transferred at a time in the text split loop. Let’s call this ‘block’. This logic causes words that exceed the limit not to be appended to the end of the block. And it continues to add the next segments. This causes data loss in every block of 400 characters.🤷

E.g. qui dolorem ipsum, quia dolor sit, amet, consectetur

The second problem requires analysis because there is something weird in the function.

For the analysis of this problem, you can take a look at the table below.

As you can see there, when the 400-character blocks filled by combining 75-character segments are completed, the last 25 characters are ignored each time.

# Value for Placeholder Len Block
1 Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium 75 1
2  doloremquelaudantium, totam rem aperiam eaque ipsa, quae ab illo inventor 74
3 e veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo en 75
4 im ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed 74
5 quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, 75
6  neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consect 75
7 etur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut l 75 2
8 abore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam 75
9 , quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut a 75
10 liquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qu 75
11 i in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, 75
12 qui dolorem eum fugiat, quo voluptas nulla pariatur? 52

🧮 Here is the general formula: 400 chars – ( 75 chars x 5 segments ) = 25 chars (to be omitted)

↑ Top

Conclusion

In this blog post, you have learned how to display text that contains bulleted lists and display longer text by using document objects.

However, there is no suitable document object that we can use to display dynamic long text. At least I couldn’t find any. Even if we can create a custom one, it looks like we need to write additional logic to control text manipulation.

Of course, this happens when we want to show text longer than 400 characters.

Next Step?

The campfire is still warm. A great opportunity for a good sleep. Or you can take a look at the RSSPO120 standard program for POPUP_TO_CONFIRM usage examples.

↑ Top

More Resources 

  • For more resources on ABAP development, you can visit the ABAP Development topic page here, ask a question, or follow the ABAP Development blog here.
  • Please follow Serkan Saglam for future posts and feel free to share your feedback or thoughts in a comment.
Endnotes 

  • ¹ Marcus Tullius Cicero, De Finibus Bonorum et Malorum, 45 BC, Liber Primus 1.10.32

Trademarks

  • SAP®, ABAP® are the trademarks or registered trademarks of SAP SE or its affiliates in Germany and in other countries.

Disclaimer

  • All source code available in this blog post is provided “as is” without warranty of any kind, and any use of such source code is at your own risk.

 

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x