Technical Articles
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
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).
DATA: LV_LEN TYPE I.
DATA: LV_OFF TYPE I.
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.
MOVE '*' TO IT_LINES-TDFORMAT.
MOVE P_TEXT+LV_OFF(53) TO IT_LINES-TDLINE.
SHIFT IT_LINES-TDLINE LEFT DELETING LEADING ‘ ‘.
LV_OFF = LV_OFF + 53.
APPEND IT_LINES.
CLEAR IT_LINES.
ENDDO.
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
Dear Jigang Zhang 张吉刚
Thank you very much for you post!. It was really helpful.
I think it might help me with an issue I am facing with an SO10 text in ADOBE. Let me briefly explain to you:
We have a long SO10 Text and we would like to adjust the text to the widht of the form.
Have found the following link FM for Splitting Paragraph into Fixed length | SAP Blogs but I have not
been totaly able to make it work.
Is there any way to "kind-of-easily" adjust the content of the text?.
It'd be just nice to have a sample code of it.
Kind Regards
Raul Daimiel
Maybe you can try like below to get the formatted long text by using attributes of the SO10 object. Then bind this long text as I mentioned at this blog.
Dear Jigang Zhang,
Thank you very much for your sample!!!. :).
I tested your suggestion and It worked 90 % perfectly fine for me.
The content was stored in a string variable... 🙁
But, by checking the IDMX_xxxx available FM's, I found the FM that would help me. 🙂
CALL FUNCTION 'IDMX_DI_SPLIT_TEXT'
EXPORTING
iv_character_chain = ld_string
IV_LENGTH = 95
IMPORTING
ET_STRING_TABLE = it_lines_adjusted
EXCEPTIONS
ERROR = 1
OTHERS = 2
The result is EXACTLY the one I expected!!!
Thank you very much!!!!!!!!.
Hi Jigang,
Thank you for the wonderful blog,I tried to use this functionality but formatting of text is gone once converted to string and downloaded in excel.
Any suggestions for that?
Jayvardhan Sharma
what kind of formatting? This blog is more about alignment, for text format like font, bold, or color which is rich text, it may not work.