Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
yashoratna
Participant
Introduction: With SAP's built-in standard function modules, such as "CONVERT OTF 2 PDF" or equivalent, we may convert OTF data to PDF format. However, despite extensive internet searches, I was unable to locate any FMs, blogs, or articles that addressed the reverse conversion—from PDF to OTF format.

I therefore considered sharing some code that will ultimately convert PDF data into OTF format. We can design a single module that will include a parameter for importing (PDF data) and a parameter for exporting (OTF data).

Importing Parameter: IV_PDF TYPE FPCONTENT (Form Processing: Content from XFT, XFD, PDF)

Exporting Parameter: ET_OTF_DATA TYPE TSFOTF (Smart Forms: Table OTF)

The OTF conversion code is straightforward but effective and useful for a variety of functionalities. In one business use case, the SAP CRM WEBUI screen has to display an Adobe form (CRM Actions in action profile under Post Processing Framework), which requires data conversion in OTF format.

Please check out below code snippet which accomplishes the required functionality.
DATA: lv_dummy    TYPE c,
lv_clen TYPE i,
lv_line(72) TYPE c,
lv_otf TYPE itcoo,
lv_len TYPE i,
lv_size TYPE i,
lv_hex(144) TYPE x.

FIELD-SYMBOLS: <l_fs> TYPE c.

CLEAR: et_otf_data.

DATA(lv_pdf) = iv_pdf.

lv_size = 72.
DESCRIBE FIELD lv_dummy LENGTH lv_clen IN BYTE MODE.
lv_size = lv_size * lv_clen.
lv_len = xstrlen( lv_pdf ).
WHILE lv_len > lv_size.
lv_hex(lv_size) = lv_pdf(lv_size).
ASSIGN lv_hex(lv_size) TO <l_fs> CASTING.
lv_line = <l_fs>.
lv_otf = lv_line.
APPEND lv_otf TO et_otf_data.
SHIFT lv_pdf LEFT BY lv_size PLACES IN BYTE MODE.
lv_len = xstrlen( lv_pdf ).
ENDWHILE.
IF lv_len > 0.
CLEAR: lv_hex, lv_otf, lv_line.
lv_hex = lv_pdf(lv_len).
ASSIGN lv_hex(lv_size) TO <l_fs> CASTING.
lv_line = <l_fs>.
lv_otf = lv_line.
APPEND lv_otf TO et_otf_data.
ENDIF.

CLEAR: lv_dummy,
lv_clen,
lv_line,
lv_otf,
lv_len,
lv_size,
lv_hex.
UNASSIGN : <l_fs>.

 

Thank you for reading this article, and please feel free to offer any insightful comments or recommendations.
3 Comments
Labels in this area