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

converting the layout from OTF format into PDF

Former Member
0 Likes
1,951

Hi Experts,

I am new to SMART FORMS,I don't have a clue about how to convert the layout from OTF format into PDF format and how to store it in Presentation server.

Please send me a Model program or step by step approach of the same.

Useful inputs will be rewarded higher points.

Thanks in Advance,

Dharani

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,712

You can use the function - CONVERT_OTF_2_PDF to convert to PDF. Once that is done, you can use the GUI_DOWNLOAD function.

Regards,

Ravi

note - Please makr all the helpful answers

Hi Experts,

I am new to SMART FORMS,I don't have a clue about how to convert the layout from OTF format into PDF format and how to store it in Presentation server.

Please send me a Model program or step by step approach of the same.

Useful inputs will be rewarded higher points.

Thanks in Advance,

Dharani

7 REPLIES 7
Read only

Former Member
0 Likes
1,713

You can use the function - CONVERT_OTF_2_PDF to convert to PDF. Once that is done, you can use the GUI_DOWNLOAD function.

Regards,

Ravi

note - Please makr all the helpful answers

Read only

Former Member
0 Likes
1,712

hi,

try this...

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZMPETS_CHARGEBACK'

IMPORTING

fm_name = fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • error handling

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

EXIT.

ENDIF.

*to get the smartform content**********

CALL FUNCTION fm_name

EXPORTING

control_parameters = fs_control_parameters

output_options = fs_output_options

hrdata = hrdata

actualdport = actualdport

actualweight = actualweight

entitlerate = entitlerate

actualrate = actualrate

shipdocno = shipdocnum

revno = revno

revdate = revdate

chargeamount = chargeamount

IMPORTING

job_output_info = fs_output_data

TABLES

it_shiphdr = int_shiphdr

it_167 = int_167

it_chargebk = int_chargebk

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*--> Convert to OTF format

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = wf_pdf_len

TABLES

otf = fs_output_data-otfdata

lines = int_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

IF sy-subrc <> 0.

WRITE 'error_otf'.

ENDIF.

<b>

reward if helpful..</b>

Regds,

Ajith

Read only

Former Member
0 Likes
1,712

Hi Dharani,

Check this Thread which is having sample programs also.

Regards,

Raghav

Read only

anversha_s
Active Contributor
0 Likes
1,712

hi,

<b><i>pls dont open same thread twice</i></b>

All you have to do is call your Smart Form to get OTF and then concert it to PDF. Works like charm:

sample code.

DATA: p_output_options TYPE ssfcompop,
p_control_parameters TYPE ssfctrlop.

p_control_parameters-no_dialog = 'X'.
p_control_parameters-getotf = 'X'.

CALL FUNCTION v_func_name "call your smartform
EXPORTING
output_options = p_output_options
control_parameters = p_control_parameters
IMPORTING
job_output_info = s_job_output_info.

call function 'CONVERT_OTF_2_PDF'
tables
otf = s_job_output_info-otfdata
lines = t_pdf.

and if u need more u can check below links also

Check the below links..

VISIT THIS LINK

also check sample programs

RSTXPDF4/5.

rgds

Anver

Read only

Former Member
0 Likes
1,712

Hi dharani,

1. while calling the FM for smartform,

2. also pass the parameter

job_output_info = w_job_info TYPE ssfcrescl,

where

data : w_job_info TYPE ssfcrescl.

3. then, after calling the FM,

4. IF NOT w_job_info-otfdata IS INITIAL.

5.

data : t_docs_tab TYPE TABLE OF docs,

t_pdf TYPE TABLE OF tline.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

  • EXPORTING

  • USE_OTF_MC_CMD = 'X'

  • ARCHIVE_INDEX =

IMPORTING

bin_filesize = w_file_size

TABLES

otf = w_job_info-otfdata

doctab_archive = t_docs_tab

lines = t_pdf

  • EXCEPTIONS

  • ERR_CONV_NOT_POSSIBLE = 1

  • ERR_OTF_MC_NOENDMARKER = 2

  • OTHERS = 3

.

regards,

amit m.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,712

Hi,

Here is the sample code.

  • Internal Table declarations

DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

i_tline TYPE TABLE OF tline WITH HEADER LINE,

i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,

i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,

  • Objects to send mail.

i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

  • Work Area declarations

w_objhead TYPE soli_tab,

w_ctrlop TYPE ssfctrlop,

w_compop TYPE ssfcompop,

w_return TYPE ssfcrescl,

w_doc_chng typE sodocchgi1,

w_data TYPE sodocchgi1,

w_buffer TYPE string,"To convert from 132 to 255

  • Variables declarations

v_form_name TYPE rs38l_fnam,

v_len_in LIKE sood-objlen,

v_len_out LIKE sood-objlen,

v_len_outn TYPE i,

v_lines_txt TYPE i,

v_lines_bin TYPE i.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZZZ_TEST2'

importing

