Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

script to pdf conversion

former_member841898
Participant
0 Likes
649

hi everybody,

i am trying to convert a script form to pdf format and downloading

it to a specific directory. I am using fm coversion otf and gui download,

everything is working fine but when i am attaching a logo to the form

and then trying to convert in the pdf format <b>program terminates</b>.

Error analysis shows that binary file size < 0.

Pls help me out regarding this matter.

thanks & regards

pankaj

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
592

data test(10) type c value 'ANEES'.

<b>DATA: BIN_SIZE TYPE I.</b>

DATA: I_ITCPO-TDGETOTF = 'X',

JOBOUTPUT TYPE SSFCRESCL,

OTF LIKE TABLE OF ITCOO with header line, " change with header line

<b>DOC LIKE TABLE OF DOCS,</b>

TLINES LIKE TABLE OF TLINE.

DATA : I_ITCPO LIKE ITCPO .

  • Mail settings

DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE. "SAPoffice: Description of Imported Object Components

DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE. "SAPoffice: Single List with Column Length 255

DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE. "SAPoffice: Single List with Column Length 255

DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE. "SAPoffice: Single List with Column Length 255

DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINe. "SAPoffice: Structure of the API Recipient List

DATA: doc_chng LIKE sodocchgi1. "Data of an object which can be changed

DATA righe_attachment TYPE i.

DATA righe_testo TYPE i.

DATA z_email(80) TYPE c.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • DEVICE = 'MAIL'

FORM = 'ZPDF1'

LANGUAGE = SY-LANGU

OPTIONS = I_ITCPO.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'E'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'.

CALL FUNCTION 'CLOSE_FORM'

TABLES

OTFDATA = OTF.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

BIN_FILESIZE = BIN_SIZE

TABLES

OTF = otf

DOCTAB_ARCHIVE = DOC

LINES = TLINES.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = BIN_SIZE

FILENAME = 'C:\anees\test.pdf'

FILETYPE = 'BIN'

TABLES

DATA_TAB = TLINES.

The above code is to convert the script to PDF and download to the local system.

It also contain the variable decleration which is used to send the PDF file as mail attachement. Dont get confuse.

Reward if helpfull.

Anees.

Message was edited by:

anees jawad

4 REPLIES 4
Read only

Former Member
0 Likes
592

Hi..

Use the Function module 'CONVERT_OTF_2_PDF'

Here is the example code.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • DEVICE = 'MAIL'

FORM = 'ZPDF1'

LANGUAGE = SY-LANGU

OPTIONS = I_ITCPO.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'E'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'.

CALL FUNCTION 'CLOSE_FORM'

TABLES

OTFDATA = OTF.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

BIN_FILESIZE = BIN_SIZE

TABLES

OTF = otf

DOCTAB_ARCHIVE = DOC

LINES = TLINES.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = BIN_SIZE

FILENAME = 'C:\anees\test.pdf'

FILETYPE = 'BIN'

TABLES

DATA_TAB = TLINES.

Reward if helpfull.

ANEES

9886358645

Read only

0 Likes
592

hi anees,

can u give me the full code, i.e. how to declare bin_size and

doc, i want the data declaration part.

thanks

pankaj

Read only

Former Member
0 Likes
593

data test(10) type c value 'ANEES'.

<b>DATA: BIN_SIZE TYPE I.</b>

DATA: I_ITCPO-TDGETOTF = 'X',

JOBOUTPUT TYPE SSFCRESCL,

OTF LIKE TABLE OF ITCOO with header line, " change with header line

<b>DOC LIKE TABLE OF DOCS,</b>

TLINES LIKE TABLE OF TLINE.

DATA : I_ITCPO LIKE ITCPO .

  • Mail settings

DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE. "SAPoffice: Description of Imported Object Components

DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE. "SAPoffice: Single List with Column Length 255

DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE. "SAPoffice: Single List with Column Length 255

DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE. "SAPoffice: Single List with Column Length 255

DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINe. "SAPoffice: Structure of the API Recipient List

DATA: doc_chng LIKE sodocchgi1. "Data of an object which can be changed

DATA righe_attachment TYPE i.

DATA righe_testo TYPE i.

DATA z_email(80) TYPE c.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • DEVICE = 'MAIL'

FORM = 'ZPDF1'

LANGUAGE = SY-LANGU

OPTIONS = I_ITCPO.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'E'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'.

CALL FUNCTION 'CLOSE_FORM'

TABLES

OTFDATA = OTF.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

BIN_FILESIZE = BIN_SIZE

TABLES

OTF = otf

DOCTAB_ARCHIVE = DOC

LINES = TLINES.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = BIN_SIZE

FILENAME = 'C:\anees\test.pdf'

FILETYPE = 'BIN'

TABLES

DATA_TAB = TLINES.

The above code is to convert the script to PDF and download to the local system.

It also contain the variable decleration which is used to send the PDF file as mail attachement. Dont get confuse.

Reward if helpfull.

Anees.

Message was edited by:

anees jawad

Read only

0 Likes
592

HELLO ANEES,

problem is solved by the socond code given by u.

awarded.

thanks and best wishes to u,

pankaj