Skip to Content
Technical Articles
Author's profile photo Jigang Zhang 张吉刚

Long text from Excel cell to SAP document to Adobe form cell

One Chinese proverb said: The faintest ink is more powerful than the strongest memory. Absolutely, sometimes I’m rush to google something and figure out one Issue without any kind of archive; then it turns out to be one fresh issue totally when it happens again.

In this article, I’ll wrap up the basic method from upload long text from a single cell of excel file to save as long text at SAP, then how to display this long text at one cell at the output in form of Adobe form.

1. From Excel Cell to SAP

First, need to upload long text from a single cell of excel file to SAP. (Forgive me I still haven’t started to use ABAP2XLSX in the production environment cause of some restrictions~.) I’m referring to this approach to achieve this by copy&modify based on Function Module: ALSM_EXCEL_TO_INTERNAL_TABLE which limitation is field ALSMEX_TABLINE-VALUE can only contain text from the cell up to 50 characters.

After extending this length with pure FM copy&modify is not working for me as it’ll missing some routine, so I copy& create a new function group ZALSMEX based on ALSMEX. And update the type definition as well at the top include program like LZALSMEXTOP to skip syntax error.

With updated FM we can accept long text from cells with more than 50 characters now. Then to deal with the inputted text at the cell as a large block of text in one paragraph, above mentioned article uses the method to get the length of the whole text first and then truncate it into several lines with a fixed length per line (here it uses 53).


LV_LEN = STRLEN( p_text ).  "total length
LV_LEN = LV_LEN / 53  + 1.  "Finding Number of Row’s taken by Long Text
    DO lv_LEN TIMES.
      LV_OFF = LV_OFF + 53.

This approach will force to switch new lines per 53 characters but it didn’t consider original word wrap& line breaks. Still not perfect~

Using split into a table at separator like cl_abap_char_utilities=>newline will not generate table TLINE perfectly as well, cause can’t make sure contents will contain that kind of separators. Another FM VB_CP_CONVERT_STRING_2_ITF will deal with this perfectly! Just convert the text get from cell to string type as its input then you will get TLINE table lines like below alignment. Save the long text using the TLINE table by FM: ‘READ_TEXT’.

2. From SAP long text to the cell of Adobe form

When want to display the long text get from SAP text editor at single-cell of the line in adobe form, we have to convert TLINE contents back to a string with alignment as well.

After getting TLINE with FM: ‘READ_TEXT’ just use FM: IDMX_DI_TLINE_INTO_STRING to convert TLINE back to a string will do. Besides, few things need to check:

  • Tick the checkbox the “allowed Multiple lines” for the cell

  • Tick the checkbox ‘Expand to fit’ for all the fields that share the same line with this specific cell
  • Then no matter what’s the column length of the cell, you will get aligned long text at single-cell of the main item.

Assigned tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.