fm_name = v_form_name

exceptions

no_form = 1

no_function_module = 2

others = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

w_ctrlop-getotf = 'X'.

w_ctrlop-no_dialog = 'X'.

w_compop-tdnoprev = 'X'.

CALL FUNCTION v_form_name

EXPORTING

control_parameters = w_ctrlop

output_options = w_compop

user_settings = 'X'

IMPORTING

job_output_info = w_return

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

i_otf[] = w_return-otfdata[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = v_len_in

TABLES

otf = i_otf

lines = i_tline

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Convert PDF from 132 to 255.

LOOP AT i_tline.

  • Replacing space by ~

TRANSLATE i_tline USING ' ~'.

CONCATENATE w_buffer i_tline INTO w_buffer.

ENDLOOP.

  • Replacing ~ by space

TRANSLATE w_buffer USING '~ '.

DO.

i_record = w_buffer.

  • Appending 255 characters as a record

APPEND i_record.

SHIFT w_buffer LEFT BY 255 PLACES.

IF w_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

Refresh: i_reclist,

i_objtxt,

i_objbin,

i_objpack.

clear w_objhead.

  • Object with PDF.

i_objbin[] = i_record[].

DESCRIBE TABLE i_objbin LINES v_lines_bin.

  • Object with main text of the mail.

i_objtxt = 'Find attached the output of the smart form.'.

APPEND i_objtxt.

i_objtxt = 'Regards,'.

APPEND i_objtxt.

i_objtxt = 'J.Jayanthi'.

APPEND i_objtxt.

DESCRIBE TABLE i_objtxt LINES v_lines_txt.

  • Document information.

w_doc_chng-obj_name = 'Smartform'.

w_doc_chng-expiry_dat = sy-datum + 10.

w_doc_chng-obj_descr = 'Smart form output'.

w_doc_chng-sensitivty = 'F'. "Functional object

w_doc_chng-doc_size = v_lines_txt * 255.

  • Pack to main body as RAW.

  • Obj. to be transported not in binary form

CLEAR i_objpack-transf_bin.

  • Start line of object header in transport packet

i_objpack-head_start = 1.

  • Number of lines of an object header in object packet

i_objpack-head_num = 0.

  • Start line of object contents in an object packet

i_objpack-body_start = 1.

  • Number of lines of the object contents in an object packet

i_objpack-body_num = v_lines_txt.

  • Code for document class

i_objpack-doc_type = 'RAW'.

APPEND i_objpack.

  • Packing as PDF.

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 1.

i_objpack-body_start = 1.

i_objpack-body_num = v_lines_bin.

i_objpack-doc_type = 'PDF'.

i_objpack-obj_name = 'Smartform'.

CONCATENATE 'Smartform_output' '.pdf'

INTO i_objpack-obj_descr.

i_objpack-doc_size = v_lines_bin * 255.

APPEND i_objpack.

  • Document information.

CLEAR i_reclist.

  • e-mail receivers.

i_reclist-receiver = '[email protected]'.

i_reclist-express = 'X'.

i_reclist-rec_type = 'U'. "Internet address

APPEND i_reclist.

  • Sending mail.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_doc_chng

put_in_outbox = 'X'

TABLES

packing_list = i_objpack

object_header = w_objhead

contents_hex = i_objbin

contents_txt = i_objtxt

receivers = i_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

Former Member
0 Likes
1,712

Hi Dharani,

Existing SAP Standard Program RSTXPDFT4 serves the purpose.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'YOUR FORM NAME'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = L_FNAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*--- Parameters to pass

WA_SSFCTRLOP-NO_DIALOG = SPACE.

WA_SSFCOMPOP-TDNOPREV = SPACE.

WA_SSFCOMPOP-TDNEWID = 'X'.

WA_SSFCOMPOP-TDDATASET = 'Your own text'.

WA_SSFCOMPOP-TDPRINTER = SPACE.

L_NOTNO = LV_NOTNO.

*--- This is Generated FM

CALL FUNCTION L_FNAME

EXPORTING

CONTROL_PARAMETERS = WA_SSFCTRLOP

OUTPUT_OPTIONS = WA_SSFCOMPOP

NOTNO = L_NOTNO

IMPORTING

JOB_OUTPUT_INFO = WA_SSFCRESCL.

*--- Get the value of Spool Request No. in WA_XID from the deep structure.

LOOP AT WA_SSFCRESCL-SPOOLIDS INTO WA_XID .

*--- RSTXPDFT4 is a SAP Standard Program which gives SMARTFORM output in

  • PDF Format. The parameter should be passed.

SUBMIT RSTXPDFT4

WITH DOWNLOAD EQ 'X'

WITH P_FILE EQ L_LOCATION

WITH SPOOLNO EQ WA_XID

AND RETURN.

ENDLOOP.

If you want Print Preview first and PDF file downloading next, then you have pass values to your Generated FM accordingly.

Thanks & Regards,

Karthikeyan G