Long text from Excel cell to SAP document to Adobe form cell
source link: https://blogs.sap.com/2021/04/30/long-text-from-excel-cell-to-sap-document-to-adobe-form-cell/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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. 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.
Recommend
-
6
Categories ProgrammingChange an Excel Cell’s Colour Based on DataThis might be a bit niche, but I needed to collect RGB val...
-
12
Hands-On With Adobe Document Generation API Adobe Document...
-
10
Merging Data with Documents Using Adobe Document Generation APIWhen you think of Adobe, you might think of Adobe Acrobat on your computer for creating PDFs. However, Adobe h...
-
2
Adobe PDF Embed API Free JavaScript API to embed high-fidelity PDFs, enable collaboration, and see analytics Try the demo
-
8
...
-
9
Excel 2011 Can not Execute a Function in Cell advertisements I am using MAC 2011 Excel (version 14.4.2) When I...
-
5
Creating Your Own Schema With the Adobe Document Generation Word Add-in ...
-
6
3 Ways to Highlight a Cell or Row With a Checkbox in Excel By Zainab Falak Published 6 hours ago Want to highl...
-
2
Introduction When doing analysis with Jupyter Notebooks, you will frequently...
-
3
In this article I will show you how to clear formatting from a cell in Excel. If you want the quick and dirty version, it's first up and will require you to simply click a couple times. If you want to become a spreadsheet speedrunner, read...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK