Thursday, 29 April 2021 15:22

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

Written by Jigang Zhang 张吉刚
Rate this item
(0 votes)
Source https://blogs.sap.com/2021/04/30/long-text-from-excel-cell-to-sap-document-to-adobe-form-cell/
“© 2020. SAP SE or an SAP affiliate company. All rights reserved.” “Used with permission of SAP SE”

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).

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.

Continue reading here
Read 51 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.